tugboat 0.0.9 → 0.2.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: 2d849915ab2227a3a3ffa08de72535a611cfbd84
4
- data.tar.gz: 62a801c0f5e32a631d290e05528f2805813d7f58
3
+ metadata.gz: a65287132cbbc39cf82f8b2f38c367cfe03cce4d
4
+ data.tar.gz: 7289289f9a09750c5a79500605f39086887f0804
5
5
  SHA512:
6
- metadata.gz: 0248ef0e63f0b8d62ab68027740fc5ba22b31f5c9c20d7df711d51f6f4e3a35aa69369bf6dbaa677b3e3b0f421865133ea0bdca13e84a530f0c5520393d4a547
7
- data.tar.gz: c1afc811c11f657f3821b2407164a63616368546c67f88f3eb67d14138c3eaf1ea00244132d0aa409f882467bf3f01a096ab6d7410ef12cb2efec8f51eb3d778
6
+ metadata.gz: a8c91047d99cf38350e01fc8d867a4c30b27fd437befcd5ca4542ebc02290608bc38ec7a6cbfc5b6ede7a20d1c597d800c874c7f889a76963f22e7b5152317d0
7
+ data.tar.gz: fc03cb535368841410681deeaa967349030bd7fb602d4f6efa24311b1dbaceabd15531584ecc0bb85345f4cda55d2c91d76408e27fc08248671196b943e72b72
@@ -1,3 +1,25 @@
1
+ ## 0.2.1 (UNRELEASED)
2
+
3
+
4
+ ## 0.2.0 (Feburary 15, 2014)
5
+
6
+ FEATURES:
7
+
8
+ - [Pierre](https://github.com/spearway) added an `info-image` and `destroy-image`
9
+ command, letting you deal with your images from Tugboat. It's great. [GH-91]
10
+ - [Pierre](https://github.com/spearway) also added a `rebuild` command,
11
+ letting you take an existing droplet and recreate it from scratch. [GH-90]
12
+
13
+ IMPROVEMENTS:
14
+
15
+ - [Dale](https://github.com/Vel0x) made it so fuzzy name searching
16
+ is case insensitive. We wonder why we didn't do this earlier, really. [GH-88]
17
+ - There is now a `--quiet/-q` flag, which makes Tugboat be silent, as it
18
+ can get a little obnoxious. [GH-87]
19
+ - [Andrew](https://github.com/4n3w) hooked up a `backups_enabled` option
20
+ for creating droplets. [GH-82]
21
+
22
+
1
23
  ## 0.0.9 (December 24, 2013)
2
24
 
3
25
  FEATURES:
@@ -9,6 +9,8 @@ module Tugboat
9
9
 
10
10
  !check_unknown_options
11
11
 
12
+ class_option :quiet, type: :boolean, aliases: "-q"
13
+
12
14
  map "--version" => :version,
13
15
  "-v" => :version,
14
16
  "password-reset" => :password_reset
@@ -33,7 +35,9 @@ module Tugboat
33
35
  $USER environment variable.
34
36
  "
35
37
  def authorize
36
- Middleware.sequence_authorize.call({})
38
+ Middleware.sequence_authorize.call({
39
+ "user_quiet" => options[:quiet]
40
+ })
37
41
  end
38
42
 
39
43
  desc "verify", "Check your DigitalOcean credentials"
@@ -42,12 +46,16 @@ module Tugboat
42
46
  to the API without errors.
43
47
  "
44
48
  def verify
45
- Middleware.sequence_verify.call({})
49
+ Middleware.sequence_verify.call({
50
+ "user_quiet" => options[:quiet]
51
+ })
46
52
  end
47
53
 
48
54
  desc "droplets", "Retrieve a list of your droplets"
49
55
  def droplets
50
- Middleware.sequence_list_droplets.call({})
56
+ Middleware.sequence_list_droplets.call({
57
+ "user_quiet" => options[:quiet]
58
+ })
51
59
  end
52
60
 
53
61
  desc "images", "Retrieve a list of your images"
@@ -59,6 +67,7 @@ module Tugboat
59
67
  def images
60
68
  Middleware.sequence_list_images.call({
61
69
  "user_show_global_images" => options[:global],
70
+ "user_quiet" => options[:quiet]
62
71
  })
63
72
  end
64
73
 
@@ -95,7 +104,8 @@ module Tugboat
95
104
  "user_droplet_ssh_port" => options[:ssh_port],
96
105
  "user_droplet_ssh_user" => options[:ssh_user],
97
106
  "user_droplet_ssh_opts" => options[:ssh_opts],
98
- "user_droplet_ssh_command" => options[:ssh_command]
107
+ "user_droplet_ssh_command" => options[:ssh_command],
108
+ "user_quiet" => options[:quiet]
99
109
  })
100
110
  end
101
111
 
@@ -120,6 +130,10 @@ module Tugboat
120
130
  :type => :boolean,
121
131
  :aliases => "-p",
122
132
  :desc => "Enable private networking on the droplet"
133
+ method_option "backups_enabled",
134
+ :type => :boolean,
135
+ :aliases => "-b",
136
+ :desc => "Enable backups on the droplet"
123
137
 
124
138
  def create(name)
125
139
  Middleware.sequence_create_droplet.call({
@@ -128,7 +142,43 @@ module Tugboat
128
142
  "create_droplet_region_id" => options[:region],
129
143
  "create_droplet_ssh_key_ids" => options[:keys],
130
144
  "create_droplet_private_networking" => options[:private_networking],
131
- "create_droplet_name" => name
145
+ "create_droplet_backups_enabled" => options[:backups_enabled],
146
+ "create_droplet_name" => name,
147
+ "user_quiet" => options[:quiet]
148
+ })
149
+ end
150
+
151
+ desc "rebuild FUZZY_NAME IMAGE_NAME", "Rebuild a droplet."
152
+ method_option "id",
153
+ :type => :string,
154
+ :aliases => "-i",
155
+ :desc => "The ID of the droplet."
156
+ method_option "name",
157
+ :type => :string,
158
+ :aliases => "-n",
159
+ :desc => "The exact name of the droplet"
160
+ method_option "confirm",
161
+ :type => :boolean,
162
+ :aliases => "-c",
163
+ :desc => "Skip confirmation of the action"
164
+ method_option "image_id",
165
+ :type => :numeric,
166
+ :aliases => "-k",
167
+ :desc => "The ID of the image"
168
+ method_option "image_name",
169
+ :type => :string,
170
+ :aliases => "-m",
171
+ :desc => "The exact name of the image"
172
+ def rebuild(name=nil, image_name=nil)
173
+ Middleware.sequence_rebuild_droplet.call({
174
+ "user_droplet_id" => options[:id],
175
+ "user_droplet_name" => options[:name],
176
+ "user_droplet_fuzzy_name" => name,
177
+ "user_image_id" => options[:image_id],
178
+ "user_image_name" => options[:image_name],
179
+ "user_image_fuzzy_name" => image_name,
180
+ "user_confirm_action" => options[:confirm],
181
+ "user_quiet" => options[:quiet]
132
182
  })
133
183
  end
134
184
 
@@ -150,7 +200,31 @@ module Tugboat
150
200
  "user_droplet_id" => options[:id],
151
201
  "user_droplet_name" => options[:name],
152
202
  "user_confirm_action" => options[:confirm],
153
- "user_droplet_fuzzy_name" => name
203
+ "user_droplet_fuzzy_name" => name,
204
+ "user_quiet" => options[:quiet]
205
+ })
206
+ end
207
+
208
+ desc "destroy_image FUZZY_NAME", "Destroy an image"
209
+ method_option "id",
210
+ :type => :string,
211
+ :aliases => "-i",
212
+ :desc => "The ID of the image."
213
+ method_option "name",
214
+ :type => :string,
215
+ :aliases => "-n",
216
+ :desc => "The exact name of the image"
217
+ method_option "confirm",
218
+ :type => :boolean,
219
+ :aliases => "-c",
220
+ :desc => "Skip confirmation of the action"
221
+ def destroy_image(name=nil)
222
+ Middleware.sequence_destroy_image.call({
223
+ "user_image_id" => options[:id],
224
+ "user_image_name" => options[:name],
225
+ "user_image_fuzzy_name" => name,
226
+ "user_confirm_action" => options[:confirm],
227
+ "user_quiet" => options[:quiet]
154
228
  })
