tugboat 2.2.2 → 2.2.3
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +520 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +0 -6
- data/README.md +34 -2
- data/Rakefile +6 -1
- data/bin/tugboat +2 -2
- data/features/cassettes/config/Array_of_SSH_Keys_in_Config.yml +1 -1
- data/features/cassettes/config/Single_SSH_key_as_number_in_config.yml +1 -1
- data/features/step_definitions/steps.rb +1 -1
- data/features/support/env.rb +7 -3
- data/lib/tugboat.rb +2 -2
- data/lib/tugboat/cli.rb +394 -444
- data/lib/tugboat/config.rb +43 -61
- data/lib/tugboat/middleware.rb +33 -33
- data/lib/tugboat/middleware/add_key.rb +12 -13
- data/lib/tugboat/middleware/ask_for_credentials.rb +12 -13
- data/lib/tugboat/middleware/base.rb +25 -20
- data/lib/tugboat/middleware/check_configuration.rb +3 -6
- data/lib/tugboat/middleware/check_credentials.rb +0 -1
- data/lib/tugboat/middleware/check_droplet_active.rb +2 -4
- data/lib/tugboat/middleware/check_droplet_inactive.rb +2 -4
- data/lib/tugboat/middleware/config.rb +3 -5
- data/lib/tugboat/middleware/confirm_action.rb +4 -6
- data/lib/tugboat/middleware/create_droplet.rb +27 -44
- data/lib/tugboat/middleware/custom_logger.rb +52 -54
- data/lib/tugboat/middleware/destroy_droplet.rb +5 -6
- data/lib/tugboat/middleware/destroy_image.rb +5 -6
- data/lib/tugboat/middleware/find_droplet.rb +43 -47
- data/lib/tugboat/middleware/find_image.rb +23 -29
- data/lib/tugboat/middleware/halt_droplet.rb +9 -10
- data/lib/tugboat/middleware/info_droplet.rb +30 -33
- data/lib/tugboat/middleware/info_image.rb +1 -1
- data/lib/tugboat/middleware/inject_client.rb +8 -10
- data/lib/tugboat/middleware/inject_configuration.rb +1 -2
- data/lib/tugboat/middleware/list_droplets.rb +9 -10
- data/lib/tugboat/middleware/list_images.rb +9 -9
- data/lib/tugboat/middleware/list_regions.rb +1 -1
- data/lib/tugboat/middleware/list_sizes.rb +1 -1
- data/lib/tugboat/middleware/list_ssh_keys.rb +1 -3
- data/lib/tugboat/middleware/password_reset.rb +6 -7
- data/lib/tugboat/middleware/rebuild_droplet.rb +7 -7
- data/lib/tugboat/middleware/resize_droplet.rb +6 -7
- data/lib/tugboat/middleware/restart_droplet.rb +4 -11
- data/lib/tugboat/middleware/snapshot_droplet.rb +7 -8
- data/lib/tugboat/middleware/ssh_droplet.rb +30 -31
- data/lib/tugboat/middleware/start_droplet.rb +5 -5
- data/lib/tugboat/middleware/wait_for_state.rb +2 -3
- data/lib/tugboat/version.rb +1 -1
- data/spec/cli/add_key_spec.rb +25 -28
- data/spec/cli/authorize_cli_spec.rb +57 -60
- data/spec/cli/config_cli_spec.rb +8 -11
- data/spec/cli/create_cli_spec.rb +40 -46
- data/spec/cli/debug_cli_spec.rb +29 -29
- data/spec/cli/destroy_cli_spec.rb +58 -60
- data/spec/cli/destroy_image_cli_spec.rb +42 -45
- data/spec/cli/droplets_cli_spec.rb +62 -64
- data/spec/cli/env_variable_spec.rb +14 -15
- data/spec/cli/halt_cli_spec.rb +65 -69
- data/spec/cli/help_cli_spec.rb +8 -8
- data/spec/cli/images_cli_spec.rb +28 -30
- data/spec/cli/info_cli_spec.rb +144 -147
- data/spec/cli/info_image_cli_spec.rb +57 -60
- data/spec/cli/keys_cli_spec.rb +8 -10
- data/spec/cli/password_reset_cli_spec.rb +56 -56
- data/spec/cli/rebuild_cli_spec.rb +194 -198
- data/spec/cli/regions_cli_spec.rb +8 -8
- data/spec/cli/resize_cli_spec.rb +54 -56
- data/spec/cli/restart_cli_spec.rb +53 -57
- data/spec/cli/sizes_cli_spec.rb +7 -8
- data/spec/cli/snapshot_cli_spec.rb +50 -53
- data/spec/cli/ssh_cli_spec.rb +41 -42
- data/spec/cli/start_cli_spec.rb +48 -52
- data/spec/cli/verify_cli_spec.rb +22 -25
- data/spec/cli/version_cli_spec.rb +6 -8
- data/spec/cli/wait_cli_spec.rb +50 -52
- data/spec/config_spec.rb +56 -57
- data/spec/middleware/base_spec.rb +5 -6
- data/spec/middleware/check_configuration_spec.rb +5 -7
- data/spec/middleware/check_credentials_spec.rb +9 -10
- data/spec/middleware/check_droplet_active_spec.rb +5 -7
- data/spec/middleware/check_droplet_inactive_spec.rb +5 -7
- data/spec/middleware/find_droplet_spec.rb +4 -5
- data/spec/middleware/find_image_spec.rb +4 -5
- data/spec/middleware/inject_client_spec.rb +9 -12
- data/spec/middleware/inject_configuration_spec.rb +4 -7
- data/spec/middleware/ssh_droplet_spec.rb +70 -73
- data/spec/shared/environment.rb +18 -20
- data/spec/spec_helper.rb +4 -4
- data/tugboat.gemspec +10 -6
- metadata +88 -17
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::CLI do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
stub_request(:get,
|
9
|
-
|
10
|
-
|
6
|
+
describe 'regions' do
|
7
|
+
it 'shows a list' do
|
8
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/regions?per_page=200').
|
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.11.0' }).
|
10
|
+
to_return(status: 200, body: fixture('show_regions'), headers: { 'Content-Type' => 'application/json' })
|
11
11
|
|
12
|
-
|
12
|
+
cli.regions
|
13
13
|
|
14
14
|
expect($stdout.string).to eq <<-eos
|
15
15
|
Regions:
|
@@ -24,7 +24,7 @@ San Francisco 1 (slug: sfo1)
|
|
24
24
|
Singapore 1 (slug: sgp1)
|
25
25
|
eos
|
26
26
|
|
27
|
-
expect(a_request(:get,
|
27
|
+
expect(a_request(:get, 'https://api.digitalocean.com/v2/regions?per_page=200')).
|
28
28
|
to have_been_made
|
29
29
|
end
|
30
30
|
end
|
data/spec/cli/resize_cli_spec.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::CLI do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
stub_request(:get,
|
9
|
-
|
10
|
-
|
6
|
+
describe 'resize' do
|
7
|
+
it 'resizes a droplet with a fuzzy name' 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.11.0' }).
|
10
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
11
11
|
|
12
|
-
stub_request(:get,
|
13
|
-
|
14
|
-
|
12
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&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.11.0' }).
|
14
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
15
15
|
|
16
|
-
stub_request(:post,
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
17
|
+
with(body: '{"type":"resize","size":"1gb"}',
|
18
|
+
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.11.0' }).
|
19
|
+
to_return(status: 200, body: fixture('resize_droplet'), headers: {})
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
cli.options = cli.options.merge(size: '1gb')
|
22
|
+
cli.resize('example.com')
|
23
23
|
|
24
24
|
expect($stdout.string).to eq <<-eos
|
25
25
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
@@ -27,22 +27,22 @@ Queuing resize for 6918990 (example.com)...Resize complete!
|
|
27
27
|
eos
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
stub_request(:get,
|
32
|
-
|
33
|
-
|
30
|
+
it 'resizes a droplet with an id' do
|
31
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
32
|
+
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.11.0' }).
|
33
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
34
34
|
|
35
|
-
stub_request(:get,
|
36
|
-
|
37
|
-
|
35
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
36
|
+
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.11.0' }).
|
37
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
38
38
|
|
39
|
-
stub_request(:post,
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
40
|
+
with(body: '{"type":"resize","size":"1gb"}',
|
41
|
+
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.11.0' }).
|
42
|
+
to_return(status: 200, body: fixture('resize_droplet'), headers: {})
|
43
43
|
|
44
|
-
|
45
|
-
|
44
|
+
cli.options = cli.options.merge(size: '1gb', id: 6_918_990)
|
45
|
+
cli.resize
|
46
46
|
|
47
47
|
expect($stdout.string).to eq <<-eos
|
48
48
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
@@ -50,52 +50,50 @@ Queuing resize for 6918990 (example.com)...Resize complete!
|
|
50
50
|
eos
|
51
51
|
end
|
52
52
|
|
53
|
-
it
|
54
|
-
stub_request(:get,
|
55
|
-
|
56
|
-
|
53
|
+
it 'resizes a droplet with a name' do
|
54
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
55
|
+
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.11.0' }).
|
56
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
57
57
|
|
58
|
-
stub_request(:get,
|
59
|
-
|
60
|
-
|
58
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
59
|
+
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.11.0' }).
|
60
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
61
61
|
|
62
|
-
stub_request(:post,
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
63
|
+
with(body: '{"type":"resize","size":"1gb"}',
|
64
|
+
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.11.0' }).
|
65
|
+
to_return(status: 200, body: fixture('resize_droplet'), headers: {})
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
cli.options = cli.options.merge(size: '1gb', name: 'example.com')
|
68
|
+
cli.resize
|
69
69
|
|
70
70
|
expect($stdout.string).to eq <<-eos
|
71
71
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
72
72
|
Queuing resize for 6918990 (example.com)...Resize complete!
|
73
73
|
eos
|
74
|
-
|
75
74
|
end
|
76
75
|
|
77
|
-
it
|
78
|
-
stub_request(:get,
|
79
|
-
|
80
|
-
|
76
|
+
it 'raises SystemExit when a request fails' do
|
77
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
78
|
+
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.11.0' }).
|
79
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
81
80
|
|
82
|
-
stub_request(:get,
|
83
|
-
|
84
|
-
|
81
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
82
|
+
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.11.0' }).
|
83
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
85
84
|
|
86
|
-
stub_request(:post,
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
86
|
+
with(body: '{"type":"resize","size":"1gb"}',
|
87
|
+
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.11.0' }).
|
88
|
+
to_return(headers: { 'Content-Type' => 'application/json' }, status: 500, body: '{"status":"ERROR","message":"Some error"}')
|
90
89
|
|
91
|
-
|
92
|
-
expect {
|
90
|
+
cli.options = cli.options.merge(size: '1gb')
|
91
|
+
expect { cli.resize('example.com') }.to raise_error(SystemExit)
|
93
92
|
|
94
93
|
expect($stdout.string).to eq <<-eos
|
95
94
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
96
95
|
Queuing resize for 6918990 (example.com)...Failed to resize Droplet: Some error
|
97
96
|
eos
|
98
|
-
|
99
97
|
end
|
100
98
|
end
|
101
99
|
end
|
@@ -1,48 +1,47 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::CLI do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
stub_request(:get,
|
9
|
-
|
10
|
-
|
6
|
+
describe 'restarts a droplet' do
|
7
|
+
it 'with a fuzzy name' 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.11.0' }).
|
10
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
11
11
|
|
12
|
-
stub_request(:get,
|
13
|
-
|
14
|
-
|
12
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&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.11.0' }).
|
14
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
15
15
|
|
16
|
-
stub_request(:post,
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
17
|
+
with(body: '{"type":"reboot"}',
|
18
|
+
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.11.0' }).
|
19
|
+
to_return(status: 200, body: fixture('restart_response'), headers: {})
|
20
20
|
|
21
|
-
|
21
|
+
cli.restart('example.com')
|
22
22
|
|
23
23
|
expect($stdout.string).to eq <<-eos
|
24
24
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
25
25
|
Queuing restart for 6918990 (example.com)...Restart complete!
|
26
26
|
eos
|
27
|
-
|
28
27
|
end
|
29
28
|
|
30
|
-
it
|
31
|
-
stub_request(:get,
|
32
|
-
|
33
|
-
|
29
|
+
it 'restarts a droplet hard when the hard option is used' do
|
30
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
31
|
+
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.11.0' }).
|
32
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
34
33
|
|
35
|
-
stub_request(:get,
|
36
|
-
|
37
|
-
|
34
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
35
|
+
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.11.0' }).
|
36
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
38
37
|
|
39
|
-
stub_request(:post,
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
39
|
+
with(body: '{"type":"power_cycle"}',
|
40
|
+
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.11.0' }).
|
41
|
+
to_return(status: 200, body: '', headers: {})
|
43
42
|
|
44
|
-
|
45
|
-
|
43
|
+
cli.options = cli.options.merge(hard: true)
|
44
|
+
cli.restart('example.com')
|
46
45
|
|
47
46
|
expect($stdout.string).to eq <<-eos
|
48
47
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
@@ -50,22 +49,22 @@ Queuing hard restart for 6918990 (example.com)...Restart complete!
|
|
50
49
|
eos
|
51
50
|
end
|
52
51
|
|
53
|
-
it
|
54
|
-
stub_request(:get,
|
55
|
-
|
56
|
-
|
52
|
+
it 'with an id' do
|
53
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
54
|
+
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.11.0' }).
|
55
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
57
56
|
|
58
|
-
stub_request(:get,
|
59
|
-
|
60
|
-
|
57
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/6918990?per_page=200').
|
58
|
+
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.11.0' }).
|
59
|
+
to_return(status: 200, body: fixture('show_droplet'), headers: {})
|
61
60
|
|
62
|
-
stub_request(:post,
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
62
|
+
with(body: '{"type":"reboot"}',
|
63
|
+
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.11.0' }).
|
64
|
+
to_return(status: 200, body: fixture('restart_response'), headers: {})
|
66
65
|
|
67
|
-
|
68
|
-
|
66
|
+
cli.options = cli.options.merge(id: '6918990')
|
67
|
+
cli.restart
|
69
68
|
|
70
69
|
expect($stdout.string).to eq <<-eos
|
71
70
|
Droplet id provided. Finding Droplet...done\e[0m, 6918990 (example.com)
|
@@ -73,30 +72,27 @@ Queuing restart for 6918990 (example.com)...Restart complete!
|
|
73
72
|
eos
|
74
73
|
end
|
75
74
|
|
75
|
+
it 'with a name' do
|
76
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
77
|
+
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.11.0' }).
|
78
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
81
|
-
|
82
|
-
stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=200").
|
83
|
-
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'}).
|
84
|
-
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
80
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
81
|
+
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.11.0' }).
|
82
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
85
83
|
|
86
|
-
stub_request(:post,
|
87
|
-
|
88
|
-
|
89
|
-
|
84
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/6918990/actions').
|
85
|
+
with(body: '{"type":"reboot"}',
|
86
|
+
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.11.0' }).
|
87
|
+
to_return(status: 200, body: fixture('restart_response'), headers: {})
|
90
88
|
|
91
|
-
|
92
|
-
|
89
|
+
cli.options = cli.options.merge(name: 'example.com')
|
90
|
+
cli.restart
|
93
91
|
|
94
92
|
expect($stdout.string).to eq <<-eos
|
95
93
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
96
94
|
Queuing restart for 6918990 (example.com)...Restart complete!
|
97
95
|
eos
|
98
96
|
end
|
99
|
-
|
100
97
|
end
|
101
|
-
|
102
98
|
end
|
data/spec/cli/sizes_cli_spec.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::CLI do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
describe
|
7
|
-
it
|
6
|
+
describe 'sizes' do
|
7
|
+
it 'shows a list' do
|
8
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/sizes?per_page=200').
|
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.11.0' }).
|
10
|
+
to_return(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_sizes'))
|
8
11
|
|
9
|
-
|
10
|
-
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'}).
|
11
|
-
to_return(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => fixture("show_sizes"))
|
12
|
-
|
13
|
-
@cli.sizes
|
12
|
+
cli.sizes
|
14
13
|
|
15
14
|
expect($stdout.string).to eq <<-eos
|
16
15
|
Sizes:
|
@@ -1,26 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Tugboat::CLI do
|
4
|
-
include_context
|
4
|
+
include_context 'spec'
|
5
5
|
|
6
|
-
let(:snapshot_name)
|
6
|
+
let(:snapshot_name) { 'foo-snapshot' }
|
7
7
|
|
8
|
-
describe
|
9
|
-
it
|
10
|
-
stub_request(:get,
|
11
|
-
|
12
|
-
|
8
|
+
describe 'snapshots a droplet' do
|
9
|
+
it 'with a fuzzy name' do
|
10
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
11
|
+
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.11.0' }).
|
12
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
13
13
|
|
14
|
-
stub_request(:get,
|
15
|
-
with(:
|
16
|
-
to_return(:
|
14
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
15
|
+
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.11.0' }).
|
16
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
17
17
|
|
18
|
-
stub_request(:post,
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/3164444/actions').
|
19
|
+
with(body: '{"type":"snapshot","name":"foo-snapshot"}',
|
20
|
+
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.11.0' }).
|
21
|
+
to_return(status: 200, body: fixture('snapshot_response'), headers: {})
|
22
22
|
|
23
|
-
|
23
|
+
cli.snapshot(snapshot_name, 'example3.com')
|
24
24
|
|
25
25
|
expect($stdout.string).to eq <<-eos
|
26
26
|
Droplet fuzzy name provided. Finding droplet ID...done\e[0m, 3164444 (example3.com)
|
@@ -29,22 +29,22 @@ Queuing snapshot 'foo-snapshot' for 3164444 (example3.com)...Snapshot successful
|
|
29
29
|
eos
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
33
|
-
stub_request(:get,
|
34
|
-
|
35
|
-
|
32
|
+
it 'with an id' do
|
33
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
34
|
+
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.11.0' }).
|
35
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
36
36
|
|
37
|
-
stub_request(:get,
|
38
|
-
|
39
|
-
|
37
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets/3164444?per_page=200').
|
38
|
+
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.11.0' }).
|
39
|
+
to_return(headers: { 'Content-Type' => 'application/json' }, status: 200, body: fixture('show_droplet_inactive'))
|
40
40
|
|
41
|
-
stub_request(:post,
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/3164494/actions').
|
42
|
+
with(body: '{"type":"snapshot","name":"foo-snapshot"}',
|
43
|
+
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.11.0' }).
|
44
|
+
to_return(status: 200, body: fixture('snapshot_response'), headers: {})
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
cli.options = cli.options.merge(id: '3164444')
|
47
|
+
cli.snapshot(snapshot_name)
|
48
48
|
|
49
49
|
expect($stdout.string).to eq <<-eos
|
50
50
|
Droplet id provided. Finding Droplet...done\e[0m, 3164494 (example.com)
|
@@ -53,23 +53,22 @@ Queuing snapshot 'foo-snapshot' for 3164494 (example.com)...Snapshot successful!
|
|
53
53
|
eos
|
54
54
|
end
|
55
55
|
|
56
|
+
it 'with a name' do
|
57
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
58
|
+
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.11.0' }).
|
59
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
to_return(:status => 200, :body => fixture('show_droplets'), :headers => {})
|
61
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
62
|
+
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.11.0' }).
|
63
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
61
64
|
|
62
|
-
stub_request(:
|
63
|
-
|
64
|
-
|
65
|
+
stub_request(:post, 'https://api.digitalocean.com/v2/droplets/3164444/actions').
|
66
|
+
with(body: '{"type":"snapshot","name":"foo-snapshot"}',
|
67
|
+
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.11.0' }).
|
68
|
+
to_return(status: 200, body: fixture('snapshot_response'), headers: {})
|
65
69
|
|
66
|
-
|
67
|
-
|
68
|
-
: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'}).
|
69
|
-
to_return(:status => 200, :body => fixture('snapshot_response'), :headers => {})
|
70
|
-
|
71
|
-
@cli.options = @cli.options.merge(:name => 'example3.com')
|
72
|
-
@cli.snapshot(snapshot_name)
|
70
|
+
cli.options = cli.options.merge(name: 'example3.com')
|
71
|
+
cli.snapshot(snapshot_name)
|
73
72
|
|
74
73
|
expect($stdout.string).to eq <<-eos
|
75
74
|
Droplet name provided. Finding droplet ID...done\e[0m, 3164444 (example3.com)
|
@@ -78,24 +77,22 @@ Queuing snapshot 'foo-snapshot' for 3164444 (example3.com)...Snapshot successful
|
|
78
77
|
eos
|
79
78
|
end
|
80
79
|
|
81
|
-
it
|
82
|
-
stub_request(:get,
|
83
|
-
|
84
|
-
|
80
|
+
it 'does not snapshot a droplet that is active' do
|
81
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=1').
|
82
|
+
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.11.0' }).
|
83
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
85
84
|
|
86
|
-
stub_request(:get,
|
87
|
-
|
88
|
-
|
85
|
+
stub_request(:get, 'https://api.digitalocean.com/v2/droplets?page=1&per_page=200').
|
86
|
+
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.11.0' }).
|
87
|
+
to_return(status: 200, body: fixture('show_droplets'), headers: {})
|
89
88
|
|
90
|
-
|
91
|
-
expect {
|
89
|
+
cli.options = cli.options.merge(name: 'example.com')
|
90
|
+
expect { cli.snapshot(snapshot_name) }.to raise_error(SystemExit)
|
92
91
|
|
93
92
|
expect($stdout.string).to eq <<-eos
|
94
93
|
Droplet name provided. Finding droplet ID...done\e[0m, 6918990 (example.com)
|
95
94
|
Droplet must be off for this operation to be successful.
|
96
95
|
eos
|
97
96
|
end
|
98
|
-
|
99
97
|
end
|
100
|
-
|
101
98
|
end
|