Skip to content

Commit 105c1a1

Browse files
committed
Merge pull request #235 from pearkes/fix_ssh_key_array_from_config
Fix to allow setting an array of keys in config
2 parents dcf00b6 + 0d903fd commit 105c1a1

File tree

4 files changed

+107
-4
lines changed

4 files changed

+107
-4
lines changed

features/cassettes/config/Array_of_SSH_Keys_in_Config.yml

Lines changed: 68 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/step_definitions/steps.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'erb'
2+
3+
Given(/^a '\.tugboat' config with data:$/) do |data_str|
4+
data = ERB.new(data_str).result(binding)
5+
File.write("#{Dir.pwd}/tmp/aruba/.tugboat", data)
6+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Feature: config
2+
In order to have an easier time connecting to droplets
3+
As a user
4+
I should be able to supply an array of ssh keys for a machine
5+
6+
@vcr
7+
Scenario: Array of SSH Keys in Config
8+
Given a '.tugboat' config with data:
9+
"""
10+
---
11+
authentication:
12+
access_token: f8sazukxeh729ggxh9gjavvzw5cabdpq95txpzhz6ep6jvtquxztfkf2chyejcsg5
13+
ssh:
14+
ssh_user: bobby_sousa
15+
ssh_key_path: "~/.ssh/id_rsa"
16+
ssh_port: '22'
17+
defaults:
18+
region: nyc2
19+
image: ubuntu-14-04-x64
20+
size: 512mb
21+
ssh_key: ['1234','5678']
22+
private_networking: 'false'
23+
backups_enabled: 'false'
24+
ip6: 'false'
25+
"""
26+
When I run `tugboat create droplet-with-array-of-keys`
27+
Then the exit status should not be 1
28+
And the output should contain "Queueing creation of droplet 'droplet-with-array-of-keys'...Droplet created!"

lib/tugboat/middleware/create_droplet.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ def call(env)
4747
droplet_backups_enabled = env["create_droplet_backups_enabled"] :
4848
droplet_backups_enabled = env["config"].default_backups_enabled
4949

50-
droplet_key_array = droplet_ssh_key_ids.split(',')
51-
52-
droplet_key_array = nil if [droplet_key_array].empty?
53-
50+
if droplet_ssh_key_ids.kind_of?(Array)
51+
droplet_key_array = droplet_ssh_key_ids
52+
else
53+
droplet_key_array = droplet_ssh_key_ids.split(',')
54+
end
5455

5556
create_opts = {
5657
:name => env["create_droplet_name"],

0 commit comments

Comments
 (0)