155
229
  end
156
230
 
@@ -172,7 +246,8 @@ module Tugboat
172
246
  "user_droplet_id" => options[:id],
173
247
  "user_droplet_name" => options[:name],
174
248
  "user_droplet_hard" => options[:hard],
175
- "user_droplet_fuzzy_name" => name
249
+ "user_droplet_fuzzy_name" => name,
250
+ "user_quiet" => options[:quiet]
176
251
  })
177
252
  end
178
253
 
@@ -194,7 +269,8 @@ module Tugboat
194
269
  "user_droplet_id" => options[:id],
195
270
  "user_droplet_name" => options[:name],
196
271
  "user_droplet_hard" => options[:hard],
197
- "user_droplet_fuzzy_name" => name
272
+ "user_droplet_fuzzy_name" => name,
273
+ "user_quiet" => options[:quiet]
198
274
  })
199
275
  end
200
276
 
@@ -211,7 +287,26 @@ module Tugboat
211
287
  Middleware.sequence_info_droplet.call({
212
288
  "user_droplet_id" => options[:id],
213
289
  "user_droplet_name" => options[:name],
214
- "user_droplet_fuzzy_name" => name
290
+ "user_droplet_fuzzy_name" => name,
291
+ "user_quiet" => options[:quiet]
292
+ })
293
+ end
294
+
295
+ desc "info_image FUZZY_NAME [OPTIONS]", "Show an image's information"
296
+ method_option "id",
297
+ :type => :string,
298
+ :aliases => "-i",
299
+ :desc => "The ID of the image."
300
+ method_option "name",
301
+ :type => :string,
302
+ :aliases => "-n",
303
+ :desc => "The exact name of the image"
304
+ def info_image(name=nil)
305
+ Middleware.sequence_info_image.call({
306
+ "user_image_id" => options[:id],
307
+ "user_image_name" => options[:name],
308
+ "user_image_fuzzy_name" => name,
309
+ "user_quiet" => options[:quiet]
215
310
  })
