tugboat 2.0.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -3
  3. data/features/{vagrant-adam → tugboat}/config_current_directory.feature +0 -0
  4. data/lib/tugboat/cli.rb +6 -1
  5. data/lib/tugboat/middleware/base.rb +59 -0
  6. data/lib/tugboat/middleware/check_credentials.rb +1 -10
  7. data/lib/tugboat/middleware/find_droplet.rb +23 -18
  8. data/lib/tugboat/middleware/list_droplets.rb +23 -19
  9. data/lib/tugboat/middleware/rebuild_droplet.rb +1 -1
  10. data/lib/tugboat/middleware/snapshot_droplet.rb +1 -1
  11. data/lib/tugboat/middleware/ssh_droplet.rb +15 -2
  12. data/lib/tugboat/middleware/wait_for_state.rb +1 -20
  13. data/lib/tugboat/version.rb +1 -1
  14. data/spec/cli/authorize_cli_spec.rb +2 -2
  15. data/spec/cli/create_cli_spec.rb +10 -10
  16. data/spec/cli/debug_cli_spec.rb +2 -2
  17. data/spec/cli/destroy_cli_spec.rb +22 -6
  18. data/spec/cli/droplets_cli_spec.rb +72 -8
  19. data/spec/cli/env_variable_spec.rb +4 -4
  20. data/spec/cli/halt_cli_spec.rb +24 -4
  21. data/spec/cli/info_cli_spec.rb +55 -10
  22. data/spec/cli/password_reset_cli_spec.rb +20 -4
  23. data/spec/cli/rebuild_cli_spec.rb +59 -19
  24. data/spec/cli/resize_cli_spec.rb +19 -3
  25. data/spec/cli/restart_cli_spec.rb +19 -3
  26. data/spec/cli/snapshot_cli_spec.rb +19 -3
  27. data/spec/cli/ssh_cli_spec.rb +37 -2
  28. data/spec/cli/start_cli_spec.rb +19 -3
  29. data/spec/cli/verify_cli_spec.rb +9 -9
  30. data/spec/cli/wait_cli_spec.rb +19 -3
  31. data/spec/fixtures/401.json +4 -0
  32. data/spec/fixtures/show_droplets.json +0 -4
  33. data/spec/fixtures/show_droplets_paginated_first.json +256 -0
  34. data/spec/fixtures/show_droplets_paginated_last.json +253 -0
  35. data/spec/fixtures/show_droplets_private_ip.json +258 -0
  36. data/spec/middleware/check_credentials_spec.rb +3 -3
  37. data/spec/middleware/ssh_droplet_spec.rb +21 -3
  38. data/tugboat.gemspec +1 -0
  39. metadata +26 -4
