tugboat 1.3.1 → 2.0.0.RC1

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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +12 -8
  4. data/lib/tugboat/cli.rb +8 -7
  5. data/lib/tugboat/config.rb +8 -12
  6. data/lib/tugboat/middleware/add_key.rb +9 -6
  7. data/lib/tugboat/middleware/ask_for_credentials.rb +7 -8
  8. data/lib/tugboat/middleware/check_configuration.rb +1 -1
  9. data/lib/tugboat/middleware/check_credentials.rb +4 -2
  10. data/lib/tugboat/middleware/config.rb +3 -4
  11. data/lib/tugboat/middleware/create_droplet.rb +32 -26
  12. data/lib/tugboat/middleware/destroy_droplet.rb +6 -6
  13. data/lib/tugboat/middleware/destroy_image.rb +6 -6
  14. data/lib/tugboat/middleware/find_droplet.rb +20 -16
  15. data/lib/tugboat/middleware/find_image.rb +17 -10
  16. data/lib/tugboat/middleware/halt_droplet.rb +8 -8
  17. data/lib/tugboat/middleware/info_droplet.rb +38 -25
  18. data/lib/tugboat/middleware/info_image.rb +5 -5
  19. data/lib/tugboat/middleware/inject_client.rb +3 -9
  20. data/lib/tugboat/middleware/list_droplets.rb +6 -4
  21. data/lib/tugboat/middleware/list_images.rb +28 -23
  22. data/lib/tugboat/middleware/list_regions.rb +3 -3
  23. data/lib/tugboat/middleware/list_sizes.rb +3 -3
  24. data/lib/tugboat/middleware/list_ssh_keys.rb +5 -4
  25. data/lib/tugboat/middleware/password_reset.rb +7 -7
  26. data/lib/tugboat/middleware/rebuild_droplet.rb +8 -8
  27. data/lib/tugboat/middleware/resize_droplet.rb +7 -7
  28. data/lib/tugboat/middleware/restart_droplet.rb +8 -8
  29. data/lib/tugboat/middleware/snapshot_droplet.rb +6 -6
  30. data/lib/tugboat/middleware/ssh_droplet.rb +3 -1
  31. data/lib/tugboat/middleware/start_droplet.rb +6 -6
  32. data/lib/tugboat/middleware/wait_for_state.rb +6 -6
  33. data/lib/tugboat/version.rb +1 -1
  34. data/spec/cli/add_key_spec.rb +16 -9
  35. data/spec/cli/authorize_cli_spec.rb +24 -29
  36. data/spec/cli/config_cli_spec.rb +57 -0
  37. data/spec/cli/create_cli_spec.rb +18 -28
  38. data/spec/cli/debug_cli_spec.rb +8 -14
  39. data/spec/cli/destroy_cli_spec.rb +39 -50
  40. data/spec/cli/destroy_image_cli_spec.rb +33 -39
  41. data/spec/cli/droplets_cli_spec.rb +15 -12
  42. data/spec/cli/halt_cli_spec.rb +50 -46
  43. data/spec/cli/images_cli_spec.rb +134 -58
  44. data/spec/cli/info_cli_spec.rb +139 -139
  45. data/spec/cli/info_image_cli_spec.rb +113 -26
  46. data/spec/cli/keys_cli_spec.rb +7 -5
  47. data/spec/cli/password_reset_cli_spec.rb +46 -44
  48. data/spec/cli/rebuild_cli_spec.rb +187 -101
  49. data/spec/cli/regions_cli_spec.rb +13 -6
  50. data/spec/cli/resize_cli_spec.rb +51 -48
  51. data/spec/cli/restart_cli_spec.rb +41 -39
  52. data/spec/cli/sizes_cli_spec.rb +13 -8
  53. data/spec/cli/snapshot_cli_spec.rb +36 -37
  54. data/spec/cli/ssh_cli_spec.rb +7 -15
  55. data/spec/cli/start_cli_spec.rb +39 -35
  56. data/spec/cli/verify_cli_spec.rb +20 -12
  57. data/spec/cli/wait_cli_spec.rb +43 -27
  58. data/spec/config_spec.rb +19 -25
  59. data/spec/fixtures/create_droplet.json +44 -0
  60. data/spec/fixtures/create_ssh_key.json +4 -4
  61. data/spec/fixtures/create_ssh_key_from_file.json +8 -0
  62. data/spec/fixtures/droplet_start_response.json +13 -0
  63. data/spec/fixtures/not_found.json +4 -0
  64. data/spec/fixtures/password_reset_response.json +13 -0
  65. data/spec/fixtures/power_cycle_response.json +13 -0
  66. data/spec/fixtures/resize_droplet.json +13 -0
  67. data/spec/fixtures/restart_response.json +13 -0
  68. data/spec/fixtures/show_coreos_image.json +23 -0
  69. data/spec/fixtures/show_droplet.json +90 -11
  70. data/spec/fixtures/show_droplet_inactive.json +90 -11
  71. data/spec/fixtures/show_droplets.json +249 -30
  72. data/spec/fixtures/show_droplets_empty.json +5 -2
  73. data/spec/fixtures/show_image.json +14 -7
  74. data/spec/fixtures/show_images.json +1075 -13
  75. data/spec/fixtures/show_images_global.json +25 -16
  76. data/spec/fixtures/show_keys.json +15 -7
  77. data/spec/fixtures/show_redmine_image.json +24 -0
  78. data/spec/fixtures/show_regions.json +181 -12
  79. data/spec/fixtures/show_sizes.json +178 -9
  80. data/spec/fixtures/shutdown_response.json +13 -0
  81. data/spec/fixtures/snapshot_response.json +13 -0
  82. data/spec/fixtures/ubuntu_image_9801951.json +24 -0
  83. data/spec/middleware/check_credentials_spec.rb +4 -3
  84. data/spec/middleware/inject_client_spec.rb +2 -2
  85. data/spec/shared/environment.rb +6 -7
  86. data/spec/spec_helper.rb +1 -1
  87. data/tugboat.gemspec +39 -19
  88. metadata +50 -14
  89. data/spec/fixtures/show_droplet_fuzzy.json +0 -13
  90. data/spec/fixtures/show_droplets_fuzzy.json +0 -35
  91. data/spec/fixtures/show_droplets_inactive.json +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d6756d7aed64e40d62a18350b778ca7a56ddd08