216
311
  end
217
312
 
@@ -229,7 +324,8 @@ module Tugboat
229
324
  "user_droplet_id" => options[:id],
230
325
  "user_droplet_name" => options[:name],
231
326
  "user_droplet_fuzzy_name" => name,
232
- "user_snapshot_name" => snapshot_name
327
+ "user_snapshot_name" => snapshot_name,
328
+ "user_quiet" => options[:quiet]
233
329
  })
234
330
  end
235
331
 
@@ -242,7 +338,7 @@ module Tugboat
242
338
  method_option "key",
243
339
  :type => :string,
244
340
  :aliases => "-k",
245
- :desc => "The string of the key"
341
+ :desc => "The string of the key"
246
342
  method_option "path",
247
343
  :type => :string,
248
344
  :aliases => "-p",
@@ -252,12 +348,15 @@ module Tugboat
252
348
  "add_key_name" => name,
253
349
  "add_key_pub_key" => options[:key],
254
350
  "add_key_file_path" => options[:path],
351
+ "user_quiet" => options[:quiet]
255
352
  })
256
353
  end
257
354
 
258
355
  desc "regions", "Show regions"
259
356
  def regions
260
- Middleware.sequence_regions.call({})
357
+ Middleware.sequence_regions.call({
358
+ "user_quiet" => options[:quiet]
359
+ })
261
360
  end
262
361
 
263
362
  desc "version", "Show version"
@@ -267,7 +366,9 @@ module Tugboat
267
366
 
268
367
  desc "sizes", "Show available droplet sizes"
269
368
  def sizes
270
- Middleware.sequence_sizes.call({})
369
+ Middleware.sequence_sizes.call({
370
+ "user_quiet" => options[:quiet]
371
+ })
271
372
  end
272
373
 
