aptible-cli 0.17.0 → 0.18.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e273e3c062fe9d8e365d630b268ea9397e6ea31598595c6ba9729c1d1a288c6d
4
- data.tar.gz: 67607c3bcb1ce4c0c782403584f6037a6abe4f8af19544a531ea2ac286d8b1a8
3
+ metadata.gz: cf958faed8401636f811f03296e187e9af011fef3d6ce6aa3bc7f2aee315d5c8
4
+ data.tar.gz: 36214902974167a2748685d63fa9d1d659c64d4f752e3b813aeb7adb907f601b
5
5
  SHA512:
6
- metadata.gz: 8283372d5967ed47fac292aea6dd979ea9be800551ad5312b44b043589317c90f733b043e90088c880c763293230e78c8464eceba32c5dd901cfa5f2b1684e83
7
- data.tar.gz: 669627d3ec851644902b3b15e8531c8131977d0023b7304e87549cbc2ef986d7b1007c59477ec2ac147affacf2960409d04d70aef1da31ac9ab245db6467dedd
6
+ metadata.gz: a1a85e655dd7e0d3267035baca9c8c5898193f524a3ac842961ec62aa0e3b4f951c89a0a1dd5a1adcf80b840b729dafb90238214d6224eff1fd524a54fb90b21
7
+ data.tar.gz: d85e946cb9adee2314f31078029033bd62ea44a0ef23d673c434e422817c17cf7094bff714ce5b6862c52135f30b030ae7d52a4f72e8052f2fc99b372b3016ca
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] # Restart a database
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
@@ -72,7 +73,6 @@ Commands:
72
73
  aptible login # Log in to Aptible
73
74
  aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
74
75
  aptible operation:cancel OPERATION_ID # Cancel a running operation
75
- aptible ps # Display running processes for an app - DEPRECATED
76
76
  aptible rebuild # Rebuild an app, and restart its services
77
77
  aptible restart # Restart all services associated with an app
78
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'
@@ -25,7 +25,6 @@ require_relative 'subcommands/db'
25
25
  require_relative 'subcommands/domains'
26
26
  require_relative 'subcommands/environment'
27
27
  require_relative 'subcommands/logs'
28
- require_relative 'subcommands/ps'
29
28
  require_relative 'subcommands/rebuild'
30
29
  require_relative 'subcommands/deploy'
31
30
  require_relative 'subcommands/restart'
@@ -50,7 +49,6 @@ module Aptible
50
49
  include Subcommands::Domains
51
50
  include Subcommands::Environment
52
51
  include Subcommands::Logs
53
- include Subcommands::Ps
54
52
  include Subcommands::Rebuild
55
53
  include Subcommands::Deploy
56
54
  include Subcommands::Restart
@@ -43,6 +43,7 @@ module Aptible
43
43
  def inject_account(node, account)
44
44
  node.value('id', account.id)
45
45
  node.value('handle', account.handle)
46
+ node.value('created_at', account.created_at)
46
47
  end
47
48
 
48
49
  def inject_operation(node, operation)
@@ -56,6 +57,7 @@ module Aptible
56
57
  def inject_app(node, app, account)
57
58
  node.value('id', app.id)
58
59
  node.value('handle', app.handle)
60
+ node.value('created_at', app.created_at)
59
61
 
60
62
  node.value('status', app.status)
61
63
  node.value('git_remote', app.git_repo)
@@ -80,8 +82,10 @@ module Aptible
80
82
  def inject_database(node, database, account)
81
83
  node.value('id', database.id)
82
84
  node.value('handle', database.handle)
85
+ node.value('created_at', database.created_at)
83
86
 
84
87
  node.value('type', database.type)
88
+ node.value('version', database.database_image.version)
85
89
  node.value('status', database.status)
86
90
 
87
91
  node.value('connection_url', database.connection_url)
@@ -92,6 +96,20 @@ module Aptible
92
96
  end
93
97
  end
94
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.baseline_iops)
107
+ end
108
+
109
+ if database.service
110
+ node.value('container_size', \
111
+ database.service.container_memory_limit_mb)
112
+ end
95
113
  end
96
114
 
97
115
  def inject_credential(node, credential)
@@ -105,6 +123,7 @@ module Aptible
105
123
  def inject_service(node, service, app)
106
124
  node.value('id', service.id)
107
125
  node.value('service', service.process_type)
126
+ node.value('created_at', service.created_at)
108
127
 
109
128
  node.value('command', service.command || 'CMD')
110
129
  node.value('container_count', service.container_count)
@@ -117,6 +136,7 @@ module Aptible
117
136
  node.value('id', vhost.id)
118
137
  node.value('hostname', vhost.external_host)
119
138
  node.value('status', vhost.status)
139
+ node.value('created_at', vhost.created_at)
120
140
 
121
141
  case vhost.type
122
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
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.17.0'.freeze
3
+ VERSION = '0.18.2'.freeze
4
4
  end
5
5
  end
@@ -27,6 +27,7 @@ describe Aptible::CLI::ResourceFormatter do
27
27
  'Id: 12',
28
28
  'Hostname: foo.io',
29
29
  'Status: provisioned',
30
+ "Created At: #{fmt_time(service.created_at)}",
30
31
  'Type: https',
31
32
  'Port: default',
32
33
  'Internal: false',
@@ -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 } }
@@ -32,11 +32,13 @@ describe Aptible::CLI::Agent do
32
32
  expected_accounts = [
33
33
  {
34
34
  'handle' => 'foo',
35
- 'ca_body' => 'account 1 cert'
35
+ 'ca_body' => 'account 1 cert',
36
+ 'created_at' => fmt_time(a1.created_at)
36
37
  },
37
38
  {
38
39
  'handle' => 'bar',
39
- 'ca_body' => '--account 2 cert--'
40
+ 'ca_body' => '--account 2 cert--',
41
+ 'created_at' => fmt_time(a2.created_at)
40
42
  }
41
43
  ]
42
44
  expect(captured_output_json.map! { |account| account.except('id') })
@@ -26,4 +26,5 @@ Fabricator(:account, from: :stub_account) do
26
26
  apps { [] }
27
27
  databases { [] }
28
28
  certificates { [] }
29
+ created_at { Time.now }
29
30
  end
@@ -29,6 +29,7 @@ Fabricator(:app, from: :stub_app) do
29
29
  configurations { [] }
30
30
  current_configuration { nil }
31
31
  errors { Aptible::Resource::Errors.new }
32
+ created_at { Time.now }
32
33
 
33
34
  after_create { |app| app.account.apps << app }
34
35
  end
@@ -0,0 +1,8 @@
1
+ class StubDatabaseDisk < OpenStruct
2
+ end
3
+
4
+ Fabricator(:database_disk, from: :stub_database_disk) do
5
+ size 100
6
+ ebs_volume_type { 'gp2' }
7
+ baseline_iops '300'
8
+ 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
@@ -14,6 +14,7 @@ Fabricator(:service, from: :stub_service) do
14
14
  container_count { 1 }
15
15
  container_memory_limit_mb { 512 }
16
16
  vhosts { [] }
17
+ created_at { Time.now }
17
18
 
18
19
  after_create do |service, transients|
19
20
  if transients[:app]
@@ -7,6 +7,7 @@ Fabricator(:vhost, from: :stub_vhost) do
7
7
  virtual_domain { Fabricate.sequence(:virtual_domain) { |i| "domain#{i}" } }
8
8
  ip_whitelist { [] }
9
9
  container_ports { [] }
10
+ created_at { Time.now }
10
11
 
11
12
  after_create { |vhost| vhost.service.vhosts << vhost }
12
13
  end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,10 @@ end
11
11
  # Require library up front
12
12
  require 'aptible/cli'
13
13
 
14
+ def fmt_time(time)
15
+ time.strftime('%Y-%m-%d %H:%M:%S %z')
16
+ end
17
+
14
18
  class SpecRenderer < Aptible::CLI::Renderer::Base
15
19
  def initialize
16
20
  @nodes = []
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.17.0
4
+ version: 0.18.2
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-01-11 00:00:00.000000000 Z
11
+ date: 2021-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource
@@ -300,7 +300,6 @@ files:
300
300
  - lib/aptible/cli/subcommands/inspect.rb
301
301
  - lib/aptible/cli/subcommands/logs.rb
302
302
  - lib/aptible/cli/subcommands/operation.rb
303
- - lib/aptible/cli/subcommands/ps.rb
304
303
  - lib/aptible/cli/subcommands/rebuild.rb
305
304
  - lib/aptible/cli/subcommands/restart.rb
306
305
  - lib/aptible/cli/subcommands/services.rb
@@ -341,6 +340,7 @@ files:
341
340
  - spec/fabricators/certificate_fabricator.rb
342
341
  - spec/fabricators/configuration_fabricator.rb
343
342
  - spec/fabricators/database_credential_fabricator.rb
343
+ - spec/fabricators/database_disk_fabricator.rb
344
344
  - spec/fabricators/database_fabricator.rb
345
345
  - spec/fabricators/database_image_fabricator.rb
346
346
  - spec/fabricators/operation_fabricator.rb
@@ -376,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
376
376
  - !ruby/object:Gem::Version
377
377
  version: '0'
378
378
  requirements: []
379
- rubygems_version: 3.0.9
379
+ rubygems_version: 3.0.3
380
380
  signing_key:
381
381
  specification_version: 4
382
382
  summary: Command-line interface for Aptible services
@@ -415,6 +415,7 @@ test_files:
415
415
  - spec/fabricators/certificate_fabricator.rb
416
416
  - spec/fabricators/configuration_fabricator.rb
417
417
  - spec/fabricators/database_credential_fabricator.rb
418
+ - spec/fabricators/database_disk_fabricator.rb
418
419
  - spec/fabricators/database_fabricator.rb
419
420
  - spec/fabricators/database_image_fabricator.rb
420
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