@@ -0,0 +1,258 @@
1
+ {
2
+ "droplets": [
3
+ {
4
+ "id": 6918990,
5
+ "name": "exampleprivate.com",
6
+ "memory": 512,
7
+ "vcpus": 1,
8
+ "disk": 20,
9
+ "locked": false,
10
+ "status": "active",
11
+ "kernel": {
12
+ "id": 2233,
13
+ "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic",
14
+ "version": "3.13.0-37-generic"
15
+ },
16
+ "created_at": "2014-11-14T16:29:21Z",
17
+ "features": [
18
+ "backups",
19
+ "ipv6",
20
+ "virtio"
21
+ ],
22
+ "backup_ids": [
23
+ 7938002
24
+ ],
25
+ "snapshot_ids": [
26
+
27
+ ],
28
+ "image": {
29
+ "id": 6918990,
30
+ "name": "14.04 x64",
31
+ "distribution": "Ubuntu",
32
+ "slug": "ubuntu-14-04-x64",
33
+ "public": true,
34
+ "regions": [
35
+ "nyc1",
36
+ "ams1",
37
+ "sfo1",
38
+ "nyc2",
39
+ "ams2",
40
+ "sgp1",
41
+ "lon1",
42
+ "nyc3",
43
+ "ams3",
44
+ "nyc3"
45
+ ],
46
+ "created_at": "2014-10-17T20:24:33Z",
47
+ "min_disk_size": 20
48
+ },
49
+ "size_slug": "512mb",
50
+ "networks": {
51
+ "v4": [
52
+ {
53
+ "ip_address": "104.236.32.182",
54
+ "netmask": "255.255.192.0",
55
+ "gateway": "104.236.0.1",
56
+ "type": "public"
57
+ },
58
+ {
59
+ "ip_address": "10.131.99.89",
60
+ "netmask": "255.255.0.0",
61
+ "gateway": "10.131.0.1",
62
+ "type": "private"
63
+ }
64
+ ],
65
+ "v6": [
66
+ {
67
+ "ip_address": "2604:A880:0800:0010:0000:0000:02DD:4001",
68
+ "netmask": 64,
69
+ "gateway": "2604:A880:0800:0010:0000:0000:0000:0001",
70
+ "type": "public"
71
+ }
72
+ ]
73
+ },
74
+ "region": {
75
+ "name": "New York 3",
76
+ "slug": "nyc3",
77
+ "sizes": [
78
+
79
+ ],
80
+ "features": [
81
+ "virtio",
82
+ "private_networking",
83
+ "backups",
84
+ "ipv6",
85
+ "metadata"
86
+ ],
87
+ "available": null
88
+ }
89
+ },
90
+ {
91
+ "id": 3164956,
92
+ "name": "example2.com",
93
+ "memory": 512,
94
+ "vcpus": 1,
95
+ "disk": 20,
96
+ "locked": false,
97
+ "status": "active",
98
+ "kernel": {
99
+ "id": 2233,
100
+ "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic",
101
+ "version": "3.13.0-37-generic"
102
+ },
103
+ "created_at": "2014-08-14T16:29:21Z",
104
+ "features": [
105
+ "backups",
106
+ "ipv6",
107
+ "virtio"
108
+ ],
109
+ "backup_ids": [
110
+ 7938002
111
+ ],
112
+ "snapshot_ids": [
113
+
114
+ ],
115
+ "image": {
116
+ "id": 6918990,
117
+ "name": "14.04 x64",
118
+ "distribution": "Ubuntu",
119
+ "slug": "ubuntu-14-04-x64",
120
+ "public": true,
121
+ "regions": [
122
+ "nyc1",
123
+ "ams1",
124
+ "sfo1",
125
+ "nyc2",
126
+ "ams2",
127
+ "sgp1",
128
+ "lon1",
129
+ "nyc3",
130
+ "ams3",
131
+ "nyc3"
132
+ ],
133
+ "created_at": "2014-10-17T20:24:33Z",
134
+ "min_disk_size": 20
135
+ },
136
+ "size_slug": "512mb",
137
+ "networks": {
138
+ "v4": [
139
+ {
140
+ "ip_address": "104.236.32.172",
141
+ "netmask": "255.255.192.0",
142
+ "gateway": "104.236.0.1",
143
+ "type": "public"
144
+ }
145
+ ],
146
+ "v6": [
147
+ {
148
+ "ip_address": "2604:A880:0800:0010:0000:0000:02DD:4001",
149
+ "netmask": 64,
150
+ "gateway": "2604:A880:0800:0010:0000:0000:0000:0001",
151
+ "type": "public"
152
+ }
153
+ ]
154
+ },
155
+ "region": {
156
+ "name": "New York 3",
157
+ "slug": "nyc3",
158
+ "sizes": [
159
+
160
+ ],
161
+ "features": [
162
+ "virtio",
163
+ "private_networking",
164
+ "backups",
165
+ "ipv6",
166
+ "metadata"
167
+ ],
168
+ "available": null
169
+ }
170
+ },
171
+ {
172
+ "id": 3164444,
173
+ "name": "example3.com",
174
+ "memory": 512,
175
+ "vcpus": 1,
176
+ "disk": 20,
177
+ "locked": false,
178
+ "status": "off",
179
+ "kernel": {
180
+ "id": 2233,
181
+ "name": "Ubuntu 14.04 x64 vmlinuz-3.13.0-37-generic",
182
+ "version": "3.13.0-37-generic"
183
+ },
184
+ "created_at": "2014-08-14T16:29:21Z",
185
+ "features": [
186
+ "backups",
187
+ "ipv6",
188
+ "virtio"
189
+ ],
190
+ "backup_ids": [
191
+ 7938002
192
+ ],
193
+ "snapshot_ids": [
194
+
195
+ ],
196
+ "image": {
197
+ "id": 6918990,
198
+ "name": "14.04 x64",
199
+ "distribution": "Ubuntu",
200
+ "slug": "ubuntu-14-04-x64",
201
+ "public": true,
202
+ "regions": [
203
+ "nyc1",
204
+ "ams1",
205
+ "sfo1",
206
+ "nyc2",
207
+ "ams2",
208
+ "sgp1",
209
+ "lon1",
210
+ "nyc3",
211
+ "ams3",
212
+ "nyc3"
213
+ ],
214
+ "created_at": "2014-10-17T20:24:33Z",
215
+ "min_disk_size": 20
216
+ },
217
+ "size_slug": "512mb",
218
+ "networks": {
219
+ "v4": [
220
+ {
221
+ "ip_address": "104.236.32.173",
222
+ "netmask": "255.255.192.0",
223
+ "gateway": "104.236.0.1",
224
+ "type": "public"
225
+ }
226
+ ],
227
+ "v6": [
228
+ {
229
+ "ip_address": "2604:A880:0800:0010:0000:0000:02DD:4001",
230
+ "netmask": 64,
231
+ "gateway": "2604:A880:0800:0010:0000:0000:0000:0001",
232
+ "type": "public"
233
+ }
234
+ ]
235
+ },
236
+ "region": {
237
+ "name": "New York 3",
238
+ "slug": "nyc3",
239
+ "sizes": [
240
+
241
+ ],
242
+ "features": [
243
+ "virtio",
244
+ "private_networking",
245
+ "backups",
246
+ "ipv6",
247
+ "metadata"
248
+ ],
249
+ "available": null
250
+ }
251
+ }
252
+ ],
253
+ "links": {
254
+ },
255
+ "meta": {
256
+ "total": 4
257
+ }
258
+ }
@@ -5,15 +5,15 @@ describe Tugboat::Middleware::CheckCredentials do
5
5
 