4
- data.tar.gz: 4a8e491b6116538bac1325d70a000529be9ffc42
3
+ metadata.gz: e4a6516497a6285190e53a1e6209f4c3bc7ff38e
4
+ data.tar.gz: 1deee8b54ce280230929f27e920fef46b6d471ff
5
5
  SHA512:
6
- metadata.gz: c703030fcc46ddb84eba13cedf3f77b1edf8828c4f8be982f171ba67fb9c12359a80e6141e26b6684b2afd612fe4efbf274350b5d36c13d226f0d5042170055f
7
- data.tar.gz: ed1455015c08cc87990f7d837084ce6f0b52f1debb107afc62ff3144246eb582ec4d8e48c603aff1c6ccbdc554bfb1297f02d3c6354e462fd13d6ab5033749b7
6
+ metadata.gz: 3f275a9150a93971d9a8e0067c09d51727162c2b97bd52c6acd42faead78c8fbcd713212343ace0c296fa347976ada8e9d5d99c2d7b0268d2f53108fe23ac424
7
+ data.tar.gz: 4a77d1bd1b256ba368d04c722e13b85802f5344d80f69979ce0887517577dcf95a66507730bb350cd7f54a205c43a66e8b04004393b17784407663c5b6d0bc3a
data/.travis.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 1.9.3
5
4
  - 2.0.0
6
5
  - 2.1.0
6
+ - 2.2.3
7
7
  script:
8
8
  - "bundle exec rake spec"
