aptible-cli 0.18.3 → 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 +6 -2
- data/lib/aptible/cli/helpers/log_drain.rb +85 -0
- data/lib/aptible/cli/helpers/metric_drain.rb +39 -0
- data/lib/aptible/cli/resource_formatter.rb +43 -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 +23 -20
- 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/subcommands/apps_spec.rb +0 -47
- 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/log_drain_spec.rb +207 -0
- data/spec/aptible/cli/subcommands/metric_drain_spec.rb +183 -0
- data/spec/fabricators/account_fabricator.rb +2 -0
- data/spec/fabricators/log_drain_fabricator.rb +21 -0
- data/spec/fabricators/metric_drain_fabricator.rb +8 -0
- metadata +14 -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
|
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-07-
|
11
|
+
date: 2021-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-resource
|
@@ -277,6 +277,8 @@ files:
|
|
277
277
|
- lib/aptible/cli/helpers/config_path.rb
|
278
278
|
- lib/aptible/cli/helpers/database.rb
|
279
279
|
- lib/aptible/cli/helpers/environment.rb
|
280
|
+
- lib/aptible/cli/helpers/log_drain.rb
|
281
|
+
- lib/aptible/cli/helpers/metric_drain.rb
|
280
282
|
- lib/aptible/cli/helpers/operation.rb
|
281
283
|
- lib/aptible/cli/helpers/security_key.rb
|
282
284
|
- lib/aptible/cli/helpers/ssh.rb
|
@@ -295,11 +297,12 @@ files:
|
|
295
297
|
- lib/aptible/cli/subcommands/config.rb
|
296
298
|
- lib/aptible/cli/subcommands/db.rb
|
297
299
|
- lib/aptible/cli/subcommands/deploy.rb
|
298
|
-
- lib/aptible/cli/subcommands/domains.rb
|
299
300
|
- lib/aptible/cli/subcommands/endpoints.rb
|
300
301
|
- lib/aptible/cli/subcommands/environment.rb
|
301
302
|
- lib/aptible/cli/subcommands/inspect.rb
|
303
|
+
- lib/aptible/cli/subcommands/log_drain.rb
|
302
304
|
- lib/aptible/cli/subcommands/logs.rb
|
305
|
+
- lib/aptible/cli/subcommands/metric_drain.rb
|
303
306
|
- lib/aptible/cli/subcommands/operation.rb
|
304
307
|
- lib/aptible/cli/subcommands/rebuild.rb
|
305
308
|
- lib/aptible/cli/subcommands/restart.rb
|
@@ -324,11 +327,12 @@ files:
|
|
324
327
|
- spec/aptible/cli/subcommands/config_spec.rb
|
325
328
|
- spec/aptible/cli/subcommands/db_spec.rb
|
326
329
|
- spec/aptible/cli/subcommands/deploy_spec.rb
|
327
|
-
- spec/aptible/cli/subcommands/domains_spec.rb
|
328
330
|
- spec/aptible/cli/subcommands/endpoints_spec.rb
|
329
331
|
- spec/aptible/cli/subcommands/environment_spec.rb
|
330
332
|
- spec/aptible/cli/subcommands/inspect_spec.rb
|
333
|
+
- spec/aptible/cli/subcommands/log_drain_spec.rb
|
331
334
|
- spec/aptible/cli/subcommands/logs_spec.rb
|
335
|
+
- spec/aptible/cli/subcommands/metric_drain_spec.rb
|
332
336
|
- spec/aptible/cli/subcommands/operation_spec.rb
|
333
337
|
- spec/aptible/cli/subcommands/rebuild_spec.rb
|
334
338
|
- spec/aptible/cli/subcommands/restart_spec.rb
|
@@ -344,6 +348,8 @@ files:
|
|
344
348
|
- spec/fabricators/database_disk_fabricator.rb
|
345
349
|
- spec/fabricators/database_fabricator.rb
|
346
350
|
- spec/fabricators/database_image_fabricator.rb
|
351
|
+
- spec/fabricators/log_drain_fabricator.rb
|
352
|
+
- spec/fabricators/metric_drain_fabricator.rb
|
347
353
|
- spec/fabricators/operation_fabricator.rb
|
348
354
|
- spec/fabricators/service_fabricator.rb
|
349
355
|
- spec/fabricators/stack_fabricator.rb
|
@@ -399,11 +405,12 @@ test_files:
|
|
399
405
|
- spec/aptible/cli/subcommands/config_spec.rb
|
400
406
|
- spec/aptible/cli/subcommands/db_spec.rb
|
401
407
|
- spec/aptible/cli/subcommands/deploy_spec.rb
|
402
|
-
- spec/aptible/cli/subcommands/domains_spec.rb
|
403
408
|
- spec/aptible/cli/subcommands/endpoints_spec.rb
|
404
409
|
- spec/aptible/cli/subcommands/environment_spec.rb
|
405
410
|
- spec/aptible/cli/subcommands/inspect_spec.rb
|
411
|
+
- spec/aptible/cli/subcommands/log_drain_spec.rb
|
406
412
|
- spec/aptible/cli/subcommands/logs_spec.rb
|
413
|
+
- spec/aptible/cli/subcommands/metric_drain_spec.rb
|
407
414
|
- spec/aptible/cli/subcommands/operation_spec.rb
|
408
415
|
- spec/aptible/cli/subcommands/rebuild_spec.rb
|
409
416
|
- spec/aptible/cli/subcommands/restart_spec.rb
|
@@ -419,6 +426,8 @@ test_files:
|
|
419
426
|
- spec/fabricators/database_disk_fabricator.rb
|
420
427
|
- spec/fabricators/database_fabricator.rb
|
421
428
|
- spec/fabricators/database_image_fabricator.rb
|
429
|
+
- spec/fabricators/log_drain_fabricator.rb
|
430
|
+
- spec/fabricators/metric_drain_fabricator.rb
|
422
431
|
- spec/fabricators/operation_fabricator.rb
|
423
432
|
- spec/fabricators/service_fabricator.rb
|
424
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
|