knife-digital_ocean 0.7.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- h.color('ID', :bold),
29
- h.color('Name', :bold)
28
+ ui.color('Name', :bold),
29
+ ui.color('Slug', :bold)
30
30
  ]
31
31
 
32
- regions = client.regions.list.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.id.to_s
40
- region_list << region.name.to_s
35
+ region_list << region.name
36
+ region_list << region.slug
41
37
  end
42
38
 
43
- puts h.list(region_list, :uneven_columns_across, 2)
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
- h.color('ID', :bold),
29
- h.color('Name', :bold)
28
+ ui.color('Slug', :bold)
30
29
  ]
31
30
 
32
- sizes = client.sizes.list.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.id.to_s
40
- size_list << size.name.to_s
34
+ size_list << size.slug
41
35
  end
42
36
 
43
- puts h.list(size_list, :uneven_columns_across, 2)
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
- h.color('ID', :bold),
29
- h.color('Name', :bold),
28
+ ui.color('ID', :bold),
29
+ ui.color('Name', :bold),
30
+ ui.color('Fingerprint', :bold)
30
31
  ]
31
32
 
32
- sshkeys = client.ssh_keys.list.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 h.list(sshkey_list, :uneven_columns_across, 2)
41
+ puts ui.list(sshkey_list, :uneven_columns_across, 3)
44
42
  end
45
-
46
43
  end
47
44
  end
48
45
  end
@@ -1,4 +1,4 @@
1
- require "knife-digital_ocean/version"
1
+ require 'knife-digital_ocean/version'
2
2
 
3
3
  module Knife
4
4
  module DigitalOcean
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module DigitalOcean
3
- VERSION = '0.7.0'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -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.stub(:client).and_return double(DigitalOcean::API)
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
- :digital_ocean_client_id => 'CLIENT_ID',
18
- :digital_ocean_api_key => 'API_KEY',
19
- :server_name => 'sever-name.example.com',
20
- :image => 11111,
21
- :location => 22222,
22
- :size => 33333,
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
- :status => 'OK',
34
- :droplet => { :id => '123' }
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
- :bootstrap => true
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.stub_chain(:droplets, :create).and_return mock_api_response(api_response)
67
- s.stub(:ip_address_available).and_return '123.123.123.123'
68
- s.stub(:tcp_test_ssh).and_return true
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.should eql(Chef::Knife::Bootstrap)
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.any_instance.stub(:run)
78
- lambda { subject.run }.should_not raise_error(SystemExit)
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
- :solo => true
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.stub_chain(:droplets, :create).and_return mock_api_response(api_response)
100
- s.stub(:ip_address_available).and_return '123.123.123.123'
101
- s.stub(:tcp_test_ssh).and_return true
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.should eql(Chef::Knife::SoloBootstrap)
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.any_instance.should_receive(:run)
111
- Chef::Knife::Bootstrap.any_instance.should_not_receive(:run)
112
- lambda { subject.run }.should_not raise_error(SystemExit)
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.should_not_receive(:droplets)
124
- lambda { subject.run }.should raise_error(SystemExit)
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.stub_chain(:droplets, :create).and_return mock_api_response(api_response)
139
- s.stub(:ip_address_available).and_return '123.123.123.123'
140
- s.stub(:tcp_test_ssh).and_return true
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.should_not_receive(:bootstrap_for_node)
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.should eql(0)
152
- e.should be_a(SystemExit)
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
- :json_attributes => json_attributes
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].should eql(json_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
- :secret_file => secret_file
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].should eql(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
- :ssh_port => ssh_port
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].should eql(ssh_port)
195
+ expect(bootstrap.config[:ssh_port]).to eql(ssh_port)
197
196
  end
198
197
  end
199
198
 
200
199
  end
201
-
@@ -3,4 +3,3 @@ require 'spec_helper'
3
3
  describe Chef::Knife::DigitalOceanDropletDestroy do
4
4
  pending
5
5
  end
6
-
@@ -3,4 +3,3 @@ require 'spec_helper'
3
3
  describe Chef::Knife::DigitalOceanDropletList do
4
4
  pending
5
5
  end
6
-
@@ -3,4 +3,3 @@ require 'spec_helper'
3
3
  describe Chef::Knife::DigitalOceanImageList do
4
4
  pending
5
5
  end
6
-
@@ -3,4 +3,3 @@ require 'spec_helper'
3
3
  describe Chef::Knife::DigitalOceanRegionList do
4
4
  pending
5
5
  end
6
-
@@ -3,4 +3,3 @@ require 'spec_helper'
3
3
  describe Chef::Knife::DigitalOceanSizeList do
4
4
  pending
5
5
  end
6
-
@@ -3,4 +3,3 @@ require 'spec_helper'
3
3
  describe Chef::Knife::DigitalOceanSshkeyList do
4
4
  pending
5
5
  end
6
-
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe Knife::DigitalOcean do
4
4
  it 'should have a VERSION defined' do
5
- described_class::VERSION.should_not be_empty
5
+ expect(described_class::VERSION).not_to be_empty
6
6
  end
7
7
  end
8
-
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'rspec/autorun'
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.7.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-05-21 00:00:00.000000000 Z
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: digital_ocean
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.5.0
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.5.0
41
+ version: 1.1.2
41
42
  - !ruby/object:Gem::Dependency
42
- name: highline
43
+ name: rspec
43
44
  requirement: !ruby/object:Gem::Requirement
44
45
  requirements:
45
- - - ">="
46
+ - - "~>"
46
47
  - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
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: '0'
55
+ version: '3.1'
55
56
  - !ruby/object:Gem::Dependency
56
- name: rspec
57
+ name: rubocop
57
58
  requirement: !ruby/object:Gem::Requirement
58
59
  requirements:
59
60
  - - "~>"
60
61
  - !ruby/object:Gem::Version
61
- version: '2.13'
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: '2.13'
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.2.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