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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 332005be8bd3b557afeaf4951fef63555ae0b425
4
- data.tar.gz: 627025c5258c0b5536bd624249f7bfd29ac65e4d
3
+ metadata.gz: a1d401db435fc6f27e515c65a389a56a6a5bd264
4
+ data.tar.gz: 53477ff41e28380766db1df3b496825ebb566fc4
5
5
  SHA512:
6
- metadata.gz: 471b6fa0448224595f7f72ca7e957f75fc6411c858c7ac9c429e283d10d449cac7a3ceff8885e0344d00484390508b0502cae468e1437dbba6b814c776095ea0
7
- data.tar.gz: 979834d8308f3ca504eb7b5cd43bdf8e9bc49a3b353352b791d67801956f0bc87384e510458bd9869101e3a5feb6c463dafaf7366e54a54118e3da5b3631800d
6
+ metadata.gz: e974ec260b01f0dccd8c82d4628b542c511b679e60c99a1d2106b005f494e7acf8a8508754573f1daf6de803cc03a7f2a9fb84776c808e74c622b78de0ff0f83
7
+ data.tar.gz: 97743644ebfc76074dd3cc18246c17271e2865efd102ccdf09ee80cb0302f9542193b23f26eb4bff49ae4b5c47b8e96763e5f8d012091ef142caf793ca14a091
data/.travis.yml CHANGED
@@ -1,12 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
- - 1.9.3
5
3
  - 2.0.0
6
4
  - 2.1.0
7
- - ruby-head
8
- matrix:
9
- allow_failures:
10
- - rvm: 1.8.7
11
- - rvm: ruby-head
12
- script: bundle exec rake test
5
+ script: bundle exec rake spec
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
- ## unreleased
1
+ ## 2.0.0 / 2014-11-07
2
+
3
+ * Now using Digital Ocean apiv2.
4
+ * Switched to the droplet_kit gem
5
+ * knife digital_ocean images list -G now replaced with -P or --public
6
+ * knife[:digital_ocean_api_key] and knife[:digital_ocean_client_id] replaced with knife[:digitalocean_access_token]
2
7
 