6
6
  describe ".call" do
7
7
  it "raises SystemExit with no configuration" do
8
- stub_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200").
8
+ stub_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1").
9
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(:headers => {'Content-Type' => 'application/json'}, :status => 200, :body => "<html>You are being redirected...</html>")
10
+ to_return(:headers => {'Content-Type' => 'application/json'}, :status => 401, :body => fixture('401'))
11
11
 
12
12
  # Inject the client.
13
13
  env["barge"] = ocean
14
14
 
15
15
  expect {described_class.new(app).call(env) }.to raise_error(SystemExit)
16
- expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?per_page=200")).
16
+ expect(a_request(:get, "https://api.digitalocean.com/v2/droplets?page=1&per_page=1")).
17
17
  to have_been_made
18
18
  end
19
19
  end
@@ -11,10 +11,10 @@ describe Tugboat::Middleware::SSHDroplet do
11
11
 
12
12
  it "exec ssh with correct options" do
13
13
  expect(Kernel).to receive(:exec).with("ssh",
14
- "-o", "IdentitiesOnly=yes",
15
14
  "-o", "LogLevel=ERROR",
16
15
  "-o", "StrictHostKeyChecking=no",
17
16
  "-o", "UserKnownHostsFile=/dev/null",
17
+ "-o", "IdentitiesOnly=yes",
18
18
  "-i", File.expand_path(ssh_key_path),
19
19
  "-p", ssh_port,
20
20
  "#{ssh_user}@#{droplet_ip}")
@@ -25,12 +25,30 @@ describe Tugboat::Middleware::SSHDroplet do
25
25
  described_class.new(app).call(env)
26
26
  end
27
27
 
28
+ it "exec ssh with IdentitiesOnly=no if no ssh_key_path in config" do
29
+ expect(Kernel).to receive(:exec).with("ssh",
30
+ "-o", "LogLevel=ERROR",
31
+ "-o", "StrictHostKeyChecking=no",
32
+ "-o", "UserKnownHostsFile=/dev/null",
33
+ "-o", "IdentitiesOnly=no",
34
+ "-p", ssh_port,
35
+ "#{ssh_user}@#{droplet_ip}")
36
+
37
+ env["droplet_ip"] = droplet_ip
38
+
39
+ config.data['ssh']['ssh_key_path'] = nil
40
+
41
+ env["config"] = config
42
+
43
+ described_class.new(app).call(env)
44
+ end
45
+
28
46
  it "executes ssh with custom options" do