273
374
  desc "start FUZZY_NAME", "Start a droplet"
@@ -283,7 +384,8 @@ module Tugboat
283
384
  Middleware.sequence_start_droplet.call({
284
385
  "user_droplet_id" => options[:id],
285
386
  "user_droplet_name" => options[:name],
286
- "user_droplet_fuzzy_name" => name
387
+ "user_droplet_fuzzy_name" => name,
388
+ "user_quiet" => options[:quiet]
287
389
  })
288
390
  end
289
391
 
@@ -306,7 +408,8 @@ module Tugboat
306
408
  "user_droplet_id" => options[:id],
307
409
  "user_droplet_name" => options[:name],
308
410
  "user_droplet_size" => options[:size],
309
- "user_droplet_fuzzy_name" => name
411
+ "user_droplet_fuzzy_name" => name,
412
+ "user_quiet" => options[:quiet]
310
413
  })
311
414
  end
312
415
 
@@ -319,11 +422,13 @@ module Tugboat
319
422
  :type => :string,
320
423
  :aliases => "-n",
321
424
  :desc => "The exact name of the droplet"
425
+
322
426
  def password_reset(name=nil)
323
427
  Middleware.sequence_password_reset.call({
324
428
  "user_droplet_id" => options[:id],
325
429
  "user_droplet_name" => options[:name],
326
- "user_droplet_fuzzy_name" => name
430
+ "user_droplet_fuzzy_name" => name,
431
+ "user_quiet" => options[:quiet]
327
432
  })
328
433
  end
329
434
 
@@ -341,14 +446,17 @@ module Tugboat
341
446
  :aliases => "-s",
342
447
  :default => "active",
343
448
  :desc => "The state of the droplet to wait for"
449
+
344
450
  def wait(name=nil)
345
451
  Middleware.sequence_wait.call({
346
452
  "user_droplet_id" => options[:id],
347
453
  "user_droplet_name" => options[:name],
348
454
  "user_droplet_desired_state" => options[:state],
349
- "user_droplet_fuzzy_name" => name
455
+ "user_droplet_fuzzy_name" => name,
456
+ "user_quiet" => options[:quiet]
350
457
  })
351
458
  end
352
459
  end
353
460
  end
354
461
 
462
+
@@ -17,6 +17,7 @@ module Tugboat
17
17
  DEFAULT_SIZE = '66'
18
18
  DEFAULT_SSH_KEY = ''
19
19
  DEFAULT_PRIVATE_NETWORKING = 'false'
20
+ DEFAULT_BACKUPS_ENABLED = 'false'
20
21
 
21
22
  def initialize
22
23
  @path = ENV["TUGBOAT_CONFIG_PATH"] || File.join(File.expand_path("~"), FILE_NAME)
@@ -72,6 +73,10 @@ module Tugboat
72
73
  @data['defaults'].nil? ? DEFAULT_PRIVATE_NETWORKING : @data['defaults']['private_networking']
73
74
  end
74
75
 
76
+ def default_backups_enabled
77
+ @data['defaults'].nil? ? DEFAULT_BACKUPS_ENABLED : @data['defaults']['backups_enabled']
78
+ end
79
+
75
80
  # Re-runs initialize
76
81
  def reset!
77
82
  self.send(:initialize)
@@ -83,7 +88,7 @@ module Tugboat
83
88
  end
84
89
 
85
90
  # Writes a config file
86
- def create_config_file(client, api, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking)
91
+ def create_config_file(client, api, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled)
87
92
  # Default SSH Key path
88
93
  if ssh_key_path.empty?
89
94
  ssh_key_path = File.join(File.expand_path("~"), DEFAULT_SSH_KEY_PATH)
@@ -117,6 +122,10 @@ module Tugboat
117
122
  private_networking = DEFAULT_PRIVATE_NETWORKING
118
123
  end
119
124
 
125
+ if backups_enabled.empty?
126
+ backups_enabled = DEFAULT_BACKUPS_ENABLED
127
+ end
128
+
120
129
  require 'yaml'
121
130
  File.open(@path, File::RDWR|File::TRUNC|File::CREAT, 0600) do |file|
