aptible-cli 0.17.2 → 0.18.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec0eedcd128407794469d7da0f0b89edcbc60b659118cab8a278166440d00e9b
4
- data.tar.gz: ed5663f602a43c54b6a13930a9f271face5c30e65c6d70d4c48eb633abb7ba63
3
+ metadata.gz: 9ffdd3315dbbee4f94b8b02bb6c6695829c511cf950448997b603cce77253d20
4
+ data.tar.gz: ac9983ee76d69580194e58d1f1acd6927f4addcbe2dbaec132ae133aa13d215a
5
5
  SHA512:
6
- metadata.gz: a77a1f7c55957bd2f08e00ee3cd98d7d29c2058e989b152c7939be33b7e385c0a75dc95db6682948477f4c400654a5a1aa629476f12ff94c5b17e17103cb18e2
7
- data.tar.gz: a9fdc5310c266fe98565ff1c2aa363a16d3b58f6943f1d5fac7184717ac9c4f0d62229b7ad651cfc71d03849d1eb3d80d72ae2fafa14b4beaacb168426cf1156
6
+ metadata.gz: d4721d191f0f6c35f6f75717b1896a5ca44441e3d912cb9af23bcde319f9f7678881a7eaf14de89e3222834c139d8c8c7bbe3eb9239d980ec55d32b47acbd835
7
+ data.tar.gz: 2ced7b764b4b1b0db0ed460a0afd3f14836054a15ec32d5681af077a6811743fddff655c3d27121abc6858729116d385eff2da2d0c807cbbcef3abf92b2b0183
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
@@ -97,6 +97,10 @@ module Aptible
97
97
  if database.disk
98
98
  node.value('disk_type', database.disk.ebs_volume_type)
99
99
  node.value('disk_size', database.disk.size)
100
+ node.value('disk_modification_progress',
101
+ database.disk.modification_progress)
102
+ node.value('disk_modification_status', database.disk.status)
103
+ node.value('disk_provisioned_iops', database.disk.provisioned_iops)
100
104
  end
101
105
 
102
106
  if database.service
@@ -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.2'.freeze
3
+ VERSION = '0.18.0'.freeze
4
4
  end
5
5
  end
@@ -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 } }
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.2
4
+ version: 0.18.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-03-17 00:00:00.000000000 Z
11
+ date: 2021-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource