aptible-cli 0.16.9 → 0.18.1
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/.gitignore +1 -1
- data/README.md +4 -2
- data/aptible-cli.gemspec +4 -0
- data/lib/aptible/cli/agent.rb +2 -2
- data/lib/aptible/cli/resource_formatter.rb +21 -0
- data/lib/aptible/cli/subcommands/db.rb +27 -2
- data/lib/aptible/cli/subcommands/environment.rb +49 -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 -4
- data/spec/aptible/cli/subcommands/db_spec.rb +72 -0
- data/spec/aptible/cli/subcommands/environment_spec.rb +56 -0
- data/spec/fabricators/account_fabricator.rb +2 -0
- data/spec/fabricators/app_fabricator.rb +1 -0
- data/spec/fabricators/database_disk_fabricator.rb +7 -0
- data/spec/fabricators/database_fabricator.rb +3 -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 +7 -3
- data/lib/aptible/cli/subcommands/ps.rb +0 -30
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17c44d3802245955af8e9e71f728cb1b78540440106df5b5510f98677276652a
|
|
4
|
+
data.tar.gz: 00ded45a48e4305d40bcb343242461c2c29738446a27f85479883ac1ca5e0052
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5f9683895ba7b8b2f2586eae6dc6dbb0b2472817bbb341609521ab7bdac72cff61719341d0545f2c0164f0f204a2041bdd2fad12029f86beae6d83482df5b386
|
|
7
|
+
data.tar.gz: 81152b5c0b39dc12136ea7bfbdcd17c3ce3cc463582fa2f37bc4000fd715b5801c3fe21edb7ca32031fdac319406f4c64664f96f5a35ad0f15b2e05255f98933
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -48,9 +48,10 @@ Commands:
|
|
|
48
48
|
aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
|
|
49
49
|
aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
|
|
50
50
|
aptible db:list # List all databases
|
|
51
|
+
aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]] # Modify a database disk
|
|
51
52
|
aptible db:reload HANDLE # Reload a database
|
|
52
53
|
aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--logical --version VERSION] [--key-arn KEY_ARN] # Create a replica/follower of a database
|
|
53
|
-
aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB]
|
|
54
|
+
aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB][--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
|
|
54
55
|
aptible db:tunnel HANDLE # Create a local tunnel to a database
|
|
55
56
|
aptible db:url HANDLE # Display a database URL
|
|
56
57
|
aptible db:versions # List available database versions
|
|
@@ -66,11 +67,12 @@ Commands:
|
|
|
66
67
|
aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
|
|
67
68
|
aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
|
|
68
69
|
aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
|
|
70
|
+
aptible environment:ca_cert # Retrieve the CA certificate associated with the environment
|
|
71
|
+
aptible environment:list # List all environments
|
|
69
72
|
aptible help [COMMAND] # Describe available commands or one specific command
|
|
70
73
|
aptible login # Log in to Aptible
|
|
71
74
|
aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
|
|
72
75
|
aptible operation:cancel OPERATION_ID # Cancel a running operation
|
|
73
|
-
aptible ps # Display running processes for an app - DEPRECATED
|
|
74
76
|
aptible rebuild # Rebuild an app, and restart its services
|
|
75
77
|
aptible restart # Restart all services associated with an app
|
|
76
78
|
aptible services # List Services for an App
|
data/aptible-cli.gemspec
CHANGED
|
@@ -28,7 +28,11 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.add_dependency 'git'
|
|
29
29
|
spec.add_dependency 'term-ansicolor'
|
|
30
30
|
spec.add_dependency 'chronic_duration', '~> 0.10.6'
|
|
31
|
+
|
|
32
|
+
# Temporarily pin ffi until https://github.com/ffi/ffi/issues/868 is fixed
|
|
33
|
+
spec.add_dependency 'ffi', '<= 1.14.1' if Gem.win_platform?
|
|
31
34
|
spec.add_dependency 'win32-process' if Gem.win_platform?
|
|
35
|
+
|
|
32
36
|
spec.add_dependency 'activesupport', '>= 4.0', '< 6.0'
|
|
33
37
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
|
34
38
|
spec.add_development_dependency 'aptible-tasks', '~> 0.5.8'
|
data/lib/aptible/cli/agent.rb
CHANGED
|
@@ -23,8 +23,8 @@ require_relative 'subcommands/apps'
|
|
|
23
23
|
require_relative 'subcommands/config'
|
|
24
24
|
require_relative 'subcommands/db'
|
|
25
25
|
require_relative 'subcommands/domains'
|
|
26
|
+
require_relative 'subcommands/environment'
|
|
26
27
|
require_relative 'subcommands/logs'
|
|
27
|
-
require_relative 'subcommands/ps'
|
|
28
28
|
require_relative 'subcommands/rebuild'
|
|
29
29
|
require_relative 'subcommands/deploy'
|
|
30
30
|
require_relative 'subcommands/restart'
|
|
@@ -47,8 +47,8 @@ module Aptible
|
|
|
47
47
|
include Subcommands::Config
|
|
48
48
|
include Subcommands::DB
|
|
49
49
|
include Subcommands::Domains
|
|
50
|
+
include Subcommands::Environment
|
|
50
51
|
include Subcommands::Logs
|
|
51
|
-
include Subcommands::Ps
|
|
52
52
|
include Subcommands::Rebuild
|
|
53
53
|
include Subcommands::Deploy
|
|
54
54
|
include Subcommands::Restart
|
|
@@ -23,6 +23,7 @@ module Aptible
|
|
|
23
23
|
node.value('created_at', backup.created_at)
|
|
24
24
|
node.value('region', backup.aws_region)
|
|
25
25
|
node.value('size', backup.size)
|
|
26
|
+
node.value('manual', backup.manual)
|
|
26
27
|
|
|
27
28
|
if backup.copied_from
|
|
28
29
|
node.keyed_object('copied_from', 'description') do |n|
|
|
@@ -42,6 +43,7 @@ module Aptible
|
|
|
42
43
|
def inject_account(node, account)
|
|
43
44
|
node.value('id', account.id)
|
|
44
45
|
node.value('handle', account.handle)
|
|
46
|
+
node.value('created_at', account.created_at)
|
|
45
47
|
end
|
|
46
48
|
|
|
47
49
|
def inject_operation(node, operation)
|
|
@@ -55,6 +57,7 @@ module Aptible
|
|
|
55
57
|
def inject_app(node, app, account)
|
|
56
58
|
node.value('id', app.id)
|
|
57
59
|
node.value('handle', app.handle)
|
|
60
|
+
node.value('created_at', app.created_at)
|
|
58
61
|
|
|
59
62
|
node.value('status', app.status)
|
|
60
63
|
node.value('git_remote', app.git_repo)
|
|
@@ -79,8 +82,10 @@ module Aptible
|
|
|
79
82
|
def inject_database(node, database, account)
|
|
80
83
|
node.value('id', database.id)
|
|
81
84
|
node.value('handle', database.handle)
|
|
85
|
+
node.value('created_at', database.created_at)
|
|
82
86
|
|
|
83
87
|
node.value('type', database.type)
|
|
88
|
+
node.value('version', database.database_image.version)
|
|
84
89
|
node.value('status', database.status)
|
|
85
90
|
|
|
86
91
|
node.value('connection_url', database.connection_url)
|
|
@@ -91,6 +96,20 @@ module Aptible
|
|
|
91
96
|
end
|
|
92
97
|
end
|
|
93
98
|
attach_account(node, account)
|
|
99
|
+
|
|
100
|
+
if database.disk
|
|
101
|
+
node.value('disk_type', database.disk.ebs_volume_type)
|
|
102
|
+
node.value('disk_size', database.disk.size)
|
|
103
|
+
node.value('disk_modification_progress',
|
|
104
|
+
database.disk.modification_progress)
|
|
105
|
+
node.value('disk_modification_status', database.disk.status)
|
|
106
|
+
node.value('disk_provisioned_iops', database.disk.provisioned_iops)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if database.service
|
|
110
|
+
node.value('container_size', \
|
|
111
|
+
database.service.container_memory_limit_mb)
|
|
112
|
+
end
|
|
94
113
|
end
|
|
95
114
|
|
|
96
115
|
def inject_credential(node, credential)
|
|
@@ -104,6 +123,7 @@ module Aptible
|
|
|
104
123
|
def inject_service(node, service, app)
|
|
105
124
|
node.value('id', service.id)
|
|
106
125
|
node.value('service', service.process_type)
|
|
126
|
+
node.value('created_at', service.created_at)
|
|
107
127
|
|
|
108
128
|
node.value('command', service.command || 'CMD')
|
|
109
129
|
node.value('container_count', service.container_count)
|
|
@@ -116,6 +136,7 @@ module Aptible
|
|
|
116
136
|
node.value('id', vhost.id)
|
|
117
137
|
node.value('hostname', vhost.external_host)
|
|
118
138
|
node.value('status', vhost.status)
|
|
139
|
+
node.value('created_at', vhost.created_at)
|
|
119
140
|
|
|
120
141
|
case vhost.type
|
|
121
142
|
when 'tcp', 'tls'
|
|
@@ -279,19 +279,24 @@ module Aptible
|
|
|
279
279
|
end
|
|
280
280
|
|
|
281
281
|
desc 'db:restart HANDLE ' \
|
|
282
|
-
'[--container-size SIZE_MB] [--disk-size SIZE_GB]'
|
|
282
|
+
'[--container-size SIZE_MB] [--disk-size SIZE_GB]' \
|
|
283
|
+
'[--iops IOPS] [--volume-type [gp2, gp3]]',
|
|
283
284
|
'Restart a database'
|
|
284
285
|
option :environment
|
|
285
286
|
option :container_size, type: :numeric
|
|
286
287
|
option :disk_size, type: :numeric
|
|
287
288
|
option :size, type: :numeric
|
|
289
|
+
option :iops, type: :numeric
|
|
290
|
+
option :volume_type
|
|
288
291
|
define_method 'db:restart' do |handle|
|
|
289
292
|
database = ensure_database(options.merge(db: handle))
|
|
290
293
|
|
|
291
294
|
opts = {
|
|
292
295
|
type: 'restart',
|
|
293
296
|
container_size: options[:container_size],
|
|
294
|
-
disk_size: options[:disk_size] || options[:size]
|
|
297
|
+
disk_size: options[:disk_size] || options[:size],
|
|
298
|
+
provisioned_iops: options[:iops],
|
|
299
|
+
ebs_volume_type: options[:volume_type]
|
|
295
300
|
}.delete_if { |_, v| v.nil? }
|
|
296
301
|
|
|
297
302
|
CLI.logger.warn([
|
|
@@ -305,6 +310,26 @@ module Aptible
|
|
|
305
310
|
attach_to_operation_logs(op)
|
|
306
311
|
end
|
|
307
312
|
|
|
313
|
+
desc 'db:modify HANDLE ' \
|
|
314
|
+
'[--iops IOPS] [--volume-type [gp2, gp3]]',
|
|
315
|
+
'Modify a database disk'
|
|
316
|
+
option :environment
|
|
317
|
+
option :iops, type: :numeric
|
|
318
|
+
option :volume_type
|
|
319
|
+
define_method 'db:modify' do |handle|
|
|
320
|
+
database = ensure_database(options.merge(db: handle))
|
|
321
|
+
|
|
322
|
+
opts = {
|
|
323
|
+
type: 'modify',
|
|
324
|
+
provisioned_iops: options[:iops],
|
|
325
|
+
ebs_volume_type: options[:volume_type]
|
|
326
|
+
}.delete_if { |_, v| v.nil? }
|
|
327
|
+
|
|
328
|
+
CLI.logger.info "Modifying #{database.handle}..."
|
|
329
|
+
op = database.create_operation!(opts)
|
|
330
|
+
attach_to_operation_logs(op)
|
|
331
|
+
end
|
|
332
|
+
|
|
308
333
|
desc 'db:url HANDLE', 'Display a database URL'
|
|
309
334
|
option :environment
|
|
310
335
|
option :type, type: :string
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Aptible
|
|
2
|
+
module CLI
|
|
3
|
+
module Subcommands
|
|
4
|
+
module Environment
|
|
5
|
+
def self.included(thor)
|
|
6
|
+
thor.class_eval do
|
|
7
|
+
include Helpers::Environment
|
|
8
|
+
include Helpers::Token
|
|
9
|
+
|
|
10
|
+
desc 'environment:list', 'List all environments'
|
|
11
|
+
option :environment
|
|
12
|
+
define_method 'environment:list' do
|
|
13
|
+
Formatter.render(Renderer.current) do |root|
|
|
14
|
+
root.keyed_list(
|
|
15
|
+
'handle'
|
|
16
|
+
) do |node|
|
|
17
|
+
scoped_environments(options).each do |account|
|
|
18
|
+
node.object do |n|
|
|
19
|
+
ResourceFormatter.inject_account(n, account)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc 'environment:ca_cert',
|
|
27
|
+
'Retrieve the CA certificate associated with the environment'
|
|
28
|
+
option :environment
|
|
29
|
+
define_method 'environment:ca_cert' do
|
|
30
|
+
Formatter.render(Renderer.current) do |root|
|
|
31
|
+
root.grouped_keyed_list(
|
|
32
|
+
'handle',
|
|
33
|
+
'ca_body'
|
|
34
|
+
) do |node|
|
|
35
|
+
scoped_environments(options).each do |account|
|
|
36
|
+
node.object do |n|
|
|
37
|
+
n.value('ca_body', account.ca_body)
|
|
38
|
+
ResourceFormatter.inject_account(n, account)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
data/lib/aptible/cli/version.rb
CHANGED
|
@@ -104,26 +104,30 @@ describe Aptible::CLI::Agent do
|
|
|
104
104
|
{
|
|
105
105
|
'environment' => {
|
|
106
106
|
'id' => account.id,
|
|
107
|
-
'handle' => account.handle
|
|
107
|
+
'handle' => account.handle,
|
|
108
|
+
'created_at' => fmt_time(account.created_at)
|
|
108
109
|
},
|
|
109
110
|
'handle' => app.handle,
|
|
110
111
|
'id' => app.id,
|
|
111
112
|
'status' => app.status,
|
|
112
113
|
'git_remote' => app.git_repo,
|
|
114
|
+
'created_at' => fmt_time(app.created_at),
|
|
113
115
|
'services' => [
|
|
114
116
|
{
|
|
115
117
|
'service' => s1.process_type,
|
|
116
118
|
'id' => s1.id,
|
|
117
119
|
'command' => s1.command,
|
|
118
120
|
'container_count' => s1.container_count,
|
|
119
|
-
'container_size' => s1.container_memory_limit_mb
|
|
121
|
+
'container_size' => s1.container_memory_limit_mb,
|
|
122
|
+
'created_at' => fmt_time(s1.created_at)
|
|
120
123
|
},
|
|
121
124
|
{
|
|
122
125
|
'service' => s2.process_type,
|
|
123
126
|
'id' => s2.id,
|
|
124
127
|
'command' => 'CMD',
|
|
125
128
|
'container_count' => s2.container_count,
|
|
126
|
-
'container_size' => s2.container_memory_limit_mb
|
|
129
|
+
'container_size' => s2.container_memory_limit_mb,
|
|
130
|
+
'created_at' => fmt_time(s2.created_at)
|
|
127
131
|
}
|
|
128
132
|
]
|
|
129
133
|
}
|
|
@@ -145,12 +149,14 @@ describe Aptible::CLI::Agent do
|
|
|
145
149
|
{
|
|
146
150
|
'environment' => {
|
|
147
151
|
'id' => account.id,
|
|
148
|
-
'handle' => account.handle
|
|
152
|
+
'handle' => account.handle,
|
|
153
|
+
'created_at' => fmt_time(account.created_at)
|
|
149
154
|
},
|
|
150
155
|
'handle' => app.handle,
|
|
151
156
|
'id' => app.id,
|
|
152
157
|
'status' => app.status,
|
|
153
158
|
'git_remote' => app.git_repo,
|
|
159
|
+
'created_at' => fmt_time(app.created_at),
|
|
154
160
|
'last_deploy_operation' =>
|
|
155
161
|
{
|
|
156
162
|
'id' => op.id,
|
|
@@ -389,6 +389,31 @@ describe Aptible::CLI::Agent do
|
|
|
389
389
|
expect(captured_logs).to match(/restarting foobar/i)
|
|
390
390
|
end
|
|
391
391
|
|
|
392
|
+
it 'allows restarting a database with provisioned iops' do
|
|
393
|
+
expect(database).to receive(:create_operation!)
|
|
394
|
+
.with(type: 'restart', provisioned_iops: 3001)
|
|
395
|
+
.and_return(op)
|
|
396
|
+
|
|
397
|
+
expect(subject).to receive(:attach_to_operation_logs).with(op)
|
|
398
|
+
|
|
399
|
+
subject.options = { iops: 3001 }
|
|
400
|
+
subject.send('db:restart', handle)
|
|
401
|
+
|
|
402
|
+
expect(captured_logs).to match(/restarting foobar/i)
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
it 'allows restarting a database with ebs volume type' do
|
|
406
|
+
expect(database).to receive(:create_operation!)
|
|
407
|
+
.with(type: 'restart', ebs_volume_type: 'gp2').and_return(op)
|
|
408
|
+
|
|
409
|
+
expect(subject).to receive(:attach_to_operation_logs).with(op)
|
|
410
|
+
|
|
411
|
+
subject.options = { volume_type: 'gp2' }
|
|
412
|
+
subject.send('db:restart', handle)
|
|
413
|
+
|
|
414
|
+
expect(captured_logs).to match(/restarting foobar/i)
|
|
415
|
+
end
|
|
416
|
+
|
|
392
417
|
it 'allows restarting a database with (implicitly disk) size' do
|
|
393
418
|
expect(database).to receive(:create_operation!)
|
|
394
419
|
.with(type: 'restart', disk_size: 40).and_return(op)
|
|
@@ -419,6 +444,53 @@ describe Aptible::CLI::Agent do
|
|
|
419
444
|
end
|
|
420
445
|
end
|
|
421
446
|
|
|
447
|
+
describe '#db:modify' do
|
|
448
|
+
before { allow(Aptible::Api::Account).to receive(:all) { [account] } }
|
|
449
|
+
before { allow(Aptible::Api::Database).to receive(:all) { [database] } }
|
|
450
|
+
|
|
451
|
+
let(:op) { Fabricate(:operation) }
|
|
452
|
+
|
|
453
|
+
it 'allows modifying a database' do
|
|
454
|
+
expect(database).to receive(:create_operation!)
|
|
455
|
+
.with(type: 'modify').and_return(op)
|
|
456
|
+
|
|
457
|
+
expect(subject).to receive(:attach_to_operation_logs).with(op)
|
|
458
|
+
|
|
459
|
+
subject.send('db:modify', handle)
|
|
460
|
+
|
|
461
|
+
expect(captured_logs).to match(/modifying foobar/i)
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
it 'allows modifying a database with provisioned iops' do
|
|
465
|
+
expect(database).to receive(:create_operation!)
|
|
466
|
+
.with(type: 'modify', provisioned_iops: 3001).and_return(op)
|
|
467
|
+
|
|
468
|
+
expect(subject).to receive(:attach_to_operation_logs).with(op)
|
|
469
|
+
|
|
470
|
+
subject.options = { iops: 3001 }
|
|
471
|
+
subject.send('db:modify', handle)
|
|
472
|
+
|
|
473
|
+
expect(captured_logs).to match(/modifying foobar/i)
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
it 'allows modifying a database with ebs volume type' do
|
|
477
|
+
expect(database).to receive(:create_operation!)
|
|
478
|
+
.with(type: 'modify', ebs_volume_type: 'gp2').and_return(op)
|
|
479
|
+
|
|
480
|
+
expect(subject).to receive(:attach_to_operation_logs).with(op)
|
|
481
|
+
|
|
482
|
+
subject.options = { volume_type: 'gp2' }
|
|
483
|
+
subject.send('db:modify', handle)
|
|
484
|
+
|
|
485
|
+
expect(captured_logs).to match(/modifying foobar/i)
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
it 'fails if the DB is not found' do
|
|
489
|
+
expect { subject.send('db:modify', 'nope') }
|
|
490
|
+
.to raise_error(Thor::Error, 'Could not find database nope')
|
|
491
|
+
end
|
|
492
|
+
end
|
|
493
|
+
|
|
422
494
|
describe '#db:url' do
|
|
423
495
|
let(:databases) { [database] }
|
|
424
496
|
before { expect(Aptible::Api::Database).to receive(:all) { databases } }
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Aptible::CLI::Agent do
|
|
4
|
+
let!(:a1) do
|
|
5
|
+
Fabricate(:account, handle: 'foo', ca_body: 'account 1 cert')
|
|
6
|
+
end
|
|
7
|
+
let!(:a2) do
|
|
8
|
+
Fabricate(:account, handle: 'bar', ca_body: '--account 2 cert--')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
let(:token) { double 'token' }
|
|
12
|
+
|
|
13
|
+
before do
|
|
14
|
+
allow(subject).to receive(:fetch_token) { token }
|
|
15
|
+
allow(Aptible::Api::Account).to receive(:all).with(token: token)
|
|
16
|
+
.and_return([a1, a2])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'lists avaliable environments' do
|
|
20
|
+
subject.send('environment:list')
|
|
21
|
+
|
|
22
|
+
expect(captured_output_text.split("\n")).to include('foo')
|
|
23
|
+
expect(captured_output_text.split("\n")).to include('bar')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'fetches certs for all avaliable environments' do
|
|
27
|
+
subject.send('environment:ca_cert')
|
|
28
|
+
|
|
29
|
+
expect(captured_output_text.split("\n")).to include('account 1 cert')
|
|
30
|
+
expect(captured_output_text.split("\n")).to include('--account 2 cert--')
|
|
31
|
+
|
|
32
|
+
expected_accounts = [
|
|
33
|
+
{
|
|
34
|
+
'handle' => 'foo',
|
|
35
|
+
'ca_body' => 'account 1 cert',
|
|
36
|
+
'created_at' => fmt_time(a1.created_at)
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
'handle' => 'bar',
|
|
40
|
+
'ca_body' => '--account 2 cert--',
|
|
41
|
+
'created_at' => fmt_time(a2.created_at)
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
expect(captured_output_json.map! { |account| account.except('id') })
|
|
45
|
+
.to eq(expected_accounts)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'fetches certs for specified environment' do
|
|
49
|
+
subject.options = { environment: 'foo' }
|
|
50
|
+
subject.send('environment:ca_cert')
|
|
51
|
+
|
|
52
|
+
expect(captured_output_text.split("\n")).to include('account 1 cert')
|
|
53
|
+
expect(captured_output_text.split("\n"))
|
|
54
|
+
.to_not include('--account 2 cert--')
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -20,9 +20,11 @@ Fabricator(:account, from: :stub_account) do
|
|
|
20
20
|
bastion_host 'localhost'
|
|
21
21
|
dumptruck_port 1234
|
|
22
22
|
handle 'aptible'
|
|
23
|
+
ca_body '--BEGIN FAKE CERT-- test --END FAKE CERT--'
|
|
23
24
|
stack
|
|
24
25
|
|
|
25
26
|
apps { [] }
|
|
26
27
|
databases { [] }
|
|
27
28
|
certificates { [] }
|
|
29
|
+
created_at { Time.now }
|
|
28
30
|
end
|
|
@@ -16,10 +16,13 @@ Fabricator(:database, from: :stub_database) do
|
|
|
16
16
|
status 'provisioned'
|
|
17
17
|
connection_url 'postgresql://aptible:password@10.252.1.125:49158/db'
|
|
18
18
|
account
|
|
19
|
+
database_image
|
|
20
|
+
disk { Fabricate(:database_disk) }
|
|
19
21
|
service { nil }
|
|
20
22
|
|
|
21
23
|
backups { [] }
|
|
22
24
|
database_credentials { [] }
|
|
25
|
+
created_at { Time.now }
|
|
23
26
|
|
|
24
27
|
after_create do |database, transients|
|
|
25
28
|
database.account.databases << database
|
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.18.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Frank Macreery
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aptible-resource
|
|
@@ -296,10 +296,10 @@ files:
|
|
|
296
296
|
- lib/aptible/cli/subcommands/deploy.rb
|
|
297
297
|
- lib/aptible/cli/subcommands/domains.rb
|
|
298
298
|
- lib/aptible/cli/subcommands/endpoints.rb
|
|
299
|
+
- lib/aptible/cli/subcommands/environment.rb
|
|
299
300
|
- lib/aptible/cli/subcommands/inspect.rb
|
|
300
301
|
- lib/aptible/cli/subcommands/logs.rb
|
|
301
302
|
- lib/aptible/cli/subcommands/operation.rb
|
|
302
|
-
- lib/aptible/cli/subcommands/ps.rb
|
|
303
303
|
- lib/aptible/cli/subcommands/rebuild.rb
|
|
304
304
|
- lib/aptible/cli/subcommands/restart.rb
|
|
305
305
|
- lib/aptible/cli/subcommands/services.rb
|
|
@@ -325,6 +325,7 @@ files:
|
|
|
325
325
|
- spec/aptible/cli/subcommands/deploy_spec.rb
|
|
326
326
|
- spec/aptible/cli/subcommands/domains_spec.rb
|
|
327
327
|
- spec/aptible/cli/subcommands/endpoints_spec.rb
|
|
328
|
+
- spec/aptible/cli/subcommands/environment_spec.rb
|
|
328
329
|
- spec/aptible/cli/subcommands/inspect_spec.rb
|
|
329
330
|
- spec/aptible/cli/subcommands/logs_spec.rb
|
|
330
331
|
- spec/aptible/cli/subcommands/operation_spec.rb
|
|
@@ -339,6 +340,7 @@ files:
|
|
|
339
340
|
- spec/fabricators/certificate_fabricator.rb
|
|
340
341
|
- spec/fabricators/configuration_fabricator.rb
|
|
341
342
|
- spec/fabricators/database_credential_fabricator.rb
|
|
343
|
+
- spec/fabricators/database_disk_fabricator.rb
|
|
342
344
|
- spec/fabricators/database_fabricator.rb
|
|
343
345
|
- spec/fabricators/database_image_fabricator.rb
|
|
344
346
|
- spec/fabricators/operation_fabricator.rb
|
|
@@ -398,6 +400,7 @@ test_files:
|
|
|
398
400
|
- spec/aptible/cli/subcommands/deploy_spec.rb
|
|
399
401
|
- spec/aptible/cli/subcommands/domains_spec.rb
|
|
400
402
|
- spec/aptible/cli/subcommands/endpoints_spec.rb
|
|
403
|
+
- spec/aptible/cli/subcommands/environment_spec.rb
|
|
401
404
|
- spec/aptible/cli/subcommands/inspect_spec.rb
|
|
402
405
|
- spec/aptible/cli/subcommands/logs_spec.rb
|
|
403
406
|
- spec/aptible/cli/subcommands/operation_spec.rb
|
|
@@ -412,6 +415,7 @@ test_files:
|
|
|
412
415
|
- spec/fabricators/certificate_fabricator.rb
|
|
413
416
|
- spec/fabricators/configuration_fabricator.rb
|
|
414
417
|
- spec/fabricators/database_credential_fabricator.rb
|
|
418
|
+
- spec/fabricators/database_disk_fabricator.rb
|
|
415
419
|
- spec/fabricators/database_fabricator.rb
|
|
416
420
|
- spec/fabricators/database_image_fabricator.rb
|
|
417
421
|
- spec/fabricators/operation_fabricator.rb
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require 'shellwords'
|
|
2
|
-
|
|
3
|
-
module Aptible
|
|
4
|
-
module CLI
|
|
5
|
-
module Subcommands
|
|
6
|
-
module Ps
|
|
7
|
-
def self.included(thor)
|
|
8
|
-
thor.class_eval do
|
|
9
|
-
include Helpers::Operation
|
|
10
|
-
include Helpers::App
|
|
11
|
-
|
|
12
|
-
desc 'ps', 'Display running processes for an app - DEPRECATED'
|
|
13
|
-
app_options
|
|
14
|
-
def ps
|
|
15
|
-
deprecated('This command is deprecated on Aptible v2 stacks.')
|
|
16
|
-
|
|
17
|
-
app = ensure_app(options)
|
|
18
|
-
|
|
19
|
-
op = app.create_operation!(type: 'ps', status: 'succeeded')
|
|
20
|
-
|
|
21
|
-
ENV['ACCESS_TOKEN'] = fetch_token
|
|
22
|
-
opts = ['-o', 'SendEnv=ACCESS_TOKEN']
|
|
23
|
-
exit_with_ssh_portal(op, *opts)
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|