9
9
  - "bundle exec rake features"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.3.1](https://github.com/pearkes/tugboat/tree/v1.3.1) (2015-08-02)
4
+
5
+ [Full Changelog](https://github.com/pearkes/tugboat/compare/v1.3.0...v1.3.1)
6
+
7
+ **Closed issues:**
8
+
9
+ - Bad documentation string [\#174](https://github.com/pearkes/tugboat/issues/174)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Removes wrong help messages for `images`. [\#173](https://github.com/pearkes/tugboat/pull/173) ([haihappen](https://github.com/haihappen))
14
+
3
15
  ## [v1.3.0](https://github.com/pearkes/tugboat/tree/v1.3.0) (2015-07-19)
4
16
 
5
17
  [Full Changelog](https://github.com/pearkes/tugboat/compare/v1.2.0...v1.3.0)
@@ -36,14 +48,6 @@
36
48
 
37
49
  - Update ssh to private ip [\#172](https://github.com/pearkes/tugboat/pull/172) ([petems](https://github.com/petems))
38
50
 
39
- ## [v2.0.0.ALPHA](https://github.com/pearkes/tugboat/tree/v2.0.0.ALPHA) (2015-07-18)
40
-
41
- [Full Changelog](https://github.com/pearkes/tugboat/compare/v1.0.0...v2.0.0.ALPHA)
42
-
43
- **Closed issues:**
44
-
45
- - 1.0.0 Release [\#125](https://github.com/pearkes/tugboat/issues/125)
46
-
47
51
  ## [v1.0.0](https://github.com/pearkes/tugboat/tree/v1.0.0) (2015-05-26)
48
52
 
49
53
  [Full Changelog](https://github.com/pearkes/tugboat/compare/v0.2.0...v1.0.0)
data/lib/tugboat/cli.rb CHANGED
@@ -73,15 +73,15 @@ module Tugboat
73
73
  })
74
74
  end
75
75
 
76
- desc "images [OPTIONS]", "Retrieve a list of your images"
77
- method_option "global",
76
+ desc "images [OPTIONS]", "Retrieve a list of images"
77
+ method_option "show_just_private_images",
78
78
  :type => :boolean,
79
79
  :default => false,
80
- :aliases => "-g",
81
- :desc => "Show global images"
80
+ :aliases => "-p",
81
+ :desc => "Show just private images"
82
82
  def images
83
83
  Middleware.sequence_list_images.call({
84
- "user_show_global_images" => options[:global],
84
+ "user_show_just_private_images" => options[:show_just_private_images],
85
85
  "user_quiet" => options[:quiet]
86
86
  })
87
87
  end
@@ -102,7 +102,8 @@ module Tugboat
102
102
  method_option "use_private_ip",
103
103
  :type => :boolean,
104
104
  :aliases => "-t",
105
- :desc => "Use Private IP while private IP is present"
105
+ :desc => "Use Private IP while private IP is present",
106
+ :default => false
106
107
  method_option "ssh_user",
107
108
  :type => :string,
108
109
  :aliases => "-u",
@@ -122,7 +123,7 @@ module Tugboat
122
123
  "user_droplet_fuzzy_name" => name,
123
124
  "user_droplet_ssh_port" => options[:ssh_port],
124
125
  "user_droplet_ssh_user" => options[:ssh_user],
125
- "user_droplet_use_private_ip" => options[:use_public_ip],
126
+ "user_droplet_use_private_ip" => options[:use_private_ip],
126
127
  "user_droplet_ssh_opts" => options[:ssh_opts],
127
128
  "user_droplet_ssh_command" => options[:ssh_command],
128
129
  "user_quiet" => options[:quiet]
@@ -12,9 +12,9 @@ module Tugboat
12
12
  FILE_NAME = '.tugboat'
13
13
  DEFAULT_SSH_KEY_PATH = '.ssh/id_rsa'
14
14
  DEFAULT_SSH_PORT = '22'
15
- DEFAULT_REGION = '8'
16
- DEFAULT_IMAGE = '9801950'
17
- DEFAULT_SIZE = '66'
15
+ DEFAULT_REGION = 'nyc2'
16
+ DEFAULT_IMAGE = 'ubuntu-14-04-x64'
17
+ DEFAULT_SIZE = '512mb'
18
18
  DEFAULT_SSH_KEY = ''
19
19
  DEFAULT_PRIVATE_NETWORKING = 'false'
20
20
  DEFAULT_BACKUPS_ENABLED = 'false'
@@ -37,12 +37,8 @@ module Tugboat
37
37
  return
38
38
  end
39
39
 
40
- def client_key
41
- @data['authentication']['client_key']
42
- end
43
-
44
- def api_key
45
- @data['authentication']['api_key']
40
+ def access_token
41
+ @data['authentication']['access_token']
46
42
  end
47
43
 
48
44
  def ssh_key_path
@@ -96,7 +92,7 @@ module Tugboat
96
92
  end
97
93
 
98
94
  # Writes a config file
99
- def create_config_file(client, api, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled)
95
+ def create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled)
100
96
  # Default SSH Key path
101
97
  if ssh_key_path.empty?
102
98
  ssh_key_path = File.join("~", DEFAULT_SSH_KEY_PATH)
@@ -138,8 +134,8 @@ module Tugboat
138
134
  File.open(@path, File::RDWR|File::TRUNC|File::CREAT, 0600) do |file|
139
135
  data = {
140
136
  "authentication" => {
141
- "client_key" => client,
142
- "api_key" => api },
137
+ "access_token" => access_token
138
+ },
143
139
  "ssh" => {
144
140
  "ssh_user" => ssh_user,
145
141
  "ssh_key_path" => ssh_key_path ,
@@ -2,7 +2,7 @@ module Tugboat
2
2
  module Middleware
3
3
  class AddKey < Base
4
4
  def call(env)
5
- ocean = env["ocean"]
5
+ ocean = env['barge']
6
6
 
7
7
  if env["add_key_pub_key"]
8
8
  pub_key_string = env["add_key_pub_key"]
@@ -29,15 +29,18 @@ module Tugboat
29
29
 
30
30
  say "Queueing upload of SSH key '#{env["add_key_name"]}'...", nil, false
31
31
 
32
- req = ocean.ssh_keys.add :name => env["add_key_name"],
33
- :ssh_pub_key => pub_key_string
32
+ response = ocean.key.create :name => env["add_key_name"],
33
+ :public_key => pub_key_string
34
34
 
35
- if req.status == "ERROR"
36
- say req.error_message, :red
35
+ unless response.success?
36
+ say "Failed to create key: #{response.message}", :red
37
37
  exit 1
38
38
  end
39
39
 
40
- say "done", :green
40
+ say "SSH Key uploaded", :green
41
+ say
42
+ say "Name: #{response.ssh_key.name}"
43
+ say "ID: #{response.ssh_key.id}"
41
44
 
42
45
  @app.call(env)
43
46
  end
@@ -3,11 +3,10 @@ module Tugboat
3
3
  # Ask for user credentials from the command line, then write them out.
4
4
  class AskForCredentials < Base
5
5
  def call(env)
6
- say "Note: You can get this information from https://cloud.digitalocean.com/api_access", :yellow
7
- say "Also Note: Tugboat is setup to work with v1 of the Digital Ocean API (https://developers.digitalocean.com/v1/)", :yellow
6
+ say "Note: You can get your Access Token from https://cloud.digitalocean.com/settings/tokens/new", :yellow
8
7
  say
9
- client_key = ask "Enter your client key:"
10
- api_key = ask "Enter your API key:"
8
+ access_token = ask "Enter your access token:"
9
+ access_token.strip!
11
10
  ssh_key_path = ask "Enter your SSH key path (optional, defaults to ~/.ssh/id_rsa):"
12
11
  ssh_user = ask "Enter your SSH user (optional, defaults to root):"
13
12
  ssh_port = ask "Enter your SSH port number (optional, defaults to 22):"
@@ -15,15 +14,15 @@ module Tugboat
15
14
  say "To retrieve region, image, size and key ID's, you can use the corresponding tugboat command, such as `tugboat images`."
16
15
  say "Defaults can be changed at any time in your ~/.tugboat configuration file."
17
16
  say
18
- region = ask "Enter your default region ID (optional, defaults to 8 (New York 3)):"
19
- image = ask "Enter your default image ID (optional, defaults to 9801950 (Ubuntu 14.04 x64)):"
20
- size = ask "Enter your default size ID (optional, defaults to 66 (512MB)):"
17
+ region = ask "Enter your default region (optional, defaults to nyc1):"
18
+ image = ask "Enter your default image ID or image slug (optional, defaults to ubuntu-14-04-x64):"
19
+ size = ask "Enter your default size (optional, defaults to 512mb)):"
21
20
  ssh_key = ask "Enter your default ssh key ID (optional, defaults to none):"
22
21
  private_networking = ask "Enter your default for private networking (optional, defaults to false):"
23
22
  backups_enabled = ask "Enter your default for enabling backups (optional, defaults to false):"
24
23
 
25
24
  # Write the config file.
26
- env['config'].create_config_file(client_key, api_key, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled)
25
+ env['config'].create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled)
27
26
  env['config'].reload!
28
27
 
29
28
  @app.call(env)
@@ -5,7 +5,7 @@ module Tugboat
5
5
  def call(env)
6
6
  config = env["config"]
7
7
 
8
- if !config || !config.data || !config.api_key || !config.client_key
8
+ if !config || !config.data || !config.access_token
9
9
  say "You must run `tugboat authorize` in order to connect to DigitalOcean", :red
10
10
  exit 1
11
11
  end
@@ -8,9 +8,11 @@ module Tugboat
8
8
  # We use a harmless API call to check if the authentication will
9
9
  # work.
10
10
  begin
11
- env["ocean"].droplets.list
11
+ env['barge'].droplet.all.list
12
12
  rescue Faraday::Error::ClientError => e
13
- say "Authentication with DigitalOcean failed. Run `tugboat authorize`", :red
13
+ say "Authentication with DigitalOcean failed."
14
+ say "Error was: #{e}"
15
+ say "Try re-running `tugboat authorize`", :red
14
16
  exit 1
15
17
  end
16
18
 
@@ -8,15 +8,14 @@ module Tugboat
8
8
 
9
9
  keys_retracted = ''
10
10
 
11
- config_data = config.data.to_yaml
11
+ config_data = config.data.to_yaml.gsub(/"/,'')
12
12
 
13
13
  if env["user_hide_keys"]
14
14
  keys_retracted = '(Keys Redacted)'
15
- config_data = config_data.gsub(/(client_key: )([a-zA-Z0-9]+)/,'\1 [REDACTED]')
16
- config_data = config_data.gsub(/(api_key: )([a-zA-Z0-9]+)/,'\1 [REDACTED]')
15
+ config_data = config_data.gsub(/(access_token: )([a-zA-Z0-9]+)/,'\1 [REDACTED]')
17
16
  end
18
17
 
19
- say "Current Config #{keys_retracted}", :green
18
+ say "Current Config #{keys_retracted}\n", :green
20
19
 
21
20
  say "Path: #{config.path}"
22
21
  say config_data
@@ -2,49 +2,55 @@ module Tugboat
2
2
  module Middleware
3
3
  class CreateDroplet < Base
4
4
  def call(env)
5
- ocean = env["ocean"]
5
+ ocean = env['barge']
6
6
 
7
7
  say "Queueing creation of droplet '#{env["create_droplet_name"]}'...", nil, false
8
8
 
9
9
  env["create_droplet_region_id"] ?
10
- droplet_region_id = env["create_droplet_region_id"] :
11
- droplet_region_id = env["config"].default_region
10
+ droplet_region_id = env["create_droplet_region_id"] :
11
+ droplet_region_id = env["config"].default_region
12
12
 
13
13
  env["create_droplet_image_id"] ?
14
- droplet_image_id = env["create_droplet_image_id"] :
15
- droplet_image_id = env["config"].default_image
14
+ droplet_image_id = env["create_droplet_image_id"] :
15
+ droplet_image_id = env["config"].default_image
16
16
 
17
17
  env["create_droplet_size_id"] ?
18
- droplet_size_id = env["create_droplet_size_id"] :
19
- droplet_size_id = env["config"].default_size
18
+ droplet_size_id = env["create_droplet_size_id"] :
19
+ droplet_size_id = env["config"].default_size
20
20
 
21
21
  env["create_droplet_ssh_key_ids"] ?
22
- droplet_ssh_key_id = env["create_droplet_ssh_key_ids"] :
23
- droplet_ssh_key_id = env["config"].default_ssh_key
22
+ droplet_ssh_key_id = env["create_droplet_ssh_key_ids"] :
23
+ droplet_ssh_key_id = env["config"].default_ssh_key
24
24
 
25
25
  env["create_droplet_private_networking"] ?
26
- droplet_private_networking = env["create_droplet_private_networking"] :
27
- droplet_private_networking = env["config"].default_private_networking
26
+ droplet_private_networking = env["create_droplet_private_networking"] :
27
+ droplet_private_networking = env["config"].default_private_networking
28
28
 
29
29
  env["create_droplet_backups_enabled"] ?
30
- droplet_backups_enabled = env["create_droplet_backups_enabled"] :
31
- droplet_backups_enabled = env["config"].default_backups_enabled
32
-
33
-
34
- req = ocean.droplets.create :name => env["create_droplet_name"],
35
- :size_id => droplet_size_id,
36
- :image_id => droplet_image_id,
37
- :region_id => droplet_region_id,
38
- :ssh_key_ids => droplet_ssh_key_id,
39
- :private_networking => droplet_private_networking,
40
- :backups_enabled => droplet_backups_enabled
41
-
42
- if req.status == "ERROR"
43
- say req.error_message, :red
30
+ droplet_backups_enabled = env["create_droplet_backups_enabled"] :
31
+ droplet_backups_enabled = env["config"].default_backups_enabled
32
+
33
+ droplet_ssh_key_id = nil if droplet_ssh_key_id.empty?
34
+
35
+ create_opts = {
36
+ :name => env["create_droplet_name"],
37
+ :size => droplet_size_id,
38
+ :image => "#{droplet_image_id}",
39
+ :region => droplet_region_id,
40
+ :ssh_keys => [droplet_ssh_key_id],
41
+ :private_networking => droplet_private_networking,
42
+ :backups_enabled => droplet_backups_enabled,
43
+ :ipv6 => nil,
44
+ }
45
+
46
+ response = ocean.droplet.create(create_opts)
47
+
48
+ unless response.success?
49
+ say "Failed to create Droplet: #{response.message}", :red
44
50
  exit 1
45
51
  end
46
52
 
47
- say "done", :green
53
+ say "Droplet created!"
48
54
 
49
55
  @app.call(env)
50
56
  end
@@ -2,19 +2,19 @@ module Tugboat
2
2
  module Middleware
3
3
  class DestroyDroplet < Base
4
4
  def call(env)
5
- ocean = env["ocean"]
5
+ ocean = env['barge']
6
6
 
7
7
  say "Queuing destroy for #{env["droplet_id"]} #{env["droplet_name"]}...", nil, false
8
8
 
9
- req = ocean.droplets.delete env["droplet_id"]
9
+ response = ocean.droplet.destroy env["droplet_id"]
10
10
 
11
- if req.status == "ERROR"
12
- say "#{req.status}: #{req.error_message}", :red
11
+ unless response.success?
12
+ say "Failed to destroy Droplet: #{response.message}", :red
13
13
  exit 1
14
+ else
15
+ say "Deletion Successful!", :green
14
16
  end
15
17
 
16
- say "done", :green
17
-
18
18
  @app.call(env)
19
19
  end
20
20
  end
@@ -2,19 +2,19 @@ module Tugboat
2
2
  module Middleware
3
3
  class DestroyImage < Base
4
4
  def call(env)
5
- ocean = env["ocean"]
5
+ ocean = env['barge']
6
6
 
7
7
  say "Queuing destroy image for #{env["image_id"]} #{env["image_name"]}...", nil, false
8
8
 
9
- req = ocean.images.delete env["image_id"]
9
+ response = ocean.image.destroy env["image_id"]
10
10
 
11
- if req.status == "ERROR"
12
- say "#{req.status}: #{req.error_message}", :red
11
+ unless response.success?
12
+ say "Failed to destroy image: #{response.message}", :red
13
13
  exit 1
14
+ else
15
+ say 'Image deletion successful!', :green
14
16
  end
15
17
 
16
- say "done", :green
17
-
18
18
  @app.call(env)
19
19
  end
20
20
  end
@@ -3,7 +3,7 @@ module Tugboat
3
3
  # Check if the client has set-up configuration yet.
4
4
  class FindDroplet < Base
5
5
  def call(env)
6
- ocean = env["ocean"]
6
+ ocean = env['barge']
7
7
  user_fuzzy_name = env['user_droplet_fuzzy_name']
8
8
  user_droplet_name = env['user_droplet_name']
9
9
  user_droplet_id = env['user_droplet_id']
@@ -28,21 +28,22 @@ module Tugboat
28
28
 
29
29
  # Easy for us if they provide an id. Just set it to the droplet_id
30
30
  if user_droplet_id
31
+
31
32
  if !porcelain
32
33
  say "Droplet id provided. Finding Droplet...", nil, false
33
34
  end
34
- req = ocean.droplets.show user_droplet_id
35
+ response = ocean.droplet.show user_droplet_id
35
36
 
36
- if req.status == "ERROR"
37
- say "#{req.status}: #{req.error_message}", :red
37
+ unless response.success?
38
+ say "Failed to find Droplet: #{response.message}", :red
38
39
  exit 1
39
40
  end
40
41
 
41
- env["droplet_id"] = req.droplet.id
42
- env["droplet_name"] = "(#{req.droplet.name})"
43
- env["droplet_ip"] = req.droplet.ip_address
44
- env["droplet_ip_private"] = req.droplet.private_ip_address
45
- env["droplet_status"] = req.droplet.status
42
+ env["droplet_id"] = response.droplet.id
43
+ env["droplet_name"] = "(#{response.droplet.name})"
44
+ env["droplet_ip"] = response.droplet.ip_address
45
+ env["droplet_ip_private"] = response.droplet.private_ip_address
46
+ env["droplet_status"] = response.droplet.status
46
47
  end
47
48
 
48
49
  # If they provide a name, we need to get the ID for it.
@@ -53,7 +54,7 @@ module Tugboat
53
54
  end
54
55
 
55
56
  # Look for the droplet by an exact name match.
56
- ocean.droplets.list.droplets.each do |d|
57
+ ocean.droplet.all.droplets.each do |d|
57
58
  if d.name == user_droplet_name
58
59
  env["droplet_id"] = d.id
59
60
  env["droplet_name"] = "(#{d.name})"
@@ -82,7 +83,7 @@ module Tugboat
82
83
  found_droplets = []
83
84
  choices = []
84
85
 
85
- ocean.droplets.list.droplets.each_with_index do |d, i|
86
+ ocean.droplet.all.droplets.each_with_index do |d, i|
86
87
  # Check to see if one of the droplet names have the fuzzy string.
87
88
  if d.name.upcase.include? user_fuzzy_name.upcase
88
89
  found_droplets << d
@@ -92,11 +93,14 @@ module Tugboat
92
93
  # Check to see if we have more then one droplet, and prompt
93
94
  # a user to choose otherwise.
94
95
  if found_droplets.length == 1
95
- env["droplet_id"] = found_droplets.first.id
96
- env["droplet_name"] = "(#{found_droplets.first.name})"
97
- env["droplet_ip"] = found_droplets.first.ip_address
98
- env["droplet_ip_private"] = found_droplets.first.private_ip_address
99
- env["droplet_status"] = found_droplets.first.status
96
+ droplet_return = found_droplets.first
97
+
98
+ env["droplet_id"] = droplet_return.id
99
+ env["droplet_name"] = "(#{droplet_return.name})"
100
+ env["droplet_ip"] = droplet_return.networks.v4.detect { |address| address.type == 'public' }.ip_address
101
+ check_private_ip = droplet_return.networks.v4.detect { |address| address.type == 'private' }
102
+ env["droplet_ip_private"] = check_private_ip.ip_address if check_private_ip
103
+ env["droplet_status"] = droplet_return.status
100
104
  elsif found_droplets.length > 1
101
105
  # Did we run the multiple questionairre?
102
106
  did_run_multiple = true
@@ -3,7 +3,7 @@ module Tugboat
3
3
  # Check if the client has set-up configuration yet.
4
4
  class FindImage < Base
5
5
  def call(env)
6
- ocean = env["ocean"]
6
+ ocean = env['barge']
7
7
  user_fuzzy_name = env['user_image_fuzzy_name']
8
8
  user_image_name = env['user_image_name']
9
9
  user_image_id = env['user_image_id']
@@ -23,24 +23,24 @@ module Tugboat
23
23
  # Easy for us if they provide an id. Just set it to the image_id
24
24
  if user_image_id
25
25
  say "Image id provided. Finding Image...", nil, false
26
- req = ocean.images.show user_image_id
26
+ response = ocean.image.show user_image_id
27
27
 
28
- if req.status == "ERROR"
29
- say "#{req.status}: #{req.error_message}", :red
28
+ unless response.success?
29
+ say "Failed to find Image: #{response.message}", :red
30
30
  exit 1
31
31
  end
32
32
 
33
- env["image_id"] = req.image.id
34
- env["image_name"] = "(#{req.image.name})"
33
+ env["image_id"] = response.image.id
34
+ env["image_name"] = "(#{response.image.name})"
35
35
  end
36
36
 
37
37
  # If they provide a name, we need to get the ID for it.
38
38
  # This requires a lookup.
39
39
  if user_image_name && !env["image_id"]
40
- say "Image name provided. Finding image ID...", nil, false
40
+ say "Image name provided. Finding Image...", nil, false
41
41
 
42
42
  # Look for the image by an exact name match.
43
- ocean.images.list.images.each do |d|
43
+ ocean.image.all['images'].each do |d|
44
44
  if d.name == user_image_name
45
45
  env["image_id"] = d.id
46
46
  env["image_name"] = "(#{d.name})"
@@ -50,7 +50,7 @@ module Tugboat
50
50
  # If we coulnd't find it, tell the user and drop out of the
51
51
  # sequence.
52
52
  if !env["image_id"]
53
- say "error\nUnable to find a image named '#{user_image_name}'.", :red
53
+ say "error\nUnable to find an image named '#{user_image_name}'.", :red
54
54
  exit 1
55
55
  end
56
56
  end
@@ -66,11 +66,18 @@ module Tugboat
66
66
  found_images = []
67
67
  choices = []
68
68
 
69
- ocean.images.list.images.each_with_index do |d, i|
69
+ ocean.image.all['images'].each_with_index do |d, i|
70
+
70
71
  # Check to see if one of the image names have the fuzzy string.
71
72
  if d.name.upcase.include? user_fuzzy_name.upcase
72
73
  found_images << d
73
74
  end
75
+
76
+ unless d.slug.nil?
77
+ if d.slug.upcase.include? user_fuzzy_name.upcase
78
+ found_images << d
79
+ end
80
+ end
74
81
  end
75
82
 
76
83
  # Check to see if we have more then one image, and prompt
@@ -2,23 +2,23 @@ module Tugboat
2
2
  module Middleware
3
3
  class HaltDroplet < Base
4
4
  def call(env)
5
- ocean = env["ocean"]
5
+ ocean = env['barge']
6
6
 
7
- req = if env["user_droplet_hard"]
7
+ response = if env["user_droplet_hard"]
8
8
  say "Queuing hard shutdown for #{env["droplet_id"]} #{env["droplet_name"]}...", nil, false
9
- ocean.droplets.power_off env["droplet_id"]
9
+ ocean.droplet.power_off env["droplet_id"]
10
10
  else
11
11
  say "Queuing shutdown for #{env["droplet_id"]} #{env["droplet_name"]}...", nil, false
12
- ocean.droplets.shutdown env["droplet_id"]
12
+ ocean.droplet.shutdown env["droplet_id"]
13
13
  end
14
14
 
15
- if req.status == "ERROR"
16
- say req.error_message, :red
15
+ unless response.success?
16
+ say "Failed to halt on Droplet: #{response.message}", :red
17
17
  exit 1
18
+ else
19
+ say "Halt successful!", :green
18
20
  end
19
21
 
20
- say "done", :green
21
-
22
22
  @app.call(env)
23
23
  end
24
24
  end