122
131
  data = {
@@ -132,7 +141,8 @@ module Tugboat
132
141
  "image" => image,
133
142
  "size" => size,
134
143
  "ssh_key" => ssh_key,
135
- "private_networking" => private_networking
144
+ "private_networking" => private_networking,
145
+ "backups_enabled" => backups_enabled
136
146
  }
137
147
  }
138
148
  file.write data.to_yaml
@@ -11,10 +11,14 @@ module Tugboat
11
11
  autoload :CheckDropletInactive, "tugboat/middleware/check_droplet_inactive"
12
12
  autoload :ConfirmAction, "tugboat/middleware/confirm_action"
13
13
  autoload :CreateDroplet, "tugboat/middleware/create_droplet"
14
+ autoload :RebuildDroplet, "tugboat/middleware/rebuild_droplet"
14
15
  autoload :DestroyDroplet, "tugboat/middleware/destroy_droplet"
16
+ autoload :DestroyImage, "tugboat/middleware/destroy_image"
15
17
  autoload :FindDroplet, "tugboat/middleware/find_droplet"
18
+ autoload :FindImage, "tugboat/middleware/find_image"
16
19
  autoload :HaltDroplet, "tugboat/middleware/halt_droplet"
17
20
  autoload :InfoDroplet, "tugboat/middleware/info_droplet"
21
+ autoload :InfoImage, "tugboat/middleware/info_image"
18
22
  autoload :InjectClient, "tugboat/middleware/inject_client"
19
23
  autoload :InjectConfiguration, "tugboat/middleware/inject_configuration"
20
24
  autoload :ListDroplets, "tugboat/middleware/list_droplets"
@@ -119,6 +123,17 @@ module Tugboat
119
123
  end
120
124
  end
121
125
 
126
+ # Show information about an image
127
+ def self.sequence_info_image
128
+ ::Middleware::Builder.new do
129
+ use InjectConfiguration
130
+ use CheckConfiguration
131
+ use InjectClient
132
+ use FindImage
133
+ use InfoImage
134
+ end
135
+ end
136
+
122
137
  # SSH into a droplet
123
138
  def self.sequence_ssh_droplet
124
139
  ::Middleware::Builder.new do
@@ -141,6 +156,19 @@ module Tugboat
141
156
  end
142
157
  end
143
158
 
159
+ # Rebuild a droplet
160
+ def self.sequence_rebuild_droplet
161
+ ::Middleware::Builder.new do
162
+ use InjectConfiguration
163
+ use CheckConfiguration
164
+ use InjectClient
165
+ use FindDroplet
166
+ use FindImage
167
+ use ConfirmAction
168
+ use RebuildDroplet
169
+ end
170
+ end
171
+
144
172
  # Destroy a droplet
145
173
  def self.sequence_destroy_droplet
146
174
  ::Middleware::Builder.new do
@@ -153,6 +181,18 @@ module Tugboat
153
181
  end
154
182
  end
155
183
 
184
+ # Destroy an image
185
+ def self.sequence_destroy_image
186
+ ::Middleware::Builder.new do
187
+ use InjectConfiguration
188
+ use CheckConfiguration
189
+ use InjectClient
190
+ use FindImage
191
+ use ConfirmAction
192
+ use DestroyImage
193
+ end
194
+ end
195
+
156
196
  # Snapshot a droplet
157
197
  def self.sequence_snapshot_droplet
158
198
  ::Middleware::Builder.new do
@@ -19,9 +19,10 @@ module Tugboat
19
19
  size = ask "Enter your default size ID (optional, defaults to 66 (512MB)):"
20
20
  ssh_key = ask "Enter your default ssh key ID (optional, defaults to none):"
21
21
  private_networking = ask "Enter your default for private networking (optional, defaults to false):"
22
+ backups_enabled = ask "Enter your default for enabling backups (optional, defaults to false):"
22
23
 
23
24
  # Write the config file.
24
- env['config'].create_config_file(client_key, api_key, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking)
25
+ 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
26
  env['config'].reload!
26
27
 
27
28
  @app.call(env)