29
47
  expect(Kernel).to receive(:exec).with("ssh",
30
- "-o", "IdentitiesOnly=yes",
31
48
  "-o", "LogLevel=ERROR",
32
49
  "-o", "StrictHostKeyChecking=no",
33
50
  "-o", "UserKnownHostsFile=/dev/null",
51
+ "-o", "IdentitiesOnly=yes",
34
52
  "-i", File.expand_path(ssh_key_path),
35
53
  "-p", ssh_port,
36
54
  "-e",
@@ -51,10 +69,10 @@ describe Tugboat::Middleware::SSHDroplet do
51
69
 
52
70
  it "executes ssh with private IP if option chosen" do
53
71
  expect(Kernel).to receive(:exec).with("ssh",
54
- "-o", "IdentitiesOnly=yes",
55
72
  "-o", "LogLevel=ERROR",
56
73
  "-o", "StrictHostKeyChecking=no",
57
74
  "-o", "UserKnownHostsFile=/dev/null",
75
+ "-o", "IdentitiesOnly=yes",
58
76
  "-i", File.expand_path(ssh_key_path),
59
77
  "-p", ssh_port,
60
78
  "-e",
@@ -27,6 +27,7 @@ Gem::Specification.new do |gem|
27
27
  gem.add_development_dependency 'rspec-expectations', '~> 2.14.0'
28
28
  gem.add_development_dependency 'rspec-mocks', '~> 2.14.0'
29
29
  gem.add_development_dependency 'webmock', '~> 1.11.0'
30
+ gem.add_development_dependency 'simplecov', '0.10'
30
31
  gem.add_development_dependency 'coveralls', '~> 0.6.7'
31
32
  gem.add_development_dependency 'aruba', '~> 0.6.2'
32
33
  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.0.1
4
+ version: 2.1.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: 2015-11-10 00:00:00.000000000 Z
13
+ date: 2015-12-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -124,6 +124,20 @@ dependencies:
124
124
  - - "~>"
125
125
  - !ruby/object:Gem::Version
126
126
  version: 1.11.0
127
+ - !ruby/object:Gem::Dependency
128
+ name: simplecov
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '='
132
+ - !ruby/object:Gem::Version
133
+ version: '0.10'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '='
139
+ - !ruby/object:Gem::Version
140
+ version: '0.10'
127
141
  - !ruby/object:Gem::Dependency
128
142
  name: coveralls
129
143
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +200,7 @@ files:
186
200
  - bin/tugboat
187
201
  - features/step_definitions/steps.rb
188
202
  - features/support/env.rb
189
- - features/vagrant-adam/config_current_directory.feature
203
+ - features/tugboat/config_current_directory.feature
190
204
  - lib/tugboat.rb
191
205
  - lib/tugboat/cli.rb
192
206
  - lib/tugboat/config.rb
@@ -254,6 +268,7 @@ files:
254
268
  - spec/cli/version_cli_spec.rb
255
269
  - spec/cli/wait_cli_spec.rb
256
270
  - spec/config_spec.rb
271
+ - spec/fixtures/401.json
257
272
  - spec/fixtures/500.html
258
273
  - spec/fixtures/create_droplet.json
259
274
  - spec/fixtures/create_ssh_key.json
@@ -271,6 +286,9 @@ files:
271
286
  - spec/fixtures/show_droplet_user_image.json
272
287
  - spec/fixtures/show_droplets.json
273
288
  - spec/fixtures/show_droplets_empty.json
289
+ - spec/fixtures/show_droplets_paginated_first.json
290
+ - spec/fixtures/show_droplets_paginated_last.json
291
+ - spec/fixtures/show_droplets_private_ip.json
274
292
  - spec/fixtures/show_image.json
275
293
  - spec/fixtures/show_images.json
276
294
  - spec/fixtures/show_images_empty.json
@@ -323,7 +341,7 @@ summary: A command line tool for interacting with your DigitalOcean droplets.
323
341
  test_files:
324
342
  - features/step_definitions/steps.rb
325
343
  - features/support/env.rb
326
- - features/vagrant-adam/config_current_directory.feature
344
+ - features/tugboat/config_current_directory.feature
327
345
  - spec/cli/add_key_spec.rb
328
346
  - spec/cli/authorize_cli_spec.rb
329
347
  - spec/cli/config_cli_spec.rb
@@ -352,6 +370,7 @@ test_files:
352
370
  - spec/cli/version_cli_spec.rb
353
371
  - spec/cli/wait_cli_spec.rb
354
372
  - spec/config_spec.rb
373
+ - spec/fixtures/401.json
355
374
  - spec/fixtures/500.html
356
375
  - spec/fixtures/create_droplet.json
357
376
  - spec/fixtures/create_ssh_key.json
@@ -369,6 +388,9 @@ test_files:
369
388
  - spec/fixtures/show_droplet_user_image.json
370
389
  - spec/fixtures/show_droplets.json
371
390
  - spec/fixtures/show_droplets_empty.json
391
+ - spec/fixtures/show_droplets_paginated_first.json
392
+ - spec/fixtures/show_droplets_paginated_last.json
393
+ - spec/fixtures/show_droplets_private_ip.json
372
394
  - spec/fixtures/show_image.json
373
395
  - spec/fixtures/show_images.json
374
396
  - spec/fixtures/show_images_empty.json