tugboat 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +64 -14
- data/CONTRIBUTING.md +3 -1
- data/README.md +264 -1
- data/Rakefile +3 -0
- data/lib/tugboat/config.rb +7 -2
- data/lib/tugboat/middleware/ask_for_credentials.rb +2 -1
- data/lib/tugboat/middleware/base.rb +7 -0
- data/lib/tugboat/middleware/custom_logger.rb +11 -4
- data/lib/tugboat/middleware/info_droplet.rb +1 -4
- data/lib/tugboat/middleware/info_image.rb +1 -0
- data/lib/tugboat/middleware/inject_client.rb +3 -12
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/authorize_cli_spec.rb +8 -0
- data/spec/cli/config_cli_spec.rb +2 -0
- data/spec/cli/create_cli_spec.rb +4 -4
- data/spec/cli/debug_cli_spec.rb +26 -6
- data/spec/cli/env_variable_spec.rb +2 -0
- data/spec/cli/info_cli_spec.rb +20 -0
- data/spec/cli/info_image_cli_spec.rb +4 -0
- data/spec/cli/wait_cli_spec.rb +5 -7
- data/spec/config_spec.rb +8 -1
- data/spec/shared/environment.rb +2 -1
- data/spec/spec_helper.rb +4 -1
- data/tugboat.gemspec +2 -1
- metadata +19 -6
- data/lib/tugboat/middleware/authentication_middleware.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8c7f40ec8f57278de6f0554c189d74fda010d97
|
4
|
+
data.tar.gz: 4be4fefc1760f3b2a4caaa4bcab754147b273084
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7525344456c0cc885294bfb17dde276f99277fc16f3ed5779c2a9d1a976872a7a67e475651ff75808dae0f2a3ed8d1311536389b35afb957518dcb49da443863
|
7
|
+
data.tar.gz: f3a895a5877808d06976d96b99531b58555f2aa6ecaa73886be28479ee78abb67f9ec29811da6b6ac2fced4062839f08839642f898288559e51ef5aaacf06c4f
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,19 +1,81 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [
|
3
|
+
## [v2.1.0](https://github.com/pearkes/tugboat/tree/v2.1.0) (2015-12-01)
|
4
4
|
|
5
|
-
[Full Changelog](https://github.com/pearkes/tugboat/compare/v2.0.1...
|
5
|
+
[Full Changelog](https://github.com/pearkes/tugboat/compare/v2.0.1...v2.1.0)
|
6
|
+
|
7
|
+
**Implemented enhancements:**
|
8
|
+
|
9
|
+
- --wait option would be useful for ssh [\#133](https://github.com/pearkes/tugboat/issues/133)
|
10
|
+
|
11
|
+
**Fixed bugs:**
|
12
|
+
|
13
|
+
- Show private ip alongside public ip in droplets list [\#220](https://github.com/pearkes/tugboat/issues/220)
|
14
|
+
|
15
|
+
- bug in connect [\#211](https://github.com/pearkes/tugboat/issues/211)
|
16
|
+
|
17
|
+
- Wrong color for successful snapshot creation? [\#209](https://github.com/pearkes/tugboat/issues/209)
|
18
|
+
|
19
|
+
- Seems to be a limit to the number of retrieved droplets [\#205](https://github.com/pearkes/tugboat/issues/205)
|
20
|
+
|
21
|
+
- tugboat ssh not using ssh-agent? [\#160](https://github.com/pearkes/tugboat/issues/160)
|
22
|
+
|
23
|
+
**Closed issues:**
|
24
|
+
|
25
|
+
- 'fuzzy name' message shows up even when full name is used [\#132](https://github.com/pearkes/tugboat/issues/132)
|
26
|
+
|
27
|
+
**Merged pull requests:**
|
28
|
+
|
29
|
+
- Add specs to private ip in droplet list fix from \#222 [\#223](https://github.com/pearkes/tugboat/pull/223) ([petems](https://github.com/petems))
|
30
|
+
|
31
|
+
- Lock simplecov version [\#222](https://github.com/pearkes/tugboat/pull/222) ([petems](https://github.com/petems))
|
32
|
+
|
33
|
+
- Fix showing of private ips when running 'tugboat droplets' [\#221](https://github.com/pearkes/tugboat/pull/221) ([mtbottle](https://github.com/mtbottle))
|
34
|
+
|
35
|
+
- Check credentials for all find droplets [\#219](https://github.com/pearkes/tugboat/pull/219) ([petems](https://github.com/petems))
|
36
|
+
|
37
|
+
- Fix v2 API changes [\#218](https://github.com/pearkes/tugboat/pull/218) ([pchaussalet](https://github.com/pchaussalet))
|
38
|
+
|
39
|
+
- Fixing error checking with new API 2.0 [\#217](https://github.com/pearkes/tugboat/pull/217) ([petems](https://github.com/petems))
|
40
|
+
|
41
|
+
- Changes logic when no ssh\_key\_path has been set [\#216](https://github.com/pearkes/tugboat/pull/216) ([petems](https://github.com/petems))
|
42
|
+
|
43
|
+
- Rename features folder [\#215](https://github.com/pearkes/tugboat/pull/215) ([petems](https://github.com/petems))
|
44
|
+
|
45
|
+
- Add SSH -w command [\#214](https://github.com/pearkes/tugboat/pull/214) ([petems](https://github.com/petems))
|
46
|
+
|
47
|
+
- Changes colour of successful snapshot to green [\#213](https://github.com/pearkes/tugboat/pull/213) ([petems](https://github.com/petems))
|
48
|
+
|
49
|
+
- Pagination regression fix for API 2.0 [\#212](https://github.com/pearkes/tugboat/pull/212) ([petems](https://github.com/petems))
|
50
|
+
|
51
|
+
- Fixes tests for each help text [\#208](https://github.com/pearkes/tugboat/pull/208) ([petems](https://github.com/petems))
|
52
|
+
|
53
|
+
- Enable pagination for Droplets list [\#210](https://github.com/pearkes/tugboat/pull/210) ([lachesis](https://github.com/lachesis))
|
6
54
|
|
7
55
|
## [v2.0.1](https://github.com/pearkes/tugboat/tree/v2.0.1) (2015-11-10)
|
8
56
|
|
9
57
|
[Full Changelog](https://github.com/pearkes/tugboat/compare/v2.0.0...v2.0.1)
|
10
58
|
|
59
|
+
**Implemented enhancements:**
|
60
|
+
|
61
|
+
- Setting client\_id and api\_key as environment variables in shell [\#176](https://github.com/pearkes/tugboat/issues/176)
|
62
|
+
|
63
|
+
- API v2.0 Support [\#122](https://github.com/pearkes/tugboat/issues/122)
|
64
|
+
|
11
65
|
**Fixed bugs:**
|
12
66
|
|
13
67
|
- Slugs don't work [\#204](https://github.com/pearkes/tugboat/issues/204)
|
14
68
|
|
15
69
|
- New Droplets dont have IP address immediatly, so the info command fails [\#198](https://github.com/pearkes/tugboat/issues/198)
|
16
70
|
|
71
|
+
**Closed issues:**
|
72
|
+
|
73
|
+
- API 2.0 Release Candidate Guinea Pigs and Feedback [\#182](https://github.com/pearkes/tugboat/issues/182)
|
74
|
+
|
75
|
+
- API 2.0 Switchover [\#161](https://github.com/pearkes/tugboat/issues/161)
|
76
|
+
|
77
|
+
- API v2 Support [\#102](https://github.com/pearkes/tugboat/issues/102)
|
78
|
+
|
17
79
|
**Merged pull requests:**
|
18
80
|
|
19
81
|
- Fixes format for creating droplets [\#207](https://github.com/pearkes/tugboat/pull/207) ([petems](https://github.com/petems))
|
@@ -26,10 +88,6 @@
|
|
26
88
|
|
27
89
|
**Implemented enhancements:**
|
28
90
|
|
29
|
-
- Setting client\_id and api\_key as environment variables in shell [\#176](https://github.com/pearkes/tugboat/issues/176)
|
30
|
-
|
31
|
-
- API v2.0 Support [\#122](https://github.com/pearkes/tugboat/issues/122)
|
32
|
-
|
33
91
|
- If a command that requires arguments is entered without arguments, print the help for that. [\#191](https://github.com/pearkes/tugboat/issues/191)
|
34
92
|
|
35
93
|
- Support traditional `-y` for automatically confirming a destructive action. [\#190](https://github.com/pearkes/tugboat/issues/190)
|
@@ -48,8 +106,6 @@
|
|
48
106
|
|
49
107
|
**Fixed bugs:**
|
50
108
|
|
51
|
-
- New Droplets dont have IP address immediatly, so the info command fails [\#198](https://github.com/pearkes/tugboat/issues/198)
|
52
|
-
|
53
109
|
- Ipv6 changes broke ssh [\#192](https://github.com/pearkes/tugboat/issues/192)
|
54
110
|
|
55
111
|
- tugboat doesn't work with team accounts, because they use api v2 [\#168](https://github.com/pearkes/tugboat/issues/168)
|
@@ -92,12 +148,6 @@
|
|
92
148
|
|
93
149
|
**Closed issues:**
|
94
150
|
|
95
|
-
- API 2.0 Release Candidate Guinea Pigs and Feedback [\#182](https://github.com/pearkes/tugboat/issues/182)
|
96
|
-
|
97
|
-
- API 2.0 Switchover [\#161](https://github.com/pearkes/tugboat/issues/161)
|
98
|
-
|
99
|
-
- API v2 Support [\#102](https://github.com/pearkes/tugboat/issues/102)
|
100
|
-
|
101
151
|
- Possible to delete an image/snapshot? [\#177](https://github.com/pearkes/tugboat/issues/177)
|
102
152
|
|
103
153
|
**Merged pull requests:**
|
data/CONTRIBUTING.md
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
To add a feature, fix a bug, or to run a development build of Tugboat
|
13
13
|
on your machine, clone down the repo and run:
|
14
14
|
|
15
|
-
$ bundle
|
15
|
+
$ bundle install --path vendor/bundle
|
16
16
|
|
17
17
|
You can then execute tugboat:
|
18
18
|
|
@@ -21,6 +21,8 @@ You can then execute tugboat:
|
|
21
21
|
As well as run the tests:
|
22
22
|
|
23
23
|
$ bundle exec rspec
|
24
|
+
Or
|
25
|
+
$ rake spec
|
24
26
|
|
25
27
|
To install the gem on your system from source:
|
26
28
|
|
data/README.md
CHANGED
@@ -243,7 +243,270 @@ After installation, source the bundle path in your `.bash_profile`/`.bashrc`:
|
|
243
243
|
|
244
244
|
Yes, please!
|
245
245
|
|
246
|
-
You can create a new issue [here](https://github.com/pearkes/tugboat/issues/new).
|
246
|
+
You can create a new issue [here](https://github.com/pearkes/tugboat/issues/new). To help with the investigation of your issue, you can set the environment variable DEBUG to give verbose Faraday logging.
|
247
|
+
|
248
|
+
* DEBUG=1 is full unredacted
|
249
|
+
* DEBUG=2 redacts private keys from the log.
|
250
|
+
|
251
|
+
Example:
|
252
|
+
|
253
|
+
```bash
|
254
|
+
DEBUG=2 bundle exec tugboat regions
|
255
|
+
I, [2015-12-06T12:04:27.148922 #92772] INFO -- : Started GET request to: https://api.digitalocean.com/v2/regions?per_page=200
|
256
|
+
D, [2015-12-06T12:04:27.149334 #92772] DEBUG -- : Request Headers:
|
257
|
+
----------------
|
258
|
+
Authorization : Bearer [TOKEN REDACTED]
|
259
|
+
Content-Type : application/json
|
260
|
+
User-Agent : Faraday v0.9.2
|
261
|
+
|
262
|
+
Request Body:
|
263
|
+
-------------
|
264
|
+
{
|
265
|
+
"regions": [
|
266
|
+
{
|
267
|
+
"name": "New York 1",
|
268
|
+
"slug": "nyc1",
|
269
|
+
"sizes": [
|
270
|
+
"32gb",
|
271
|
+
"16gb",
|
272
|
+
"2gb",
|
273
|
+
"1gb",
|
274
|
+
"4gb",
|
275
|
+
"8gb",
|
276
|
+
"512mb",
|
277
|
+
"64gb",
|
278
|
+
"48gb"
|
279
|
+
],
|
280
|
+
"features": [
|
281
|
+
"private_networking",
|
282
|
+
"backups",
|
283
|
+
"ipv6",
|
284
|
+
"metadata"
|
285
|
+
],
|
286
|
+
"available": true
|
287
|
+
},
|
288
|
+
{
|
289
|
+
"name": "Amsterdam 1",
|
290
|
+
"slug": "ams1",
|
291
|
+
"sizes": [
|
292
|
+
"16gb",
|
293
|
+
"2gb",
|
294
|
+
"1gb",
|
295
|
+
"4gb",
|
296
|
+
"8gb",
|
297
|
+
"512mb"
|
298
|
+
],
|
299
|
+
"features": [
|
300
|
+
"backups"
|
301
|
+
],
|
302
|
+
"available": true
|
303
|
+
},
|
304
|
+
{
|
305
|
+
"name": "San Francisco 1",
|
306
|
+
"slug": "sfo1",
|
307
|
+
"sizes": [
|
308
|
+
"32gb",
|
309
|
+
"16gb",
|
310
|
+
"2gb",
|
311
|
+
"1gb",
|
312
|
+
"4gb",
|
313
|
+
"8gb",
|
314
|
+
"512mb",
|
315
|
+
"64gb",
|
316
|
+
"48gb"
|
317
|
+
],
|
318
|
+
"features": [
|
319
|
+
"private_networking",
|
320
|
+
"backups",
|
321
|
+
"ipv6",
|
322
|
+
"metadata"
|
323
|
+
],
|
324
|
+
"available": true
|
325
|
+
},
|
326
|
+
{
|
327
|
+
"name": "New York 2",
|
328
|
+
"slug": "nyc2",
|
329
|
+
"sizes": [
|
330
|
+
"32gb",
|
331
|
+
"16gb",
|
332
|
+
"2gb",
|
333
|
+
"1gb",
|
334
|
+
"4gb",
|
335
|
+
"8gb",
|
336
|
+
"512mb",
|
337
|
+
"64gb",
|
338
|
+
"48gb"
|
339
|
+
],
|
340
|
+
"features": [
|
341
|
+
"private_networking",
|
342
|
+
"backups",
|
343
|
+
"ipv6",
|
344
|
+
"metadata"
|
345
|
+
],
|
346
|
+
"available": true
|
347
|
+
},
|
348
|
+
{
|
349
|
+
"name": "Amsterdam 2",
|
350
|
+
"slug": "ams2",
|
351
|
+
"sizes": [
|
352
|
+
"32gb",
|
353
|
+
"16gb",
|
354
|
+
"2gb",
|
355
|
+
"1gb",
|
356
|
+
"4gb",
|
357
|
+
"8gb",
|
358
|
+
"512mb",
|
359
|
+
"64gb",
|
360
|
+
"48gb"
|
361
|
+
],
|
362
|
+
"features": [
|
363
|
+
"private_networking",
|
364
|
+
"backups",
|
365
|
+
"ipv6",
|
366
|
+
"metadata"
|
367
|
+
],
|
368
|
+
"available": true
|
369
|
+
},
|
370
|
+
{
|
371
|
+
"name": "Singapore 1",
|
372
|
+
"slug": "sgp1",
|
373
|
+
"sizes": [
|
374
|
+
"32gb",
|
375
|
+
"16gb",
|
376
|
+
"2gb",
|
377
|
+
"1gb",
|
378
|
+
"4gb",
|
379
|
+
"8gb",
|
380
|
+
"512mb",
|
381
|
+
"64gb",
|
382
|
+
"48gb"
|
383
|
+
],
|
384
|
+
"features": [
|
385
|
+
"private_networking",
|
386
|
+
"backups",
|
387
|
+
"ipv6",
|
388
|
+
"metadata"
|
389
|
+
],
|
390
|
+
"available": true
|
391
|
+
},
|
392
|
+
{
|
393
|
+
"name": "London 1",
|
394
|
+
"slug": "lon1",
|
395
|
+
"sizes": [
|
396
|
+
"32gb",
|
397
|
+
"16gb",
|
398
|
+
"2gb",
|
399
|
+
"1gb",
|
400
|
+
"4gb",
|
401
|
+
"8gb",
|
402
|
+
"512mb",
|
403
|
+
"64gb",
|
404
|
+
"48gb"
|
405
|
+
],
|
406
|
+
"features": [
|
407
|
+
"private_networking",
|
408
|
+
"backups",
|
409
|
+
"ipv6",
|
410
|
+
"metadata"
|
411
|
+
],
|
412
|
+
"available": true
|
413
|
+
},
|
414
|
+
{
|
415
|
+
"name": "New York 3",
|
416
|
+
"slug": "nyc3",
|
417
|
+
"sizes": [
|
418
|
+
"32gb",
|
419
|
+
"16gb",
|
420
|
+
"2gb",
|
421
|
+
"1gb",
|
422
|
+
"4gb",
|
423
|
+
"8gb",
|
424
|
+
"512mb",
|
425
|
+
"64gb",
|
426
|
+
"48gb"
|
427
|
+
],
|
428
|
+
"features": [
|
429
|
+
"private_networking",
|
430
|
+
"backups",
|
431
|
+
"ipv6",
|
432
|
+
"metadata"
|
433
|
+
],
|
434
|
+
"available": true
|
435
|
+
},
|
436
|
+
{
|
437
|
+
"name": "Amsterdam 3",
|
438
|
+
"slug": "ams3",
|
439
|
+
"sizes": [
|
440
|
+
"32gb",
|
441
|
+
"16gb",
|
442
|
+
"2gb",
|
443
|
+
"1gb",
|
444
|
+
"4gb",
|
445
|
+
"8gb",
|
446
|
+
"512mb",
|
447
|
+
"64gb",
|
448
|
+
"48gb"
|
449
|
+
],
|
450
|
+
"features": [
|
451
|
+
"private_networking",
|
452
|
+
"backups",
|
453
|
+
"ipv6",
|
454
|
+
"metadata"
|
455
|
+
],
|
456
|
+
"available": true
|
457
|
+
},
|
458
|
+
{
|
459
|
+
"name": "Frankfurt 1",
|
460
|
+
"slug": "fra1",
|
461
|
+
"sizes": [
|
462
|
+
"32gb",
|
463
|
+
"16gb",
|
464
|
+
"2gb",
|
465
|
+
"1gb",
|
466
|
+
"4gb",
|
467
|
+
"8gb",
|
468
|
+
"512mb",
|
469
|
+
"64gb",
|
470
|
+
"48gb"
|
471
|
+
],
|
472
|
+
"features": [
|
473
|
+
"private_networking",
|
474
|
+
"backups",
|
475
|
+
"ipv6",
|
476
|
+
"metadata"
|
477
|
+
],
|
478
|
+
"available": true
|
479
|
+
},
|
480
|
+
{
|
481
|
+
"name": "Toronto 1",
|
482
|
+
"slug": "tor1",
|
483
|
+
"sizes": [
|
484
|
+
"32gb",
|
485
|
+
"16gb",
|
486
|
+
"2gb",
|
487
|
+
"1gb",
|
488
|
+
"4gb",
|
489
|
+
"8gb",
|
490
|
+
"512mb",
|
491
|
+
"64gb",
|
492
|
+
"48gb"
|
493
|
+
],
|
494
|
+
"features": [
|
495
|
+
"private_networking",
|
496
|
+
"backups",
|
497
|
+
"ipv6",
|
498
|
+
"metadata"
|
499
|
+
],
|
500
|
+
"available": true
|
501
|
+
}
|
502
|
+
],
|
503
|
+
"links": {
|
504
|
+
},
|
505
|
+
"meta": {
|
506
|
+
"total": 11
|
507
|
+
}
|
508
|
+
}
|
509
|
+
```
|
247
510
|
|
248
511
|
## Contributing
|
249
512
|
|
data/Rakefile
CHANGED
data/lib/tugboat/config.rb
CHANGED
@@ -106,7 +106,7 @@ module Tugboat
|
|
106
106
|
end
|
107
107
|
|
108
108
|
# Writes a config file
|
109
|
-
def create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled)
|
109
|
+
def create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled, ip6)
|
110
110
|
# Default SSH Key path
|
111
111
|
if ssh_key_path.empty?
|
112
112
|
ssh_key_path = File.join("~", DEFAULT_SSH_KEY_PATH)
|
@@ -144,6 +144,10 @@ module Tugboat
|
|
144
144
|
backups_enabled = DEFAULT_BACKUPS_ENABLED
|
145
145
|
end
|
146
146
|
|
147
|
+
if ip6.empty?
|
148
|
+
ip6 = DEFAULT_IP6
|
149
|
+
end
|
150
|
+
|
147
151
|
require 'yaml'
|
148
152
|
File.open(@path, File::RDWR|File::TRUNC|File::CREAT, 0600) do |file|
|
149
153
|
data = {
|
@@ -160,7 +164,8 @@ module Tugboat
|
|
160
164
|
"size" => size,
|
161
165
|
"ssh_key" => ssh_key,
|
162
166
|
"private_networking" => private_networking,
|
163
|
-
"backups_enabled" => backups_enabled
|
167
|
+
"backups_enabled" => backups_enabled,
|
168
|
+
"ip6" => ip6,
|
164
169
|
}
|
165
170
|
}
|
166
171
|
file.write data.to_yaml
|
@@ -20,9 +20,10 @@ module Tugboat
|
|
20
20
|
ssh_key = ask "Enter your default ssh key IDs (optional, defaults to none, comma separated string):"
|
21
21
|
private_networking = ask "Enter your default for private networking (optional, defaults to false):"
|
22
22
|
backups_enabled = ask "Enter your default for enabling backups (optional, defaults to false):"
|
23
|
+
ip6 = ask "Enter your default for IPv6 (optional, defaults to false):"
|
23
24
|
|
24
25
|
# Write the config file.
|
25
|
-
env['config'].create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled)
|
26
|
+
env['config'].create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled, ip6)
|
26
27
|
env['config'].reload!
|
27
28
|
|
28
29
|
@app.call(env)
|
@@ -18,6 +18,13 @@ module Tugboat
|
|
18
18
|
say "", :clear, false
|
19
19
|
end
|
20
20
|
|
21
|
+
def check_response_success(task_string, response)
|
22
|
+
unless response.success?
|
23
|
+
say "Failed to #{task_string}: #{response.message}", :red
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
21
28
|
def call(env)
|
22
29
|
@app.call(env)
|
23
30
|
end
|
@@ -27,8 +27,7 @@ module Tugboat
|
|
27
27
|
|
28
28
|
def filter(output)
|
29
29
|
if ENV['DEBUG'].to_i == 2
|
30
|
-
output = output.to_s.gsub(/
|
31
|
-
output = output.to_s.gsub(/api_key=[a-zA-Z0-9]*/,'api_key=[API-KEY]')
|
30
|
+
output = output.to_s.gsub(/Bearer [a-zA-Z0-9]*/,'Bearer [TOKEN REDACTED]')
|
32
31
|
output = output.to_s.gsub(/_digitalocean2_session_v2=[a-zA-Z0-9%-]*/,'_digitalocean2_session_v2=[SESSION_COOKIE]')
|
33
32
|
else
|
34
33
|
output
|
@@ -52,15 +51,23 @@ module Tugboat
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def debug_message(name, headers, body)
|
55
|
-
|
54
|
+
|
55
|
+
main_message = <<-MESSAGE.gsub(/^ +([^ ])/m, '\\1')
|
56
56
|
#{name} Headers:
|
57
57
|
----------------
|
58
58
|
#{format_headers(headers)}
|
59
59
|
|
60
60
|
#{name} Body:
|
61
61
|
-------------
|
62
|
-
#{body}
|
63
62
|
MESSAGE
|
63
|
+
main_message + pretty_body(body)
|
64
|
+
end
|
65
|
+
|
66
|
+
def pretty_body(body)
|
67
|
+
body_json = JSON.parse(body)
|
68
|
+
JSON.pretty_generate(body_json)
|
69
|
+
rescue JSON::ParserError => e
|
70
|
+
body
|
64
71
|
end
|
65
72
|
|
66
73
|
def format_headers(headers)
|
@@ -6,10 +6,7 @@ module Tugboat
|
|
6
6
|
|
7
7
|
response = ocean.droplet.show env["droplet_id"]
|
8
8
|
|
9
|
-
|
10
|
-
say "Failed to get info for Droplet: #{response.message}", :red
|
11
|
-
exit 1
|
12
|
-
end
|
9
|
+
check_response_success('get info for Droplet', response)
|
13
10
|
|
14
11
|
droplet = response.droplet
|
15
12
|
|
@@ -1,22 +1,11 @@
|
|
1
1
|
require 'barge'
|
2
|
+
require File.expand_path('../custom_logger', __FILE__)
|
2
3
|
|
3
4
|
module Tugboat
|
4
5
|
module Middleware
|
5
6
|
# Inject the digital ocean client into the environment
|
6
7
|
class InjectClient < Base
|
7
8
|
|
8
|
-
def tugboat_faraday
|
9
|
-
Faraday.new(:url => 'https://api.digitalocean.com/') do |faraday|
|
10
|
-
faraday.use AuthenticationMiddleware, @client_id, @api_key
|
11
|
-
faraday.use Faraday::Response::RaiseError
|
12
|
-
faraday.use CustomLogger if ENV['DEBUG']
|
13
|
-
faraday.request :url_encoded
|
14
|
-
faraday.response :rashify
|
15
|
-
faraday.response :json, :content_type => /\b(json|json-home)$/
|
16
|
-
faraday.adapter Faraday.default_adapter
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
9
|
def call(env)
|
21
10
|
# Sets the digital ocean client into the environment for use
|
22
11
|
# later.
|
@@ -24,6 +13,8 @@ module Tugboat
|
|
24
13
|
|
25
14
|
env['barge'] = Barge::Client.new(:access_token => @access_token)
|
26
15
|
|
16
|
+
env['barge'].faraday.use CustomLogger if ENV['DEBUG']
|
17
|
+
|
27
18
|
@app.call(env)
|
28
19
|
end
|
29
20
|
end
|
data/lib/tugboat/version.rb
CHANGED
@@ -36,6 +36,8 @@ describe Tugboat::CLI do
|
|
36
36
|
expect($stdin).to receive(:gets).and_return(private_networking)
|
37
37
|
expect($stdout).to receive(:print).with("Enter your default for enabling backups (optional, defaults to false): ")
|
38
38
|
expect($stdin).to receive(:gets).and_return(backups_enabled)
|
39
|
+
expect($stdout).to receive(:print).with("Enter your default for IPv6 (optional, defaults to false): ")
|
40
|
+
expect($stdin).to receive(:gets).and_return(ip6)
|
39
41
|
|
40
42
|
@cli.authorize
|
41
43
|
|
@@ -54,6 +56,7 @@ describe Tugboat::CLI do
|
|
54
56
|
expect(config["defaults"]["ssh_key"]).to eq ssh_key_id
|
55
57
|
expect(config["defaults"]["private_networking"]).to eq private_networking
|
56
58
|
expect(config["defaults"]["backups_enabled"]).to eq backups_enabled
|
59
|
+
expect(config["defaults"]["ip6"]).to eq ip6
|
57
60
|
end
|
58
61
|
|
59
62
|
it "sets defaults if no input given" do
|
@@ -82,6 +85,8 @@ describe Tugboat::CLI do
|
|
82
85
|
expect($stdin).to receive(:gets).and_return('')
|
83
86
|
expect($stdout).to receive(:print).with("Enter your default for enabling backups (optional, defaults to false): ")
|
84
87
|
expect($stdin).to receive(:gets).and_return('')
|
88
|
+
expect($stdout).to receive(:print).with("Enter your default for IPv6 (optional, defaults to false): ")
|
89
|
+
expect($stdin).to receive(:gets).and_return('')
|
85
90
|
|
86
91
|
@cli.authorize
|
87
92
|
|
@@ -98,6 +103,9 @@ describe Tugboat::CLI do
|
|
98
103
|
expect(config["ssh"]["ssh_key_path"]).to eq "~/.ssh/id_rsa"
|
99
104
|
expect(config["ssh"]["ssh_port"]).to eq "22"
|
100
105
|
expect(config["defaults"]["ssh_key"]).to eq ""
|
106
|
+
expect(config["defaults"]["private_networking"]).to eq 'false'
|
107
|
+
expect(config["defaults"]["backups_enabled"]).to eq 'false'
|
108
|
+
expect(config["defaults"]["ip6"]).to eq 'false'
|
101
109
|
end
|
102
110
|
end
|
103
111
|
|
data/spec/cli/config_cli_spec.rb
CHANGED
@@ -25,6 +25,7 @@ defaults:
|
|
25
25
|
ssh_key: '1234'
|
26
26
|
private_networking: 'false'
|
27
27
|
backups_enabled: 'false'
|
28
|
+
ip6: 'false'
|
28
29
|
eos
|
29
30
|
end
|
30
31
|
|
@@ -50,6 +51,7 @@ defaults:
|
|
50
51
|
ssh_key: '1234'
|
51
52
|
private_networking: 'false'
|
52
53
|
backups_enabled: 'false'
|
54
|
+
ip6: 'false'
|
53
55
|
eos
|
54
56
|
end
|
55
57
|
end
|
data/spec/cli/create_cli_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Tugboat::CLI do
|
|
6
6
|
describe "create a droplet" do
|
7
7
|
it "with a name, uses defaults from configuration" do
|
8
8
|
stub_request(:post, "https://api.digitalocean.com/v2/droplets").
|
9
|
-
with(:body => "{\"name\":\"foo\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\"
|
9
|
+
with(:body => "{\"name\":\"foo\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":null}",
|
10
10
|
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
11
11
|
to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
|
12
12
|
|
@@ -19,7 +19,7 @@ Queueing creation of droplet '#{droplet_name}'...Droplet created!
|
|
19
19
|
|
20
20
|
it "with args does not use defaults from configuration" do
|
21
21
|
stub_request(:post, "https://api.digitalocean.com/v2/droplets").
|
22
|
-
with(:body => "{\"name\":\"example.com\",\"size\":\"1gb\",\"image\":\"ubuntu-12-04-x64\",\"region\":\"nyc3\",\"ssh_keys\":[\"foo_bar_key\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\"
|
22
|
+
with(:body => "{\"name\":\"example.com\",\"size\":\"1gb\",\"image\":\"ubuntu-12-04-x64\",\"region\":\"nyc3\",\"ssh_keys\":[\"foo_bar_key\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":null}",
|
23
23
|
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
24
24
|
to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
|
25
25
|
|
@@ -49,7 +49,7 @@ Queueing creation of droplet 'example.com'...Droplet created!
|
|
49
49
|
|
50
50
|
it "with user data args" do
|
51
51
|
stub_request(:post, "https://api.digitalocean.com/v2/droplets").
|
52
|
-
with(:body => "{\"name\":\"example.com\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\"
|
52
|
+
with(:body => "{\"name\":\"example.com\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":\"#!/bin/bash\\n\\necho \\\"Hello world\\\"\"}",
|
53
53
|
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
54
54
|
to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
|
55
55
|
|
@@ -103,7 +103,7 @@ eos
|
|
103
103
|
|
104
104
|
it "does not clobber named droplets that contain the word help" do
|
105
105
|
stub_request(:post, "https://api.digitalocean.com/v2/droplets").
|
106
|
-
with(:body => "{\"name\":\"somethingblahblah--help\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\"
|
106
|
+
with(:body => "{\"name\":\"somethingblahblah--help\",\"size\":\"512mb\",\"image\":\"ubuntu-14-04-x64\",\"region\":\"nyc2\",\"ssh_keys\":[\"1234\"],\"private_networking\":\"false\",\"backups_enabled\":\"false\",\"ipv6\":\"false\",\"user_data\":null}",
|
107
107
|
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
108
108
|
to_return(:status => 200, :body => fixture('create_droplet'), :headers => {})
|
109
109
|
|
data/spec/cli/debug_cli_spec.rb
CHANGED
@@ -8,14 +8,24 @@ describe Tugboat::CLI do
|
|
8
8
|
allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
|
9
9
|
allow(ENV).to receive(:[]).with('DEBUG').and_return(1)
|
10
10
|
allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
|
11
|
+
allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return(nil)
|
11
12
|
end
|
12
13
|
|
13
14
|
it "gives full faraday logs" do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
|
16
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
17
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
18
|
+
|
19
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
|
20
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
21
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
22
|
+
|
18
23
|
@cli.droplets
|
24
|
+
|
25
|
+
expect($stdout.string).to include "Started GET request to: https://api.digitalocean.com/v2/droplets?page=1&per_page=200"
|
26
|
+
expect($stdout.string).to include "DEBUG -- : Request Headers:"
|
27
|
+
|
28
|
+
expect($stdout.string).to include "Bearer foo"
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
@@ -24,15 +34,25 @@ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200
|
|
24
34
|
allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
|
25
35
|
allow(ENV).to receive(:[]).with('DEBUG').and_return(2)
|
26
36
|
allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
|
37
|
+
allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return(nil)
|
27
38
|
end
|
28
39
|
|
29
40
|
it "gives full faraday logs with redacted API keys" do
|
30
|
-
|
31
|
-
|
41
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
|
42
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
43
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
44
|
+
|
45
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
|
32
46
|
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
33
47
|
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
34
48
|
@cli.droplets
|
49
|
+
|
50
|
+
expect($stdout.string).to include "Started GET request to: https://api.digitalocean.com/v2/droplets?page=1&per_page=200"
|
51
|
+
expect($stdout.string).to include "DEBUG -- : Request Headers:"
|
52
|
+
|
53
|
+
expect($stdout.string).to_not include "Bearer foo"
|
35
54
|
end
|
36
55
|
end
|
56
|
+
|
37
57
|
end
|
38
58
|
|
@@ -12,6 +12,7 @@ describe Tugboat::CLI do
|
|
12
12
|
allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
|
13
13
|
allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return('env_variable')
|
14
14
|
allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
|
15
|
+
allow(ENV).to receive(:[]).with('DEBUG').and_return(nil)
|
15
16
|
|
16
17
|
@cli.verify
|
17
18
|
expect($stdout.string).to eq "Authentication with DigitalOcean was successful.\n"
|
@@ -26,6 +27,7 @@ describe Tugboat::CLI do
|
|
26
27
|
allow(ENV).to receive(:[]).with('HOME').and_return('/tmp/fake_home')
|
27
28
|
allow(ENV).to receive(:[]).with('DO_API_TOKEN').and_return('')
|
28
29
|
allow(ENV).to receive(:[]).with('http_proxy').and_return(nil)
|
30
|
+
allow(ENV).to receive(:[]).with('DEBUG').and_return(nil)
|
29
31
|
|
30
32
|
@cli.verify
|
31
33
|
expect($stdout.string).to eq "Authentication with DigitalOcean was successful.\n"
|
data/spec/cli/info_cli_spec.rb
CHANGED
@@ -4,6 +4,26 @@ describe Tugboat::CLI do
|
|
4
4
|
include_context "spec"
|
5
5
|
|
6
6
|
describe "info" do
|
7
|
+
it "shows an error if response is not successful" do
|
8
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
|
9
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
10
|
+
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
11
|
+
|
12
|
+
stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
|
13
|
+
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
14
|
+
to_return(:status => 404, :body => fixture('not_found'), :headers => {})
|
15
|
+
|
16
|
+
@cli.options = @cli.options.merge(:id => 6918990)
|
17
|
+
|
18
|
+
expect {@cli.info}.to raise_error(SystemExit)
|
19
|
+
|
20
|
+
expect($stdout.string).to eq <<-eos
|
21
|
+
Droplet id provided. Finding Droplet...Failed to find Droplet: The resource you were accessing could not be found.
|
22
|
+
eos
|
23
|
+
|
24
|
+
expect(a_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200")).to have_been_made
|
25
|
+
end
|
26
|
+
|
7
27
|
it "shows a droplet with a fuzzy name" do
|
8
28
|
stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
|
9
29
|
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
@@ -22,6 +22,7 @@ Name: 745.1.0 (alpha)
|
|
22
22
|
ID: 12789325
|
23
23
|
Distribution: CoreOS
|
24
24
|
Min Disk Size: 20GB
|
25
|
+
Regions: nyc1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
|
25
26
|
eos
|
26
27
|
end
|
27
28
|
|
@@ -44,6 +45,7 @@ Name: Redmine on 14.04
|
|
44
45
|
ID: 12438838
|
45
46
|
Distribution: Ubuntu
|
46
47
|
Min Disk Size: 20GB
|
48
|
+
Regions: nyc1,ams1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
|
47
49
|
eos
|
48
50
|
end
|
49
51
|
|
@@ -66,6 +68,7 @@ Name: Redmine on 14.04
|
|
66
68
|
ID: 12438838
|
67
69
|
Distribution: Ubuntu
|
68
70
|
Min Disk Size: 20GB
|
71
|
+
Regions: nyc1,ams1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
|
69
72
|
eos
|
70
73
|
end
|
71
74
|
|
@@ -143,6 +146,7 @@ Name: 14.10 x32
|
|
143
146
|
ID: 9801951
|
144
147
|
Distribution: Ubuntu
|
145
148
|
Min Disk Size: 20GB
|
149
|
+
Regions: nyc1,ams1,sfo1,nyc2,ams2,sgp1,lon1,nyc3,ams3,fra1
|
146
150
|
eos
|
147
151
|
end
|
148
152
|
|
data/spec/cli/wait_cli_spec.rb
CHANGED
@@ -37,19 +37,17 @@ eos
|
|
37
37
|
|
38
38
|
stub_request(:get, "https://api.digitalocean.com/v2/droplets/6918990?per_page=200").
|
39
39
|
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
40
|
-
to_return(
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization'=>'Bearer foo', 'Content-Type'=>'application/json', 'User-Agent'=>'Faraday v0.9.2'}).
|
45
|
-
to_return(:status => 200, :body => fixture('show_droplet'), :headers => {})
|
40
|
+
to_return(
|
41
|
+
{:status => 200, :body => fixture('show_droplet_inactive'), :headers => {}},
|
42
|
+
{:status => 200, :body => fixture('show_droplet'), :headers => {}}
|
43
|
+
)
|
46
44
|
|
47
45
|
@cli.options = @cli.options.merge(:state => "active")
|
48
46
|
@cli.wait("example.com")
|
49
47
|
|
50
48
|
expect($stdout.string).to eq <<-eos
|
51
49
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
52
|
-
Waiting for droplet to become active
|
50
|
+
Waiting for droplet to become active...done\e[0m (2s)
|
53
51
|
eos
|
54
52
|
end
|
55
53
|
|
data/spec/config_spec.rb
CHANGED
@@ -33,12 +33,13 @@ describe Tugboat::Configuration do
|
|
33
33
|
let(:ssh_key_id) { '1234' }
|
34
34
|
let(:private_networking) { 'false' }
|
35
35
|
let(:backups_enabled) { 'false' }
|
36
|
+
let(:ip6) { 'false' }
|
36
37
|
|
37
38
|
let(:config) { config = Tugboat::Configuration.instance }
|
38
39
|
|
39
40
|
before :each do
|
40
41
|
# Create a temporary file
|
41
|
-
config.create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key_id, private_networking, backups_enabled)
|
42
|
+
config.create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key_id, private_networking, backups_enabled, ip6)
|
42
43
|
end
|
43
44
|
|
44
45
|
it "can be created" do
|
@@ -105,6 +106,7 @@ describe Tugboat::Configuration do
|
|
105
106
|
let(:config_default_ssh_key) { Tugboat::Configuration::DEFAULT_SSH_KEY }
|
106
107
|
let(:config_default_networking) { Tugboat::Configuration::DEFAULT_PRIVATE_NETWORKING }
|
107
108
|
let(:config_default_backups) { Tugboat::Configuration::DEFAULT_BACKUPS_ENABLED }
|
109
|
+
let(:config_default_ip6) { Tugboat::Configuration::DEFAULT_IP6 }
|
108
110
|
let(:backwards_config) {
|
109
111
|
{
|
110
112
|
'authentication' => { 'client_key' => client_key, 'api_key' => api_key },
|
@@ -151,5 +153,10 @@ describe Tugboat::Configuration do
|
|
151
153
|
expect(backups_enabled).to eql config_default_backups
|
152
154
|
end
|
153
155
|
|
156
|
+
it "should use default ip6 if not in the configuration" do
|
157
|
+
ip6 = config.default_ip6
|
158
|
+
expect(ip6).to eql config_default_ip6
|
159
|
+
end
|
160
|
+
|
154
161
|
end
|
155
162
|
end
|
data/spec/shared/environment.rb
CHANGED
@@ -19,6 +19,7 @@ shared_context "spec" do
|
|
19
19
|
let(:ssh_public_key) { 'ssh-dss A123= user@host' }
|
20
20
|
let(:private_networking) { 'false'}
|
21
21
|
let(:backups_enabled) { 'false'}
|
22
|
+
let(:ip6) { 'false' }
|
22
23
|
let(:ocean) { Barge::Client.new(:access_token => access_token) }
|
23
24
|
let(:app) { lambda { |env| } }
|
24
25
|
let(:env) { {} }
|
@@ -30,7 +31,7 @@ shared_context "spec" do
|
|
30
31
|
@cli = Tugboat::CLI.new
|
31
32
|
|
32
33
|
# Set a temprary project path and create fake config.
|
33
|
-
config.create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key_id, private_networking, backups_enabled)
|
34
|
+
config.create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key_id, private_networking, backups_enabled, ip6)
|
34
35
|
config.reload!
|
35
36
|
|
36
37
|
# Keep track of the old stderr / out
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'simplecov'
|
2
|
+
require 'simplecov-console'
|
2
3
|
require 'coveralls'
|
3
|
-
|
4
|
+
|
5
|
+
SimpleCov.formatters = [
|
4
6
|
SimpleCov::Formatter::HTMLFormatter,
|
7
|
+
SimpleCov::Formatter::Console,
|
5
8
|
Coveralls::SimpleCov::Formatter
|
6
9
|
]
|
7
10
|
SimpleCov.start do
|
data/tugboat.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.required_ruby_version = '>= 1.9.2'
|
20
20
|
|
21
21
|
gem.add_dependency 'thor', '~> 0.18.1'
|
22
|
-
gem.add_dependency 'barge', '~> 0.
|
22
|
+
gem.add_dependency 'barge', '~> 0.12.0'
|
23
23
|
gem.add_dependency 'middleware', '~> 0.1.0'
|
24
24
|
|
25
25
|
gem.add_development_dependency 'rake'
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |gem|
|
|
28
28
|
gem.add_development_dependency 'rspec-mocks', '~> 2.14.0'
|
29
29
|
gem.add_development_dependency 'webmock', '~> 1.11.0'
|
30
30
|
gem.add_development_dependency 'simplecov', '0.10'
|
31
|
+
gem.add_development_dependency 'simplecov-console', '0.2.0'
|
31
32
|
gem.add_development_dependency 'coveralls', '~> 0.6.7'
|
32
33
|
gem.add_development_dependency 'aruba', '~> 0.6.2'
|
33
34
|
gem.add_development_dependency 'pry'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tugboat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Pearkes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2016-01-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.12.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.12.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: middleware
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,6 +138,20 @@ dependencies:
|
|
138
138
|
- - '='
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0.10'
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: simplecov-console
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - '='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 0.2.0
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: 0.2.0
|
141
155
|
- !ruby/object:Gem::Dependency
|
142
156
|
name: coveralls
|
143
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,7 +221,6 @@ files:
|
|
207
221
|
- lib/tugboat/middleware.rb
|
208
222
|
- lib/tugboat/middleware/add_key.rb
|
209
223
|
- lib/tugboat/middleware/ask_for_credentials.rb
|
210
|
-
- lib/tugboat/middleware/authentication_middleware.rb
|
211
224
|
- lib/tugboat/middleware/base.rb
|
212
225
|
- lib/tugboat/middleware/check_configuration.rb
|
213
226
|
- lib/tugboat/middleware/check_credentials.rb
|
@@ -334,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
334
347
|
version: '0'
|
335
348
|
requirements: []
|
336
349
|
rubyforge_project:
|
337
|
-
rubygems_version: 2.
|
350
|
+
rubygems_version: 2.5.1
|
338
351
|
signing_key:
|
339
352
|
specification_version: 4
|
340
353
|
summary: A command line tool for interacting with your DigitalOcean droplets.
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Tugboat
|
2
|
-
class AuthenticationMiddleware < Faraday::Middleware
|
3
|
-
extend Forwardable
|
4
|
-
def_delegators :'Faraday::Utils', :parse_query, :build_query
|
5
|
-
RED = "\e[31m"
|
6
|
-
CLEAR = "\e[0m"
|
7
|
-
|
8
|
-
def initialize(app, client_id, api_key)
|
9
|
-
@client_id = client_id
|
10
|
-
@api_key = api_key
|
11
|
-
|
12
|
-
super(app)
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(env)
|
16
|
-
params = { 'client_id' => @client_id, 'api_key' => @api_key }.update query_params(env[:url])
|
17
|
-
|
18
|
-
env[:url].query = build_query params
|
19
|
-
|
20
|
-
begin
|
21
|
-
@app.call(env)
|
22
|
-
rescue Faraday::Error::ClientError => e
|
23
|
-
puts "#{RED}#{e}!#{CLEAR}\n"
|
24
|
-
if env[:body].is_a?(Hashie::Rash)
|
25
|
-
puts "\n#{RED}#{env[:body].error_message}#{CLEAR}\n\n"
|
26
|
-
end
|
27
|
-
puts "Double-check your parameters and configuration (in your ~/.tugboat file)" if env[:status] == 401
|
28
|
-
exit 1
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def query_params(url)
|
33
|
-
if url.query.nil? or url.query.empty?
|
34
|
-
{}
|
35
|
-
else
|
36
|
-
parse_query url.query
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|