3
8
  * [Full Changelog](https://github.com/rmoriz/knife-digital_ocean/compare/v0.7.0...master)
4
9
 
data/Guardfile CHANGED
@@ -4,15 +4,15 @@
4
4
  guard 'rspec' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
- watch('spec/spec_helper.rb') { "spec" }
7
+ watch('spec/spec_helper.rb') { 'spec' }
8
8
 
9
9
  # Rails example
10
10
  watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
11
  watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
12
  watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
- watch('config/routes.rb') { "spec/routing" }
15
- watch('app/controllers/application_controller.rb') { "spec/controllers" }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
14
+ watch('config/routes.rb') { 'spec/routing' }
15
+ watch('app/controllers/application_controller.rb') { 'spec/controllers' }
16
16
 
17
17
  # Capybara features specs
18
18
  watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
@@ -21,4 +21,3 @@ guard 'rspec' do
21
21
  watch(%r{^spec/acceptance/(.+)\.feature$})
22
22
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
23
  end
24
-
data/README.md CHANGED
@@ -9,8 +9,7 @@
9
9
  This is a plugin for [Chef's](http://www.opscode.com/chef/) [knife](http://wiki.opscode.com/display/chef/Knife) tool. It allows you to bootstrap virtual machines with [DigitalOcean.com](https://www.digitalocean.com/) including the initial bootstrapping of chef on that system.
10
10
  You can also use [knife-solo](http://matschaffer.github.com/knife-solo/) for chef bootstrapping or skip it altogether for another solution.
11
11
 
12
- This knife plugin uses the [digital_ocean](https://github.com/rmoriz/digital_ocean) rubygem.
13
-
12
+ This knife plugin uses the [droplet_kit](https://github.com/digitalocean/droplet_kit) rubygem.
14
13
 
15
14
  ## Installation
16
15
 
@@ -18,7 +17,6 @@ This knife plugin uses the [digital_ocean](https://github.com/rmoriz/digital_oce
18
17
  ➜ gem install knife-digital_ocean
19
18
  ```
20
19
 
21
-
22
20
  ## Overview
23
21
 
24
22
  This plugin provides the following sub-commands:
@@ -50,8 +48,7 @@ This plugin provides the following sub-commands:
50
48
  The best way is to put your API-credentials of DigitalOcean in your knife.rb file of choice (e.g. in ```~/.chef/knife.rb```):
51
49
 
52
50
  ```ruby
53
- knife[:digital_ocean_client_id] = 'XXXXXXXXXXXX'
54
- knife[:digital_ocean_api_key] = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
51
+ knife[:digital_ocean_access_token] = 'YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY'
55
52
  ```
56
53
 
57
54
  ## Usage
@@ -69,23 +66,23 @@ use method **A**:
69
66
  __Examples__
70
67
 
71
68
  ```shell
72
- ➜ knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
73
- --image 25306 \
74
- --location 2 \
75
- --size 66 \
69
+ ➜ knife digital_ocean droplet create --server-name awesome-vm1.vm.io \
70
+ --image debian-7-0-x64 \
71
+ --location nyc3 \
72
+ --size 1gb \
76
73
  --ssh-keys 1234,1235 \
77
74
  --ssh-port 22
78
75
  ```
79
76
 
80
77
  ```shell
81
- ➜ knife digital_ocean droplet create --server-name awesome-vm2.chef.io \
82
- --image 25306 \
83
- --location 4 \
84
- --size 66 \
78
+ ➜ knife digital_ocean droplet create --server-name awesome-vm2.vm.io \
79
+ --image debian-7.0-x64 \
80
+ --location sfo1 \
81
+ --size 512mb \
85
82
  --ssh-keys 1234,1235 \
86
83
  --bootstrap \
87
84
  --run-list "role[base],role[webserver]" \
88
- --secret-file "~/.ssh/secret_file" \
85
+ --secret-file "/home/user/.ssh/secret_file" \
89
86
  --ssh-port 22 \
90
87
  --identity-file "~/.ssh/id_rsa" \
91
88
  --private_networking
@@ -95,9 +92,9 @@ __Syntax__
95
92
 
96
93
  ```shell
97
94
  ➜ knife digital_ocean droplet create --server-name <FQDN> \
98
- --image <IMAGE ID> \
99
- --location <REGION ID> \
100
- --size <SIZE ID> \
95
+ --image <IMAGE SLUG> \
96
+ --location <REGION SLUG> \
97
+ --size <SIZE SLUG> \
101
98
  --ssh-keys <SSH KEY-ID(s), comma-separated> \
102
99
  --ssh-port <SSH PORT> \
103
100
  --bootstrap \
@@ -110,9 +107,9 @@ __Short Syntax__
110
107
 
111
108
  ```shell
112
109
  ➜ knife digital_ocean droplet create -N <FQDN> \
113
- -I <IMAGE ID> \
114
- -L <REGION ID> \
115
- -S <SIZE ID> \
110
+ -I <IMAGE SLUG> \
111
+ -L <REGION SLUG> \
112
+ -S <SIZE SLUG> \
116
113
  -K <SSH KEY-ID(s), comma-separated> \
117
114
  -p <SSH PORT> \
118
115
  -B \
@@ -129,10 +126,10 @@ Please consult the [knife-solo documentation](http://matschaffer.github.io/knife
129
126
  __Example__
130
127
 
131
128
  ```bash
132
- ➜ knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
133
- --image 25306 \
134
- --location 2 \
135
- --size 66 \
129
+ ➜ knife digital_ocean droplet create --server-name awesome-vm1.vm.io \
130
+ --image debian-7-0-x64 \
131
+ --location lon1 \
132
+ --size 2gb \
136
133
  --ssh-keys 1234,4567 \
137
134
  --run-list "<RUNLIST>" \
138
135
  --solo
@@ -145,10 +142,10 @@ This will just create a droplet and return its IP-address. Nothing else. You can
145
142
  __Example__
146
143
 
147
144
  ```bash
148
- ➜ knife digital_ocean droplet create --server-name awesome-vm1.chef.io \
149
- --image 25306 \
150
- --location 2 \
151
- --size 66 \
145
+ ➜ knife digital_ocean droplet create --server-name awesome-vm1.vm.io \
146
+ --image debian-7-0-x64 \
147
+ --location lon1 \
148
+ --size 2gb \
152
149
  --ssh-keys 1234,4567
153
150
  ```
154
151
 
@@ -157,8 +154,8 @@ __Example__
157
154
  ```shell
158
155
  ➜ knife digital_ocean droplet list
159
156
  ID Name Size Region IPv4 Image Status
160
- 12345 app20.ams.nl.chef.io 1GB Amsterdam 1 185.14.123.123 25306 (Ubuntu 12.10 x32 Server) active
161
- 23456 awesome-vm1.chef.io 512MB Amsterdam 1 185.14.124.125 25306 (Ubuntu 12.10 x32 Server) active
157
+ 12345 app20.ams.nl.vm.io 1gb Amsterdam 1 185.14.123.123 25306 (Ubuntu 12.10 x32 Server) active
158
+ 23456 awesome-vm1.vm.io 512mb Amsterdam 1 185.14.124.125 25306 (Ubuntu 12.10 x32 Server) active
162
159
  ```
163
160
 
164
161
  ### Destroy a droplet (server) including all of its data!
@@ -172,29 +169,32 @@ OK
172
169
 
173
170
  ```shell
174
171
  ➜ knife digital_ocean region list
175
- ID Name
176
- 1 New York 1
177
- 2 Amsterdam 1
178
- 3 San Francisco 1
179
- 4 New York 2
180
- 5 Amsterdam 2
181
- 6 Singapore 1
172
+ Name Slug
173
+ New York 1 nyc1
174
+ Amsterdam 1 ams1
175
+ San Francisco 1 sfo1
176
+ New York 2 nyc2
177
+ Amsterdam 2 ams2
178
+ Singapore 1 sgp1
179
+ London 1 lon1
180
+ New York 3 nyc3
181
+ Amsterdam 3 ams3
182
182
  ```
183
183
 
184
184
  ### List sizes (instance types)
185
185
 
186
186
  ```shell
187
187
  ➜ knife digital_ocean size list
188
- ID Name
189
- 63 1GB
190
- 62 2GB
191
- 64 4GB
192
- 65 8GB
193
- 61 16GB
194
- 60 32GB
195
- 70 48GB
196
- 69 64GB
197
- 66 512MB
188
+ Slug
189
+ 512mb
190
+ 1gb
191
+ 2gb
192
+ 4gb
193
+ 8gb
194
+ 16gb
195
+ 32gb
196
+ 48gb
197
+ 64gb
198
198
  ```
199
199
 
200
200
  ### List images
@@ -203,74 +203,68 @@ ID Name
203
203
 
204
204
  ```shell
205
205
  ➜ knife digital_ocean image list
206
- ID Distribution Name Global
207
- 11111 Ubuntu app100.ams.nlxxxxx.net 2013-02-01 -
208
- 11112 Ubuntu app100.ams.nlxxxxx.net 2013-02-03 -
209
- 11113 Ubuntu init -
206
+ ID Distribution Name
207
+ 11111 Ubuntu app100.ams.nlxxxxx.net 2013-02-01
208
+ 11112 Ubuntu app100.ams.nlxxxxx.net 2013-02-03
209
+ 11113 Ubuntu init
210
210
  ```
211
211
 
212
-
213
- #### Global images (OS)
212
+ #### Public images (OS)
214
213
 
215
214
  ```shell
216
- ➜ knife digital_ocean image list --global
217
- ID Distribution Name Global
218
- 361740 Arch Linux Arch Linux 2013.05 x32 +
219
- 350424 Arch Linux Arch Linux 2013.05 x64 +
220
- 1602 CentOS CentOS 5.8 x32 +
221
- 1601 CentOS CentOS 5.8 x64 +
222
- 376568 CentOS CentOS 6.4 x32 +
223
- 562354 CentOS CentOS 6.4 x64 +
224
- 3240847 CentOS CentOS 6.5 x32 +
225
- 3240850 CentOS CentOS 6.5 x64 +
226
- 12575 Debian Debian 6.0 x32 +
227
- 12573 Debian Debian 6.0 x64 +
228
- 3102384 Debian Debian 7.0 x32 +
229
- 3102387 Debian Debian 7.0 x64 +
230
- 3102721 Fedora Fedora 19 x32 +
231
- 3102879 Fedora Fedora 19 x64 +
232
- 3243143 Fedora Fedora 20 x32 +
233
- 3243145 Fedora Fedora 20 x64 +
234
- 3104894 Ubuntu Docker 0.10 on Ubuntu 13.10 x64 +
235
- 3288841 Ubuntu Dokku v0.2.3 on Ubuntu 14.04 +
236
- 3121555 Ubuntu Ghost 0.4.2 on Ubuntu 12.04 +
237
- 3118238 Ubuntu GitLab 6.6.5 CE +
238
- 3120115 Ubuntu LAMP on Ubuntu 12.04 +
239
- 3118235 Ubuntu MEAN on Ubuntu 12.04.4 +
240
- 3137903 Ubuntu Redmine on Ubuntu 12.04 +
241
- 3137635 Ubuntu Ruby on Rails on Ubuntu 12.10 (Nginx + Unicorn) +
242
- 14098 Ubuntu Ubuntu 10.04 x32 +
243
- 14097 Ubuntu Ubuntu 10.04 x64 +
244
- 3100616 Ubuntu Ubuntu 12.04.4 x32 +
245
- 3101045 Ubuntu Ubuntu 12.04.4 x64 +
246
- 3101888 Ubuntu Ubuntu 12.10 x32 +
247
- 3101891 Ubuntu Ubuntu 12.10 x64 +
248
- 3104282 Ubuntu Ubuntu 12.10 x64 Desktop +
249
- 3101580 Ubuntu Ubuntu 13.10 x32 +
250
- 3101918 Ubuntu Ubuntu 13.10 x64 +
251
- 3240033 Ubuntu Ubuntu 14.04 x32 +
252
- 3240036 Ubuntu Ubuntu 14.04 x64 +
253
- 3135725 Ubuntu Wordpress on Ubuntu 13.10 +
215
+ ➜ knife digital_ocean image list --public
216
+ ID Distribution Name Slug
217
+ 6376601 Ubuntu Ruby on Rails on 14.04 (Nginx + Unicorn) ruby-on-rail
218
+ 6423475 Ubuntu WordPress on 14.04 wordpress
219
+ 6732690 Ubuntu LEMP on 14.04 lemp
220
+ 6732691 Ubuntu LAMP on 14.04 lamp
221
+ 6734341 Ubuntu node-v0.10.32 on 14.04 node
222
+ 6734697 Ubuntu Django on 14.04 django
223
+ 6738037 Ubuntu Dokku v0.2.3 on 14.04 (w/ Docker 1.2.0) dokku
224
+ 6798184 Ubuntu MEAN on 14.04 mean
225
+ 6854006 Ubuntu Drupal 7.32 on 14.04 drupal
226
+ 6884371 Ubuntu Magento 1.9.0.1 on 14.04 magento
227
+ 7284647 Ubuntu Ghost 0.5.3 on 14.04 ghost
228
+ 7354580 Ubuntu Docker 1.3.1 on 14.04 docker
229
+ 7518201 Ubuntu GitLab 7.4.3 CE on 14.04 gitlab
230
+ 7572830 Ubuntu Redmine on 14.04 redmine
231
+ 6370882 Fedora 20 x64 fedora-20-x6
232
+ 6370885 Fedora 20 x32 fedora-20-x3
233
+ 6370968 Fedora 19 x64 fedora-19-x6
234
+ 6370969 Fedora 19 x32 fedora-19-x3
235
+ 6372105 CentOS 6.5 x32 centos-6-5-x
236
+ 6372108 CentOS 6.5 x64 centos-6-5-x
237
+ 6372321 CentOS 5.10 x64 centos-5-8-x
238
+ 6372425 CentOS 5.10 x32 centos-5-8-x
239
+ 6372526 Debian 7.0 x64 debian-7-0-x
240
+ 6372528 Debian 7.0 x32 debian-7-0-x
241
+ 6372581 Debian 6.0 x64 debian-6-0-x
242
+ 6372662 Debian 6.0 x32 debian-6-0-x
243
+ 6374124 Ubuntu 10.04 x64 ubuntu-10-04
244
+ 6374125 Ubuntu 10.04 x32 ubuntu-10-04
245
+ 6374128 Ubuntu 12.04.5 x64 ubuntu-12-04
246
+ 6374130 Ubuntu 12.04.5 x32 ubuntu-12-04
247
+ 6882384 CoreOS 444.5.0 (beta) coreos-beta
248
+ 6886342 CoreOS 444.5.0 (stable) coreos-stabl
249
+ 6918735 Ubuntu 14.04 x32 ubuntu-14-04
250
+ 6918990 Ubuntu 14.04 x64 ubuntu-14-04
251
+ 7053293 CentOS 7.0 x64 centos-7-0-x
252
+ 7111343 Ubuntu 14.10 x64 ubuntu-14-10
253
+ 7111572 Ubuntu 14.10 x32 ubuntu-14-10
254
+ 7556046 CoreOS CoreOS (alpha) 490.0.0 coreos-alpha
254
255
  ```
255
256
 
256
-
257
257
  ### SSH keys (previously uploaded via DigitalOcean's webfrontend)
258
258
 
259
259
  ```shell
260
260
  ➜ knife digital_ocean sshkey list
261
- ID Name
262
- 1234 Alice
263
- 1235 Bob
264
- 1236 Chuck
265
- 1237 Craig
261
+ ID Name Fingerprint
262
+ 1234 Alice e0:1a:1b:30:7f:bd:b2:cf:f2:4f:3b:35:3c:87:46:1c
263
+ 1235 Bob b0:ca:40:36:7f:bd:b2:cf:f2:4f:2b:45:3c:28:41:5f
264
+ 1236 Chuck g0:da:3e:15:7f:bd:b2:cf:f2:4f:3a:26:3c:34:52:2b
265
+ 1237 Craig f0:fa:2b:22:7f:bd:b2:cf:f2:4f:4c:18:3c:66:54:1c
266
266
  ```
267
267
 
268
-
269
- ## Commercial Support
270
-
271
- Commercial support is available. Please contact [https://roland.io/](https://roland.io/) or [http://moriz.com/](http://moriz.com/)
272
-
273
-
274
268
  ## Contributing
275
269
 
276
270
  1. Fork it
@@ -290,20 +284,7 @@ For more information and a complete list see [the contributor page on GitHub](ht
290
284
 
291
285
  Apache 2.0 (like Chef itself), see LICENSE.txt file.
292
286
 
293
-
294
- ## Mobile Application
295
-
296
- Ever wanted to control your DigitalOcean Droplets with your iPhone, iPad or iPod Touch?
297
-
298
- [Get my CloudOcean App!](http://cloudoceanapp.com/)
299
-
300
- [![CloudOcean - DigitalOcean iOS app](http://i.imgur.com/JLQua2w.png)](http://cloudoceanapp.com/)
301
-
302
-
303
287
  ## Copyright
304
288
 
305
289
  Copyright © 2014 [Roland Moriz](https://roland.io), [Moriz GmbH](https://moriz.de/)
306
-
307
- [![LinkedIn](http://www.linkedin.com/img/webpromo/btn_viewmy_160x25.png)](http://www.linkedin.com/in/rmoriz)
308
- [![Twitter](http://i.imgur.com/1kYFHlu.png)](https://twitter.com/rmoriz)
309
-
290
+ Copyright © 2014 [Greg Fitzgerald](https://github.com/gregf)
data/Rakefile CHANGED
@@ -1,17 +1,17 @@
1
- #encoding: utf-8
1
+ # encoding: utf-8
2
2
  require 'rubygems'
3
3
  require 'bundler'
4
4
  Bundler.setup
5
5
  Bundler::GemHelper.install_tasks
6
6
 
7
7
  require 'rspec/core/rake_task'
8
- desc 'Run RSpec'
9
- RSpec::Core::RakeTask.new do |spec|
10
- spec.pattern = 'spec/**/*_spec.rb'
11
- spec.rspec_opts = ['--color', '--format nested']
12
- end
13
8
 
14
- desc 'Run rspec tests'
15
- task :test => [:spec]
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ require 'rubocop/rake_task'
12
+ desc 'Run RuboCop on the lib directory'
13
+ RuboCop::RakeTask.new(:rubocop) do |task|
14
+ task.patterns = ['lib/**/*.rb']
15
+ end
16
16
 
17
- task :default => :test
17
+ task default: :spec
@@ -6,23 +6,23 @@ require 'knife-digital_ocean/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'knife-digital_ocean'
8
8
  gem.version = Knife::DigitalOcean::VERSION
9
- gem.authors = ['Roland Moriz']
10
- gem.email = ['roland@moriz.de']
11
- gem.description = %q{A plugin for chef's knife to manage instances of DigitalOcean servers}
12
- gem.summary = %q{A plugin for chef's knife to manage instances of DigitalOcean servers}
9
+ gem.authors = ['Roland Moriz', 'Greg Fitzgerald']
10
+ gem.email = ['roland@moriz.de', 'greg@gregf.org']
11
+ gem.description = "A plugin for chef's knife to manage instances of DigitalOcean servers"
12
+ gem.summary = "A plugin for chef's knife to manage instances of DigitalOcean servers"
13
13
  gem.homepage = 'https://github.com/rmoriz/knife-digital_ocean'
14
14
  gem.license = 'Apache 2.0'
15
15
 
16
16
  gem.add_dependency 'chef', '>= 10.18'
17
- gem.add_dependency 'digital_ocean', '~> 1.5.0'
18
- gem.add_dependency 'highline'
17
+ gem.add_dependency 'droplet_kit', '~> 1.1.2'
19
18
 
20
- gem.add_development_dependency 'rspec', '~> 2.13'
19
+ gem.add_development_dependency 'rspec', '~> 3.1'
20
+ gem.add_development_dependency 'rubocop', '~> 0.27'
21
21
  gem.add_development_dependency 'rake'
22
22
  gem.add_development_dependency 'knife-solo'
23
23
 
24
- gem.files = `git ls-files`.split($/)
25
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
24
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
25
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
26
26
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
27
27
  gem.require_paths = ['lib']
28
28
  end
@@ -3,9 +3,9 @@
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
5
5
  # You may obtain a copy of the License at
6
- #
6
+ #
7
7
  # http://www.apache.org/licenses/LICENSE-2.0
8
- #
8
+ #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,10 +15,9 @@
15
15
  class Chef
16
16
  class Knife
17
17
  module DigitalOceanBase
18
-
19
18
  def self.load_deps
20
- require 'digital_ocean'
21
- require 'highline'
19
+ require 'droplet_kit'
20
+ require 'json'
22
21
  end
23
22
 
24
23
  def self.included(includer)
@@ -39,30 +38,19 @@ class Chef
39
38
  #
40
39
  deps { Chef::Knife::DigitalOceanBase.load_deps }
41
40
 
42
- option :digital_ocean_client_id,
43
- :short => '-K CLIENT_ID',
44
- :long => '--digital_ocean_client_id CLIENT_ID',
45
- :description => 'Your DigitalOcean client_id',
46
- :proc => Proc.new { |client_id| Chef::Config[:knife][:digital_ocean_client_id] = client_id }
47
-
48
- option :digital_ocean_api_key,
49
- :short => '-A API_KEY',
50
- :long => '--digital_ocean_api_key API_KEY',
51
- :description => 'Your DigitalOcean API_KEY',
52
- :proc => Proc.new { |api_key| Chef::Config[:knife][:digital_ocean_api_key] = api_key }
41
+ option :digital_ocean_access_token,
42
+ short: '-A ACCESS_TOKEN',
43
+ long: '--digital_ocean_access_token ACCESS_TOKEN',
44
+ description: 'Your DigitalOcean ACCESS_TOKEN',
45
+ proc: proc { |access_token| Chef::Config[:knife][:digital_ocean_access_token] = access_token }
53
46
  end
54
47
  end
55
48
 
56
- def h
57
- @highline ||= HighLine.new
58
- end
59
-
60
49
  def client
61
- DigitalOcean::API.new(:client_id => Chef::Config[:knife][:digital_ocean_client_id],
62
- :api_key => Chef::Config[:knife][:digital_ocean_api_key])
50
+ DropletKit::Client.new(access_token: Chef::Config[:knife][:digital_ocean_access_token])
63
51
  end
64
52
 
65
- def validate!(keys=[:digital_ocean_client_id, :digital_ocean_api_key])
53
+ def validate!(keys = [:digital_ocean_access_token])
66
54
  errors = []
67
55
 
68
56
  keys.each do |k|
@@ -71,7 +59,7 @@ class Chef
71
59
  end
72
60
  end
73
61
 
74
- if errors.each{|e| ui.error(e)}.any?
62
+ if errors.each { |e| ui.error(e) }.any?
75
63
  exit 1
76
64
  end
77
65
  end