knife-digital_ocean 0.7.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -8
- data/CHANGELOG.md +6 -1
- data/Guardfile +4 -5
- data/README.md +98 -117
- data/Rakefile +9 -9
- data/knife-digital_ocean.gemspec +9 -9
- data/lib/chef/knife/digital_ocean_base.rb +12 -24
- data/lib/chef/knife/digital_ocean_droplet_create.rb +102 -101
- data/lib/chef/knife/digital_ocean_droplet_destroy.rb +8 -9
- data/lib/chef/knife/digital_ocean_droplet_list.rb +16 -34
- data/lib/chef/knife/digital_ocean_image_list.rb +18 -31
- data/lib/chef/knife/digital_ocean_region_list.rb +8 -12
- data/lib/chef/knife/digital_ocean_size_list.rb +6 -12
- data/lib/chef/knife/digital_ocean_sshkey_list.rb +8 -11
- data/lib/knife-digital_ocean.rb +1 -1
- data/lib/knife-digital_ocean/version.rb +1 -1
- data/spec/lib/chef/knife/digital_ocean_droplet_create_spec.rb +64 -66
- data/spec/lib/chef/knife/digital_ocean_droplet_destroy_spec.rb +0 -1
- data/spec/lib/chef/knife/digital_ocean_droplet_list_spec.rb +0 -1
- data/spec/lib/chef/knife/digital_ocean_image_list_spec.rb +0 -1
- data/spec/lib/chef/knife/digital_ocean_region_list_spec.rb +0 -1
- data/spec/lib/chef/knife/digital_ocean_size_list_spec.rb +0 -1
- data/spec/lib/chef/knife/digital_ocean_sshkey_list_spec.rb +0 -1
- data/spec/lib/knife-digital_ocean/version_spec.rb +1 -2
- data/spec/spec_helper.rb +2 -4
- metadata +17 -15
@@ -1,9 +1,9 @@
|
|
1
1
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
2
|
# you may not use this file except in compliance with the License.
|
3
3
|
# You may obtain a copy of the License at
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Unless required by applicable law or agreed to in writing, software
|
8
8
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
9
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -25,22 +25,18 @@ class Chef
|
|
25
25
|
validate!
|
26
26
|
|
27
27
|
region_list = [
|
28
|
-
|
29
|
-
|
28
|
+
ui.color('Name', :bold),
|
29
|
+
ui.color('Slug', :bold)
|
30
30
|
]
|
31
31
|
|
32
|
-
regions = client.regions.
|
33
|
-
|
34
|
-
regions.sort! do |a, b|
|
35
|
-
a.name.to_i <=> b.name.to_i
|
36
|
-
end
|
32
|
+
regions = client.regions.all
|
37
33
|
|
38
34
|
regions.each do |region|
|
39
|
-
region_list << region.
|
40
|
-
region_list << region.
|
35
|
+
region_list << region.name
|
36
|
+
region_list << region.slug
|
41
37
|
end
|
42
38
|
|
43
|
-
puts
|
39
|
+
puts ui.list(region_list, :uneven_columns_across, 2)
|
44
40
|
end
|
45
41
|
end
|
46
42
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
2
|
# you may not use this file except in compliance with the License.
|
3
3
|
# You may obtain a copy of the License at
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Unless required by applicable law or agreed to in writing, software
|
8
8
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
9
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -25,22 +25,16 @@ class Chef
|
|
25
25
|
validate!
|
26
26
|
|
27
27
|
size_list = [
|
28
|
-
|
29
|
-
h.color('Name', :bold)
|
28
|
+
ui.color('Slug', :bold)
|
30
29
|
]
|
31
30
|
|
32
|
-
sizes = client.sizes.
|
33
|
-
|
34
|
-
sizes.sort! do |a, b|
|
35
|
-
a.name.to_i <=> b.name.to_i
|
36
|
-
end
|
31
|
+
sizes = client.sizes.all
|
37
32
|
|
38
33
|
sizes.each do |size|
|
39
|
-
size_list << size.
|
40
|
-
size_list << size.name.to_s
|
34
|
+
size_list << size.slug
|
41
35
|
end
|
42
36
|
|
43
|
-
puts
|
37
|
+
puts ui.list(size_list, :uneven_columns_across, 1)
|
44
38
|
end
|
45
39
|
end
|
46
40
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
2
2
|
# you may not use this file except in compliance with the License.
|
3
3
|
# You may obtain a copy of the License at
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Unless required by applicable law or agreed to in writing, software
|
8
8
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
9
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -25,24 +25,21 @@ class Chef
|
|
25
25
|
validate!
|
26
26
|
|
27
27
|
sshkey_list = [
|
28
|
-
|
29
|
-
|
28
|
+
ui.color('ID', :bold),
|
29
|
+
ui.color('Name', :bold),
|
30
|
+
ui.color('Fingerprint', :bold)
|
30
31
|
]
|
31
32
|
|
32
|
-
sshkeys = client.ssh_keys.
|
33
|
-
|
34
|
-
sshkeys.sort! do |a, b|
|
35
|
-
a.name <=> b.name
|
36
|
-
end
|
33
|
+
sshkeys = client.ssh_keys.all
|
37
34
|
|
38
35
|
sshkeys.each do |sshkey|
|
39
36
|
sshkey_list << sshkey.id.to_s
|
40
37
|
sshkey_list << sshkey.name.to_s
|
38
|
+
sshkey_list << sshkey.fingerprint.to_s
|
41
39
|
end
|
42
40
|
|
43
|
-
puts
|
41
|
+
puts ui.list(sshkey_list, :uneven_columns_across, 3)
|
44
42
|
end
|
45
|
-
|
46
43
|
end
|
47
44
|
end
|
48
45
|
end
|
data/lib/knife-digital_ocean.rb
CHANGED
@@ -6,34 +6,33 @@ end
|
|
6
6
|
|
7
7
|
describe Chef::Knife::DigitalOceanDropletCreate do
|
8
8
|
|
9
|
-
subject
|
9
|
+
subject do
|
10
10
|
s = Chef::Knife::DigitalOceanDropletCreate.new
|
11
|
-
s.
|
11
|
+
allow(s).to receive(:client).and_return double(DropletKit::Droplet)
|
12
12
|
s
|
13
|
-
|
13
|
+
end
|
14
14
|
|
15
|
-
let(:config)
|
15
|
+
let(:config) do
|
16
16
|
{
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:ssh_key_ids => [ 44444, 44445 ]
|
17
|
+
digital_ocean_access_token: 'ACCESS_TOKEN',
|
18
|
+
server_name: 'sever-name.example.com',
|
19
|
+
image: 11_111,
|
20
|
+
location: 22_222,
|
21
|
+
size: 33_333,
|
22
|
+
ssh_key_ids: [44_444, 44_445]
|
24
23
|
}
|
25
|
-
|
24
|
+
end
|
26
25
|
|
27
|
-
let(:custom_config)
|
26
|
+
let(:custom_config) do
|
28
27
|
{}
|
29
|
-
|
28
|
+
end
|
30
29
|
|
31
|
-
let(:api_response)
|
30
|
+
let(:api_response) do
|
32
31
|
{
|
33
|
-
:
|
34
|
-
:
|
32
|
+
status: 'OK',
|
33
|
+
droplet: { id: '123' }
|
35
34
|
}
|
36
|
-
|
35
|
+
end
|
37
36
|
|
38
37
|
before do
|
39
38
|
Chef::Knife::DigitalOceanDropletCreate.load_deps
|
@@ -54,39 +53,39 @@ describe Chef::Knife::DigitalOceanDropletCreate do
|
|
54
53
|
end
|
55
54
|
|
56
55
|
context 'bootstrapping for chef-server' do
|
57
|
-
let(:custom_config)
|
56
|
+
let(:custom_config) do
|
58
57
|
{
|
59
|
-
|
58
|
+
bootstrap: true
|
60
59
|
}
|
61
|
-
|
60
|
+
end
|
62
61
|
|
63
62
|
describe 'should use the default bootstrap class' do
|
64
|
-
let(:subject)
|
63
|
+
let(:subject) do
|
65
64
|
s = super()
|
66
|
-
s.client.
|
67
|
-
s.
|
68
|
-
s.
|
65
|
+
allow(s.client).to receive_message_chain(:droplets, :create).and_return mock_api_response(api_response)
|
66
|
+
allow(s).to receive(:ip_address_available).and_return '123.123.123.123'
|
67
|
+
allow(s).to receive(:tcp_test_ssh).and_return true
|
69
68
|
s
|
70
|
-
|
69
|
+
end
|
71
70
|
|
72
71
|
it 'should use the right bootstrap class' do
|
73
|
-
subject.bootstrap_class.
|
72
|
+
expect(subject.bootstrap_class).to eql(Chef::Knife::Bootstrap)
|
74
73
|
end
|
75
74
|
|
76
75
|
it 'should call #run on the bootstrap class' do
|
77
|
-
Chef::Knife::Bootstrap.
|
78
|
-
|
76
|
+
allow_any_instance_of(Chef::Knife::Bootstrap).to receive(:run)
|
77
|
+
expect { subject.run }.not_to raise_error
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
83
82
|
context 'bootstrapping for knife-solo' do
|
84
83
|
|
85
|
-
let(:custom_config)
|
84
|
+
let(:custom_config) do
|
86
85
|
{
|
87
|
-
|
86
|
+
solo: true
|
88
87
|
}
|
89
|
-
|
88
|
+
end
|
90
89
|
|
91
90
|
describe 'when knife-solo is installed' do
|
92
91
|
before do
|
@@ -94,22 +93,22 @@ describe Chef::Knife::DigitalOceanDropletCreate do
|
|
94
93
|
require 'chef/knife/solo_bootstrap'
|
95
94
|
end
|
96
95
|
|
97
|
-
let(:subject)
|
96
|
+
let(:subject) do
|
98
97
|
s = super()
|
99
|
-
s.client.
|
100
|
-
s.
|
101
|
-
s.
|
98
|
+
allow(s.client).to receive_message_chain(:droplets, :create).and_return mock_api_response(api_response)
|
99
|
+
allow(s).to receive(:ip_address_available).and_return '123.123.123.123'
|
100
|
+
allow(s).to receive(:tcp_test_ssh).and_return true
|
102
101
|
s
|
103
|
-
|
102
|
+
end
|
104
103
|
|
105
104
|
it 'should use the right bootstrap class' do
|
106
|
-
subject.bootstrap_class.
|
105
|
+
expect(subject.bootstrap_class).to eql(Chef::Knife::SoloBootstrap)
|
107
106
|
end
|
108
107
|
|
109
108
|
it 'should call #run on the bootstrap class' do
|
110
|
-
Chef::Knife::SoloBootstrap.
|
111
|
-
Chef::Knife::Bootstrap.
|
112
|
-
|
109
|
+
expect_any_instance_of(Chef::Knife::SoloBootstrap).to receive(:run)
|
110
|
+
expect_any_instance_of(Chef::Knife::Bootstrap).not_to receive(:run)
|
111
|
+
expect { subject.run }.not_to raise_error
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
@@ -120,36 +119,36 @@ describe Chef::Knife::DigitalOceanDropletCreate do
|
|
120
119
|
end
|
121
120
|
|
122
121
|
it 'should not create a droplet' do
|
123
|
-
subject.client.
|
124
|
-
|
122
|
+
expect(subject.client).not_to receive(:droplets)
|
123
|
+
expect { subject.run }.to raise_error(SystemExit)
|
125
124
|
end
|
126
125
|
end
|
127
126
|
|
128
127
|
end
|
129
128
|
|
130
129
|
context 'no bootstrapping' do
|
131
|
-
let(:custom_config)
|
130
|
+
let(:custom_config) do
|
132
131
|
{}
|
133
|
-
|
132
|
+
end
|
134
133
|
|
135
134
|
describe 'should not do any bootstrapping' do
|
136
|
-
let(:subject)
|
135
|
+
let(:subject) do
|
137
136
|
s = super()
|
138
|
-
s.client.
|
139
|
-
s.
|
140
|
-
s.
|
137
|
+
allow(s.client).to receive_message_chain(:droplets, :create).and_return mock_api_response(api_response)
|
138
|
+
allow(s).to receive(:ip_address_available).and_return '123.123.123.123'
|
139
|
+
allow(s).to receive(:tcp_test_ssh).and_return true
|
141
140
|
s
|
142
|
-
|
141
|
+
end
|
143
142
|
|
144
143
|
it 'should call #bootstrap_for_node' do
|
145
|
-
subject.
|
144
|
+
expect(subject).not_to receive(:bootstrap_for_node)
|
146
145
|
expect { subject.run }.to raise_error
|
147
146
|
end
|
148
147
|
|
149
148
|
it 'should have a 0 exit code' do
|
150
149
|
expect { subject.run }.to raise_error { |e|
|
151
|
-
e.status.
|
152
|
-
e.
|
150
|
+
expect(e.status).to eql(0)
|
151
|
+
expect(e).to be_a(SystemExit)
|
153
152
|
}
|
154
153
|
end
|
155
154
|
end
|
@@ -157,45 +156,44 @@ describe Chef::Knife::DigitalOceanDropletCreate do
|
|
157
156
|
|
158
157
|
context 'passing json attributes (-j)' do
|
159
158
|
let(:json_attributes) { '{ "apache": { "listen_ports": 80 } }' }
|
160
|
-
let(:custom_config)
|
159
|
+
let(:custom_config) do
|
161
160
|
{
|
162
|
-
|
161
|
+
json_attributes: json_attributes
|
163
162
|
}
|
164
|
-
|
163
|
+
end
|
165
164
|
|
166
165
|
it 'should configure the first boot attributes on Bootstrap' do
|
167
166
|
bootstrap = subject.bootstrap_for_node('123.123.123.123')
|
168
|
-
bootstrap.config[:first_boot_attributes].
|
167
|
+
expect(bootstrap.config[:first_boot_attributes]).to eql(json_attributes)
|
169
168
|
end
|
170
169
|
end
|
171
170
|
|
172
171
|
context 'passing secret_file (--secret-file)' do
|
173
172
|
let(:secret_file) { '/tmp/sekretfile' }
|
174
|
-
let(:custom_config)
|
173
|
+
let(:custom_config) do
|
175
174
|
{
|
176
|
-
|
175
|
+
secret_file: secret_file
|
177
176
|
}
|
178
|
-
|
177
|
+
end
|
179
178
|
|
180
179
|
it 'secret_file should be available to Bootstrap' do
|
181
180
|
bootstrap = subject.bootstrap_for_node('123.123.123.123')
|
182
|
-
bootstrap.config[:secret_file].
|
181
|
+
expect(bootstrap.config[:secret_file]).to eql(secret_file)
|
183
182
|
end
|
184
183
|
end
|
185
184
|
|
186
185
|
context 'passing ssh_port (--ssh-port)' do
|
187
186
|
let(:ssh_port) { 22 }
|
188
|
-
let(:custom_config)
|
187
|
+
let(:custom_config) do
|
189
188
|
{
|
190
|
-
|
189
|
+
ssh_port: ssh_port
|
191
190
|
}
|
192
|
-
|
191
|
+
end
|
193
192
|
|
194
193
|
it 'ssh_port should be available to Bootstrap' do
|
195
194
|
bootstrap = subject.bootstrap_for_node('123.123.123.123')
|
196
|
-
bootstrap.config[:ssh_port].
|
195
|
+
expect(bootstrap.config[:ssh_port]).to eql(ssh_port)
|
197
196
|
end
|
198
197
|
end
|
199
198
|
|
200
199
|
end
|
201
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
-
require '
|
3
|
-
|
4
|
-
require 'digital_ocean'
|
2
|
+
require 'droplet_kit'
|
5
3
|
require 'hashie'
|
6
4
|
|
7
5
|
require 'chef/knife'
|
@@ -13,4 +11,4 @@ require 'chef/knife/digital_ocean_region_list'
|
|
13
11
|
require 'chef/knife/digital_ocean_size_list'
|
14
12
|
require 'chef/knife/digital_ocean_sshkey_list'
|
15
13
|
|
16
|
-
Dir['./spec/support/**/*.rb'].sort.each {|f| require f}
|
14
|
+
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-digital_ocean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roland Moriz
|
8
|
+
- Greg Fitzgerald
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
+
date: 2014-11-07 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: chef
|
@@ -25,47 +26,47 @@ dependencies:
|
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '10.18'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
+
name: droplet_kit
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
32
|
- - "~>"
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
34
|
+
version: 1.1.2
|
34
35
|
type: :runtime
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
39
|
- - "~>"
|
39
40
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
41
|
+
version: 1.1.2
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
+
name: rspec
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - "
|
46
|
+
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :
|
48
|
+
version: '3.1'
|
49
|
+
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- - "
|
53
|
+
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
+
version: '3.1'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
57
|
+
name: rubocop
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
60
|
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
62
|
+
version: '0.27'
|
62
63
|
type: :development
|
63
64
|
prerelease: false
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
+
version: '0.27'
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
71
|
name: rake
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,6 +98,7 @@ dependencies:
|
|
97
98
|
description: A plugin for chef's knife to manage instances of DigitalOcean servers
|
98
99
|
email:
|
99
100
|
- roland@moriz.de
|
101
|
+
- greg@gregf.org
|
100
102
|
executables: []
|
101
103
|
extensions: []
|
102
104
|
extra_rdoc_files: []
|
@@ -149,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
151
|
version: '0'
|
150
152
|
requirements: []
|
151
153
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.4.2
|
153
155
|
signing_key:
|
154
156
|
specification_version: 4
|
155
157
|
summary: A plugin for chef's knife to manage instances of DigitalOcean servers
|