aptible-cli 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -50
- data/lib/aptible/cli/agent.rb +9 -3
- data/lib/aptible/cli/helpers/config_path.rb +11 -0
- data/lib/aptible/cli/helpers/log_drain.rb +85 -0
- data/lib/aptible/cli/helpers/metric_drain.rb +39 -0
- data/lib/aptible/cli/helpers/ssh.rb +5 -1
- data/lib/aptible/cli/helpers/token.rb +5 -1
- data/lib/aptible/cli/resource_formatter.rb +66 -3
- data/lib/aptible/cli/subcommands/apps.rb +5 -40
- data/lib/aptible/cli/subcommands/backup.rb +15 -7
- data/lib/aptible/cli/subcommands/db.rb +24 -21
- data/lib/aptible/cli/subcommands/log_drain.rb +159 -0
- data/lib/aptible/cli/subcommands/metric_drain.rb +137 -0
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/resource_formatter_spec.rb +1 -0
- data/spec/aptible/cli/subcommands/apps_spec.rb +10 -51
- data/spec/aptible/cli/subcommands/backup_spec.rb +1 -1
- data/spec/aptible/cli/subcommands/db_spec.rb +0 -26
- data/spec/aptible/cli/subcommands/environment_spec.rb +4 -2
- data/spec/aptible/cli/subcommands/log_drain_spec.rb +207 -0
- data/spec/aptible/cli/subcommands/metric_drain_spec.rb +183 -0
- data/spec/fabricators/account_fabricator.rb +3 -0
- data/spec/fabricators/app_fabricator.rb +1 -0
- data/spec/fabricators/database_disk_fabricator.rb +2 -1
- data/spec/fabricators/database_fabricator.rb +1 -0
- data/spec/fabricators/log_drain_fabricator.rb +21 -0
- data/spec/fabricators/metric_drain_fabricator.rb +8 -0
- data/spec/fabricators/service_fabricator.rb +1 -0
- data/spec/fabricators/vhost_fabricator.rb +1 -0
- data/spec/spec_helper.rb +4 -0
- metadata +15 -5
- data/lib/aptible/cli/subcommands/domains.rb +0 -40
- data/spec/aptible/cli/subcommands/domains_spec.rb +0 -76
@@ -0,0 +1,21 @@
|
|
1
|
+
class StubLogDrain < OpenStruct
|
2
|
+
def attributes
|
3
|
+
# I foresee hard-coding values like this
|
4
|
+
# being hard to debug in the future,
|
5
|
+
# so sorry if you're here and cursing me, but
|
6
|
+
# I can't think of a better way to fake this.
|
7
|
+
{
|
8
|
+
'drain_username' => drain_username,
|
9
|
+
'drain_host' => drain_host,
|
10
|
+
'drain_port' => drain_port,
|
11
|
+
'url' => url
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Fabricator(:log_drain, from: :stub_log_drain) do
|
17
|
+
id { sequence(:log_drain_id) }
|
18
|
+
account
|
19
|
+
|
20
|
+
after_create { |drain| drain.account.log_drains << drain }
|
21
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Macreery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-resource
|
@@ -274,8 +274,11 @@ files:
|
|
274
274
|
- lib/aptible/cli/formatter/value.rb
|
275
275
|
- lib/aptible/cli/helpers/app.rb
|
276
276
|
- lib/aptible/cli/helpers/app_or_database.rb
|
277
|
+
- lib/aptible/cli/helpers/config_path.rb
|
277
278
|
- lib/aptible/cli/helpers/database.rb
|
278
279
|
- lib/aptible/cli/helpers/environment.rb
|
280
|
+
- lib/aptible/cli/helpers/log_drain.rb
|
281
|
+
- lib/aptible/cli/helpers/metric_drain.rb
|
279
282
|
- lib/aptible/cli/helpers/operation.rb
|
280
283
|
- lib/aptible/cli/helpers/security_key.rb
|
281
284
|
- lib/aptible/cli/helpers/ssh.rb
|
@@ -294,11 +297,12 @@ files:
|
|
294
297
|
- lib/aptible/cli/subcommands/config.rb
|
295
298
|
- lib/aptible/cli/subcommands/db.rb
|
296
299
|
- lib/aptible/cli/subcommands/deploy.rb
|
297
|
-
- lib/aptible/cli/subcommands/domains.rb
|
298
300
|
- lib/aptible/cli/subcommands/endpoints.rb
|
299
301
|
- lib/aptible/cli/subcommands/environment.rb
|
300
302
|
- lib/aptible/cli/subcommands/inspect.rb
|
303
|
+
- lib/aptible/cli/subcommands/log_drain.rb
|
301
304
|
- lib/aptible/cli/subcommands/logs.rb
|
305
|
+
- lib/aptible/cli/subcommands/metric_drain.rb
|
302
306
|
- lib/aptible/cli/subcommands/operation.rb
|
303
307
|
- lib/aptible/cli/subcommands/rebuild.rb
|
304
308
|
- lib/aptible/cli/subcommands/restart.rb
|
@@ -323,11 +327,12 @@ files:
|
|
323
327
|
- spec/aptible/cli/subcommands/config_spec.rb
|
324
328
|
- spec/aptible/cli/subcommands/db_spec.rb
|
325
329
|
- spec/aptible/cli/subcommands/deploy_spec.rb
|
326
|
-
- spec/aptible/cli/subcommands/domains_spec.rb
|
327
330
|
- spec/aptible/cli/subcommands/endpoints_spec.rb
|
328
331
|
- spec/aptible/cli/subcommands/environment_spec.rb
|
329
332
|
- spec/aptible/cli/subcommands/inspect_spec.rb
|
333
|
+
- spec/aptible/cli/subcommands/log_drain_spec.rb
|
330
334
|
- spec/aptible/cli/subcommands/logs_spec.rb
|
335
|
+
- spec/aptible/cli/subcommands/metric_drain_spec.rb
|
331
336
|
- spec/aptible/cli/subcommands/operation_spec.rb
|
332
337
|
- spec/aptible/cli/subcommands/rebuild_spec.rb
|
333
338
|
- spec/aptible/cli/subcommands/restart_spec.rb
|
@@ -343,6 +348,8 @@ files:
|
|
343
348
|
- spec/fabricators/database_disk_fabricator.rb
|
344
349
|
- spec/fabricators/database_fabricator.rb
|
345
350
|
- spec/fabricators/database_image_fabricator.rb
|
351
|
+
- spec/fabricators/log_drain_fabricator.rb
|
352
|
+
- spec/fabricators/metric_drain_fabricator.rb
|
346
353
|
- spec/fabricators/operation_fabricator.rb
|
347
354
|
- spec/fabricators/service_fabricator.rb
|
348
355
|
- spec/fabricators/stack_fabricator.rb
|
@@ -398,11 +405,12 @@ test_files:
|
|
398
405
|
- spec/aptible/cli/subcommands/config_spec.rb
|
399
406
|
- spec/aptible/cli/subcommands/db_spec.rb
|
400
407
|
- spec/aptible/cli/subcommands/deploy_spec.rb
|
401
|
-
- spec/aptible/cli/subcommands/domains_spec.rb
|
402
408
|
- spec/aptible/cli/subcommands/endpoints_spec.rb
|
403
409
|
- spec/aptible/cli/subcommands/environment_spec.rb
|
404
410
|
- spec/aptible/cli/subcommands/inspect_spec.rb
|
411
|
+
- spec/aptible/cli/subcommands/log_drain_spec.rb
|
405
412
|
- spec/aptible/cli/subcommands/logs_spec.rb
|
413
|
+
- spec/aptible/cli/subcommands/metric_drain_spec.rb
|
406
414
|
- spec/aptible/cli/subcommands/operation_spec.rb
|
407
415
|
- spec/aptible/cli/subcommands/rebuild_spec.rb
|
408
416
|
- spec/aptible/cli/subcommands/restart_spec.rb
|
@@ -418,6 +426,8 @@ test_files:
|
|
418
426
|
- spec/fabricators/database_disk_fabricator.rb
|
419
427
|
- spec/fabricators/database_fabricator.rb
|
420
428
|
- spec/fabricators/database_image_fabricator.rb
|
429
|
+
- spec/fabricators/log_drain_fabricator.rb
|
430
|
+
- spec/fabricators/metric_drain_fabricator.rb
|
421
431
|
- spec/fabricators/operation_fabricator.rb
|
422
432
|
- spec/fabricators/service_fabricator.rb
|
423
433
|
- spec/fabricators/stack_fabricator.rb
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'shellwords'
|
2
|
-
|
3
|
-
module Aptible
|
4
|
-
module CLI
|
5
|
-
module Subcommands
|
6
|
-
module Domains
|
7
|
-
def self.included(thor)
|
8
|
-
thor.class_eval do
|
9
|
-
include Helpers::Operation
|
10
|
-
include Helpers::App
|
11
|
-
|
12
|
-
desc 'domains',
|
13
|
-
"Print an app's current virtual domains - DEPRECATED"
|
14
|
-
app_options
|
15
|
-
option :verbose, aliases: '-v'
|
16
|
-
def domains
|
17
|
-
deprecated 'This command is deprecated in favor of endpoints:list'
|
18
|
-
app = ensure_app(options)
|
19
|
-
print_vhosts(app) do |vhost|
|
20
|
-
if options[:verbose]
|
21
|
-
"#{vhost.virtual_domain} -> #{vhost.external_host}"
|
22
|
-
else
|
23
|
-
vhost.virtual_domain
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def print_vhosts(app)
|
31
|
-
(app.vhosts || []).each do |vhost|
|
32
|
-
say yield(vhost)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,76 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Aptible::CLI::Agent do
|
4
|
-
before do
|
5
|
-
allow(subject).to receive(:ask)
|
6
|
-
allow(subject).to receive(:save_token)
|
7
|
-
allow(subject).to receive(:fetch_token) { double 'token' }
|
8
|
-
end
|
9
|
-
|
10
|
-
let!(:account) { Fabricate(:account) }
|
11
|
-
let!(:app) { Fabricate(:app, handle: 'hello', account: account) }
|
12
|
-
let!(:service) { Fabricate(:service, app: app) }
|
13
|
-
let(:op) { Fabricate(:operation, status: 'succeeded', resource: app) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
allow(Aptible::Api::App).to receive(:all) { [app] }
|
17
|
-
allow(Aptible::Api::Account).to receive(:all) { [account] }
|
18
|
-
end
|
19
|
-
|
20
|
-
let!(:vhost1) do
|
21
|
-
Fabricate(:vhost, virtual_domain: 'domain1', external_host: 'host1',
|
22
|
-
service: service)
|
23
|
-
end
|
24
|
-
|
25
|
-
let!(:vhost2) do
|
26
|
-
Fabricate(:vhost, virtual_domain: 'domain2', external_host: 'host2',
|
27
|
-
service: service)
|
28
|
-
end
|
29
|
-
|
30
|
-
describe '#domains' do
|
31
|
-
it 'should print out the hostnames' do
|
32
|
-
expect(subject).to receive(:environment_from_handle)
|
33
|
-
.with('foobar')
|
34
|
-
.and_return(account)
|
35
|
-
expect(subject).to receive(:apps_from_handle).and_return([app])
|
36
|
-
allow(subject).to receive(:options) do
|
37
|
-
{ environment: 'foobar', app: 'web' }
|
38
|
-
end
|
39
|
-
expect(subject).to receive(:say).with('domain1')
|
40
|
-
expect(subject).to receive(:say).with('domain2')
|
41
|
-
|
42
|
-
subject.send('domains')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should fail if app is non-existent' do
|
46
|
-
allow(subject).to receive(:options) { { app: 'not-an-app' } }
|
47
|
-
|
48
|
-
expect do
|
49
|
-
subject.send('domains')
|
50
|
-
end.to raise_error(Thor::Error, /Could not find app/)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'should fail if environment is non-existent' do
|
54
|
-
allow(Aptible::Api::Account).to receive(:all) { [] }
|
55
|
-
|
56
|
-
expect do
|
57
|
-
subject.send('domains')
|
58
|
-
end.to raise_error(Thor::Error)
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should print hostnames if -v is passed' do
|
62
|
-
expect(subject).to receive(:environment_from_handle)
|
63
|
-
.with('foobar')
|
64
|
-
.and_return(account)
|
65
|
-
expect(subject).to receive(:apps_from_handle).and_return([app])
|
66
|
-
allow(subject).to receive(:options) do
|
67
|
-
{ verbose: true, app: 'hello', environment: 'foobar' }
|
68
|
-
end
|
69
|
-
|
70
|
-
expect(subject).to receive(:say).with('domain1 -> host1')
|
71
|
-
expect(subject).to receive(:say).with('domain2 -> host2')
|
72
|
-
|
73
|
-
subject.send('domains')
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|