knife-digital_ocean 2.1.0 → 2.2.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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Guardfile +1 -16
  6. data/README.md +112 -2
  7. data/knife-digital_ocean.gemspec +3 -0
  8. data/lib/chef/knife/digital_ocean_account_info.rb +45 -0
  9. data/lib/chef/knife/digital_ocean_domain_create.rb +55 -0
  10. data/lib/chef/knife/digital_ocean_domain_destroy.rb +43 -0
  11. data/lib/chef/knife/digital_ocean_domain_list.rb +44 -0
  12. data/lib/chef/knife/digital_ocean_domain_record_create.rb +78 -0
  13. data/lib/chef/knife/digital_ocean_domain_record_destroy.rb +54 -0
  14. data/lib/chef/knife/digital_ocean_domain_record_edit.rb +88 -0
  15. data/lib/chef/knife/digital_ocean_domain_record_list.rb +56 -0
  16. data/lib/chef/knife/digital_ocean_droplet_destroy.rb +29 -3
  17. data/lib/chef/knife/digital_ocean_sshkey_create.rb +54 -0
  18. data/lib/chef/knife/digital_ocean_sshkey_destroy.rb +43 -0
  19. data/lib/knife-digital_ocean/version.rb +1 -1
  20. data/spec/fixtures/vcr_cassettes/accountinfo.yml +65 -0
  21. data/spec/fixtures/vcr_cassettes/domainlist.yml +69 -0
  22. data/spec/fixtures/vcr_cassettes/public_images.yml +164 -0
  23. data/spec/lib/chef/knife/digital_ocean_account_info_spec.rb +37 -0
  24. data/spec/lib/chef/knife/digital_ocean_domain_create_spec.rb +5 -0
  25. data/spec/lib/chef/knife/digital_ocean_domain_destroy_spec.rb +5 -0
  26. data/spec/lib/chef/knife/digital_ocean_domain_list_spec.rb +38 -0
  27. data/spec/lib/chef/knife/digital_ocean_domain_record_create_spec.rb +5 -0
  28. data/spec/lib/chef/knife/digital_ocean_domain_record_destroy_spec.rb +5 -0
  29. data/spec/lib/chef/knife/digital_ocean_domain_record_edit_spec.rb +5 -0
  30. data/spec/lib/chef/knife/digital_ocean_domain_record_list_spec.rb +5 -0
  31. data/spec/lib/chef/knife/digital_ocean_image_list_spec.rb +14 -1
  32. data/spec/lib/chef/knife/digital_ocean_sshkey_create_spec.rb +5 -0
  33. data/spec/lib/chef/knife/digital_ocean_sshkey_destroy_spec.rb +5 -0
  34. data/spec/spec_helper.rb +26 -4
  35. metadata +83 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 529ea199eb79dd265a5596c4829c33c544625119
4
- data.tar.gz: dc1b77c699eaaaf00f840a86c278266fe01cf344
3
+ metadata.gz: 20219152d6de37594c8b08a29627e41e6e52d245
4
+ data.tar.gz: 18b24e2ef42827ca6052c5ee5e6828592bddd546
5
5
  SHA512:
6
- metadata.gz: 8b8777968d4b48e0d3cfb3bbdff2953443456ddd4aade58392db60c1ce8eb7559881627a9c1af581db3408d7f2785dde44d20a950c9e852f134c3811a6ae42e2
7
- data.tar.gz: 4705cb3ded89d46759fc75be597d764e7e6f552e85afa28857738fb096d41728c2a3703f189a3372f37739ade06ce4f13b64da69cdff5ee033a5d6af665b41c0
6
+ metadata.gz: 513bc8bcac02b559db21dfb4624773ef1742ae09dd2ce3406415faec61fdf3d29565b49ca77954635b8d2aa4ef4dfc4a465ed83ca6cf5fdb05a84ba0a5cc2aa8
7
+ data.tar.gz: 97b6fcae12fd43e3c06850a4bc418600e1c763cc9f00f94f3daf39d53e97e1ae6fa5a10f987fea3829584df6192133e6f27e814c4f85b89120ae18559afdcc93
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: 8aEdu9dp84Siy5yUaitdFV3NAqVpkfap1
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.2.0 / 2014-11-14
2
+
3
+ * Domain support, thanks to [@nozpheratu](https://github.com/nozpheratu) [PR #32]
4
+ * knife digital_ocean destroy -all, Thanks to [@yury-egorenkov](https://github.com/yury-egorenkov) [PR #41]
5
+ * New commands account info, sshkey create, sshkey destroy.
6
+
1
7
  ## 2.1.0 / 2014-11-09
2
8
 
3
9
  * Better test coverage
data/Guardfile CHANGED
@@ -1,23 +1,8 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec' do
4
+ guard :rspec, cmd: 'bundle exec rspec' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb') { 'spec' }
8
-
9
- # Rails example
10
- watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
- watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
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' }
16
-
17
- # Capybara features specs
18
- watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
-
20
- # Turnip features and steps
21
- watch(%r{^spec/acceptance/(.+)\.feature$})
22
- watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
8
  end
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![Build Status](https://travis-ci.org/rmoriz/knife-digital_ocean.png)](https://travis-ci.org/rmoriz/knife-digital_ocean)
6
6
  <a href="https://gemnasium.com/rmoriz/knife-digital_ocean"><img src="https://gemnasium.com/rmoriz/knife-digital_ocean.png"/></a>
7
7
  <a href="https://codeclimate.com/github/rmoriz/knife-digital_ocean"><img src="https://codeclimate.com/github/rmoriz/knife-digital_ocean.png"/></a>
8
+ [![Coverage Status](https://coveralls.io/repos/rmoriz/knife-digital_ocean/badge.png?branch=master)](https://coveralls.io/r/rmoriz/knife-digital_ocean?branch=master)
8
9
 
9
10
  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
11
  You can also use [knife-solo](http://matschaffer.github.com/knife-solo/) for chef bootstrapping or skip it altogether for another solution.
@@ -39,9 +40,37 @@ This plugin provides the following sub-commands:
39
40
  * knife digital_ocean size list (options)
40
41
  **Lists the available server sizes**
41
42
 
43
+ * knife digital_ocean domain create (options)
44
+ **Creates a domain name**
45
+
46
+ * knife digital_ocean domain destroy (options)
47
+ **Destroys a domain name**
48
+
49
+ * knife digital_ocean domain list
50
+ **Lists your domains added to Digital Ocean**
51
+
52
+ * knife digital_ocean domain record create (options)
53
+ **Creates a record for an existing domain**
54
+
55
+ * knife digital_ocean domain record destroy (options)
56
+ **Destroys a record for an existing domain**
57
+
58
+ * knife digital_ocean domain record list (options)
59
+ **Lists records for an existing domain**
60
+
61
+ * knife digital_ocean sshkey create (options)
62
+ **Creates a ssh key for use on digital ocean**
63
+
64
+ * knife digital_ocean sshkey destroy (options)
65
+ **Destroys the ssh key**
66
+
42
67
  * knife digital_ocean sshkey list
43
68
  **Lists name + id of the uploaded known ssh keys**
44
69
 
70
+ * knife digital_ocean account info
71
+ **Shows account information**
72
+
73
+
45
74
 
46
75
  ## Configuration
47
76
 
@@ -158,13 +187,23 @@ ID Name Size Region IPv4 Image
158
187
  23456 awesome-vm1.vm.io 512mb Amsterdam 1 185.14.124.125 25306 (Ubuntu 12.10 x32 Server) active
159
188
  ```
160
189
 
161
- ### Destroy a droplet (server) including all of its data!
190
+ ### !WARNING! Destroy a droplet (server) including all of its data!
162
191
 
192
+ #### Destroy droplet by id
163
193
  ```shell
164
194
  ➜ knife digital_ocean droplet destroy -S 23456
165
195
  OK
166
196
  ```
167
197
 
198
+ #### Destroy all droplets
199
+
200
+ ```shell
201
+ ➜ knife digital_ocean droplet destroy --all
202
+ Delete droplet with id: 1824315
203
+ Delete droplet with id: 1824316
204
+ Delete droplet with id: 1824317
205
+ ```
206
+
168
207
  ### List regions
169
208
 
170
209
  ```shell
@@ -254,7 +293,9 @@ ID Distribution Name Slug
254
293
  7556046 CoreOS CoreOS (alpha) 490.0.0 coreos-alpha
255
294
  ```
256
295
 
257
- ### SSH keys (previously uploaded via DigitalOcean's webfrontend)
296
+ ### SSH keys
297
+
298
+ #### List SSH keys
258
299
 
259
300
  ```shell
260
301
  ➜ knife digital_ocean sshkey list
@@ -265,6 +306,75 @@ ID Name Fingerprint
265
306
  1237 Craig f0:fa:2b:22:7f:bd:b2:cf:f2:4f:4c:18:3c:66:54:1c
266
307
  ```
267
308
 
309
+ #### Create a SSH key
310
+
311
+ ```shell
312
+ ➜ knife digital_ocean sshkey create -i ~/.ssh/id_rsa.pub -n Bob
313
+ ```
314
+
315
+ #### Destroy a SSH key
316
+
317
+ ```shell
318
+ ➜ knife digital_ocean sshkey destroy -i 1236
319
+ OK
320
+ ```
321
+
322
+ ### DNS
323
+
324
+ #### Create a domain
325
+
326
+ ```shell
327
+ ➜ knife digital_ocean domain create -N example.com -I 192.168.1.1
328
+ ```
329
+
330
+ #### Destroy a domain
331
+
332
+ ```shell
333
+ ➜ knife digital_ocean domain destroy -D example.com
334
+ OK
335
+ ```
336
+
337
+ #### List domains
338
+
339
+ ```shell
340
+ ➜ knife digital_ocean domain list
341
+ Name TTL
342
+ example.com 1800
343
+ ```
344
+
345
+ #### Create a domain record
346
+
347
+ ```shell
348
+ ➜ knife digital_ocean domain create -D example.com -T cname -N www -a @
349
+ ```
350
+
351
+ #### Destroy a domain record
352
+
353
+ ```shell
354
+ ➜ knife digital_ocean domain destroy -D example.com -R 3355880
355
+ OK
356
+ ```
357
+
358
+ #### List domain records
359
+
360
+ ```shell
361
+ ➜ knife digital_ocean domain record list -D example.com
362
+ ID Type Name Data
363
+ 3355877 NS @ ns1.digitalocean.com
364
+ 3355878 NS @ ns2.digitalocean.com
365
+ 3355879 NS @ ns3.digitalocean.com
366
+ 3355880 A @ 192.168.1.1
367
+ ```
368
+
369
+ ### Account Info
370
+
371
+ ```shell
372
+ ➜ knife digital_ocean account info
373
+ UUID Email Droplet Limit Email Verified
374
+ 58e2e737d3b7407b042aa7f99f4da4229166f2a1 joe@example.com 10 true
375
+ ```
376
+
377
+
268
378
  ## Contributing
269
379
 
270
380
  1. Fork it
@@ -22,6 +22,9 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'knife-solo'
23
23
  gem.add_development_dependency 'webmock', '~> 1.20'
24
24
  gem.add_development_dependency 'vcr', '~> 2.9'
25
+ gem.add_development_dependency 'guard', '~> 2.8'
26
+ gem.add_development_dependency 'guard-rspec', '~> 4.3'
27
+ gem.add_development_dependency 'coveralls'
25
28
 
26
29
  gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
27
30
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
@@ -0,0 +1,45 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/digital_ocean_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class DigitalOceanAccountInfo < Knife
18
+ include Knife::DigitalOceanBase
19
+
20
+ banner 'knife digital_ocean account info (options)'
21
+
22
+ def run
23
+ $stdout.sync = true
24
+
25
+ validate!
26
+
27
+ account_info = [
28
+ ui.color('UUID', :bold),
29
+ ui.color('Email', :bold),
30
+ ui.color('Droplet Limit', :bold),
31
+ ui.color('Email Verified', :bold)
32
+ ]
33
+
34
+ account = client.account.info
35
+
36
+ account_info << account.uuid.to_s
37
+ account_info << account.email.to_s
38
+ account_info << account.droplet_limit.to_s
39
+ account_info << account.email_verified.to_s
40
+
41
+ puts ui.list(account_info, :uneven_columns_across, 4)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,55 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+
14
+ require 'chef/knife/digital_ocean_base'
15
+
16
+ class Chef
17
+ class Knife
18
+ class DigitalOceanDomainCreate < Knife
19
+ include Knife::DigitalOceanBase
20
+
21
+ banner 'knife digital_ocean domain create (options)'
22
+
23
+ option :name,
24
+ :short => '-N NAME',
25
+ :long => '--name NAME',
26
+ :description => 'The domain name'
27
+
28
+ option :ip_address,
29
+ :short => '-I IP Address',
30
+ :long => '--ip-address address',
31
+ :description => 'The ip address'
32
+
33
+ def run
34
+ $stdout.sync = true
35
+
36
+ validate!
37
+
38
+ unless locate_config_value(:name)
39
+ ui.error("Name cannot be empty. => -N <domain-name>")
40
+ exit 1
41
+ end
42
+
43
+ unless locate_config_value(:ip_address)
44
+ ui.error("IP Address cannot be empty. => -I <ip-address>")
45
+ exit 1
46
+ end
47
+
48
+ domain = DropletKit::Domain.new ip_address: locate_config_value(:ip_address), name: locate_config_value(:name)
49
+ result = client.domains.create domain
50
+ ui.error JSON.parse(result)['message'] rescue 'OK'
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,43 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+
14
+ require 'chef/knife/digital_ocean_base'
15
+
16
+ class Chef
17
+ class Knife
18
+ class DigitalOceanDomainDestroy < Knife
19
+ include Knife::DigitalOceanBase
20
+
21
+ banner 'knife digital_ocean domain destroy (options)'
22
+
23
+ option :domain,
24
+ :short => '-D Name',
25
+ :long => '--domain-name Name',
26
+ :description => 'The domain name'
27
+
28
+ def run
29
+ $stdout.sync = true
30
+
31
+ validate!
32
+
33
+ unless locate_config_value(:domain)
34
+ ui.error("Domain cannot be empty. => -D <domain-name>")
35
+ exit 1
36
+ end
37
+
38
+ result = client.domains.delete(name: locate_config_value(:domain))
39
+ ui.error JSON.parse(result)['message'] rescue 'OK'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,44 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+ require 'chef/knife/digital_ocean_base'
14
+
15
+ class Chef
16
+ class Knife
17
+ class DigitalOceanDomainList < Knife
18
+ include Knife::DigitalOceanBase
19
+
20
+ banner 'knife digital_ocean domain list'
21
+
22
+ def run
23
+ $stdout.sync = true
24
+
25
+ validate!
26
+
27
+ domains_list = [
28
+ ui.color('Name', :bold),
29
+ ui.color('TTL', :bold)
30
+ ]
31
+
32
+ domains = client.domains.all
33
+
34
+ domains.each do |domain|
35
+ domains_list << domain.name.to_s
36
+ domains_list << domain.ttl.to_s
37
+ end
38
+
39
+ puts ui.list(domains_list, :uneven_columns_across, 2)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,78 @@
1
+ # Licensed under the Apache License, Version 2.0 (the "License");
2
+ # you may not use this file except in compliance with the License.
3
+ # You may obtain a copy of the License at
4
+ #
5
+ # http://www.apache.org/licenses/LICENSE-2.0
6
+ #
7
+ # Unless required by applicable law or agreed to in writing, software
8
+ # distributed under the License is distributed on an "AS IS" BASIS,
9
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ # See the License for the specific language governing permissions and
11
+ # limitations under the License.
12
+ #
13
+
14
+ require 'chef/knife/digital_ocean_base'
15
+
16
+ class Chef
17
+ class Knife
18
+ class DigitalOceanDomainRecordCreate < Knife
19
+ include Knife::DigitalOceanBase
20
+
21
+ banner 'knife digital_ocean domain record create (options)'
22
+
23
+ option :domain,
24
+ :short => '-D NAME',
25
+ :long => '--domain-id NAME',
26
+ :description => 'The domain name'
27
+
28
+ option :type,
29
+ :short => '-T RECORD TYPE',
30
+ :long => '--type RECORD TYPE',
31
+ :description => 'The type of record'
32
+
33
+ option :name,
34
+ :short => '-N RECORD NAME',
35
+ :long => '--name RECORD NAME',
36
+ :description => 'The record name'
37
+
38
+ option :data,
39
+ :short => '-a DATA',
40
+ :long => '--data DATA',
41
+ :description => 'The record data'
42
+
43
+ def run
44
+ $stdout.sync = true
45
+
46
+ validate!
47
+
48
+ unless locate_config_value(:domain)
49
+ ui.error("Domain cannot be empty. => -D <domain-id>")
50
+ exit 1
51
+ end
52
+
53
+ unless locate_config_value(:type)
54
+ ui.error("Record type cannot be empty. => -T <record-type>")
55
+ exit 1
56
+ end
57
+
58
+ unless locate_config_value(:name)
59
+ ui.error("Record name cannot be empty. => -N <record-name>")
60
+ exit 1
61
+ end
62
+
63
+ unless locate_config_value(:data)
64
+ ui.error("Record data cannot be empty. => -d <data>")
65
+ exit 1
66
+ end
67
+
68
+ domain_record = DropletKit::DomainRecord.new(
69
+ type: locate_config_value(:type),
70
+ name: locate_config_value(:name),
71
+ data: locate_config_value(:data)
72
+ )
73
+ result = client.domain_records.create domain_record, for_domain: locate_config_value(:domain)
74
+ ui.error JSON.parse(result)['message'] rescue 'OK'
75
+ end
76
+ end
77
+ end
78
+ end