aptible-cli 0.20.0 → 0.21.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: 985fa3322948f2656c41b9b6e7ed378625424554dcf26d1db461386586f488a9
4
- data.tar.gz: 71150a291daf6e6a054979d6308e9a919654679b88b9581d51959c3100cf9a07
3
+ metadata.gz: b212760948b9bef6355281c713ae9077b7e424e21f5cdf4c5c88f60deb13b38d
4
+ data.tar.gz: 5dbf4dab98017d0a0c2a6201b4c7715cda3f46cbb481d64ba9ce7b5bf1fad2fc
5
5
  SHA512:
6
- metadata.gz: 3551dbb8cff5d22404f022652c70dadf2407f46f11443c84b36eeaa9ba1ec2cb13260d3fd613402c24532e366daf25d9516e19c05a3017f605d5fb8d8a5d5059
7
- data.tar.gz: 7ef21a787bbb1c81587fd3ad4ef4adee351a10de48d9b80299d8f7f83912a67d1a54c835c856be2b79d93783c6c45e7211d6abb7f5eb7531f80bc834eadbfcf1
6
+ metadata.gz: 42335afa7c7bc447a120cbfcd7244ce326476d001922cb8eafcecd3c278a65859cb06d61234fc8607ab4cf9b7d31bf15dd60348ca2bc7af926e62def427386fa
7
+ data.tar.gz: 3e3dbe977c93e72a6cb621e3d6d529812ce9a2725ca6a309efce5f524acf93922259bb7814cd4958b63a168ce03e8184249e0fe8af061d3710e5fdb023e48299
data/Gemfile.lock CHANGED
@@ -11,7 +11,7 @@ GIT
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- aptible-cli (0.20.0)
14
+ aptible-cli (0.21.0)
15
15
  activesupport (>= 4.0, < 6.0)
16
16
  aptible-api (~> 1.5.3)
17
17
  aptible-auth (~> 1.2.4)
data/README.md CHANGED
@@ -30,13 +30,13 @@ Commands:
30
30
  aptible apps:create HANDLE # Create a new application
31
31
  aptible apps:deprovision # Deprovision an app
32
32
  aptible apps:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename an app handle. In order for the new app handle to appear in log drain and metric drain destinations, you must restart the app.
33
- aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] # Scale a service
33
+ aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] [--container-profile PROFILE] # Scale a service
34
34
  aptible backup:list DB_HANDLE # List backups for a database
35
35
  aptible backup:orphaned # List backups associated with deprovisioned databases
36
36
  aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
37
- aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--key-arn KEY_ARN] # Restore a backup
37
+ aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Restore a backup
38
38
  aptible backup_retention_policy [ENVIRONMENT_HANDLE] # Show the current backup retention policy for the environment
39
- aptible backup_retention_policy:set [ENVIRONMENT_HANDLE] [--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] [--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] [--keep-final|--no-keep-final] # Change the environemnt's backup retention policy
39
+ aptible backup_retention_policy:set [ENVIRONMENT_HANDLE] [--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] [--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] [--keep-final|--no-keep-final] [--force] # Change the environment's backup retention policy
40
40
  aptible config # Print an app's current configuration
41
41
  aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
42
42
  aptible config:get [VAR1] # Print a specific key within an app's current configuration
@@ -45,7 +45,7 @@ Commands:
45
45
  aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
46
46
  aptible db:backup HANDLE # Backup a database
47
47
  aptible db:clone SOURCE DEST # Clone a database to create a new one
48
- aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--key-arn KEY_ARN] # Create a new database
48
+ aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--key-arn KEY_ARN] # Create a new database
49
49
  aptible db:deprovision HANDLE # Deprovision a database
50
50
  aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
51
51
  aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
@@ -53,8 +53,8 @@ Commands:
53
53
  aptible db:modify HANDLE [--iops IOPS] [--volume-type [gp2, gp3]] # Modify a database disk
54
54
  aptible db:reload HANDLE # Reload a database
55
55
  aptible db:rename OLD_HANDLE NEW_HANDLE [--environment ENVIRONMENT_HANDLE] # Rename a database handle. In order for the new database handle to appear in log drain and metric drain destinations, you must reload the database.
56
- 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
57
- aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
56
+ aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--logical --version VERSION] [--key-arn KEY_ARN] # Create a replica/follower of a database
57
+ aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--container-profile PROFILE] [--iops IOPS] [--volume-type [gp2, gp3]] # Restart a database
58
58
  aptible db:tunnel HANDLE # Create a local tunnel to a database
59
59
  aptible db:url HANDLE # Display a database URL
60
60
  aptible db:versions # List available database versions
@@ -52,7 +52,9 @@ module Aptible
52
52
  handle: dest_handle,
53
53
  container_size: options[:container_size],
54
54
  disk_size: options[:size],
55
- key_arn: options[:key_arn]
55
+ key_arn: options[:key_arn],
56
+ instance_profile: options[:instance_profile],
57
+ provisioned_iops: options[:provisioned_iops]
56
58
  }.reject { |_, v| v.nil? }
57
59
 
58
60
  if options[:logical]
@@ -47,16 +47,20 @@ module Aptible
47
47
  end
48
48
 
49
49
  desc 'apps:scale SERVICE ' \
50
- '[--container-count COUNT] [--container-size SIZE_MB]',
50
+ '[--container-count COUNT] [--container-size SIZE_MB] ' \
51
+ '[--container-profile PROFILE]',
51
52
  'Scale a service'
52
53
  app_options
53
54
  option :container_count, type: :numeric
54
55
  option :container_size, type: :numeric
56
+ option :container_profile, type: :string,
57
+ desc: 'Examples: m c r'
55
58
  define_method 'apps:scale' do |type|
56
59
  service = ensure_service(options, type)
57
60
 
58
61
  container_count = options[:container_count]
59
62
  container_size = options[:container_size]
63
+ container_profile = options[:container_profile]
60
64
 
61
65
  if options[:size]
62
66
  m = 'You have used the "--size" option to specify a container '\
@@ -74,6 +78,7 @@ module Aptible
74
78
  opts = { type: 'scale' }
75
79
  opts[:container_count] = container_count if container_count
76
80
  opts[:container_size] = container_size if container_size
81
+ opts[:instance_profile] = container_profile if container_profile
77
82
 
78
83
  op = service.create_operation!(opts)
79
84
  attach_to_operation_logs(op)
@@ -10,6 +10,7 @@ module Aptible
10
10
  desc 'backup:restore BACKUP_ID ' \
11
11
  '[--environment ENVIRONMENT_HANDLE] [--handle HANDLE] ' \
12
12
  '[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
13
+ '[--container-profile PROFILE] [--iops IOPS] ' \
13
14
  '[--key-arn KEY_ARN]',
14
15
  'Restore a backup'
15
16
  option :handle, desc: 'a name to use for the new database'
@@ -18,6 +19,9 @@ module Aptible
18
19
  option :size, type: :numeric
19
20
  option :disk_size, type: :numeric
20
21
  option :key_arn, type: :string
22
+ option :container_profile, type: :string,
23
+ desc: 'Examples: m c r'
24
+ option :iops, type: :numeric
21
25
  define_method 'backup:restore' do |backup_id|
22
26
  backup = Aptible::Api::Backup.find(backup_id, token: fetch_token)
23
27
  raise Thor::Error, "Backup ##{backup_id} not found" if backup.nil?
@@ -41,7 +45,9 @@ module Aptible
41
45
  container_size: options[:container_size],
42
46
  disk_size: options[:disk_size],
43
47
  destination_account: destination_account,
44
- key_arn: options[:key_arn]
48
+ key_arn: options[:key_arn],
49
+ instance_profile: options[:container_profile],
50
+ provisioned_iops: options[:iops]
45
51
  }.delete_if { |_, v| v.nil? }
46
52
 
47
53
  if options[:size]
@@ -33,8 +33,8 @@ module Aptible
33
33
  desc 'backup_retention_policy:set [ENVIRONMENT_HANDLE] ' \
34
34
  '[--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] ' \
35
35
  '[--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] ' \
36
- '[--keep-final|--no-keep-final]',
37
- "Change the environemnt's backup retention policy"
36
+ '[--keep-final|--no-keep-final] [--force]',
37
+ "Change the environment's backup retention policy"
38
38
  option :daily, type: :numeric,
39
39
  desc: 'Number of daily backups to retain'
40
40
  option :monthly, type: :numeric,
@@ -43,12 +43,14 @@ module Aptible
43
43
  desc: 'Number of yearly backups to retain'
44
44
  option :make_copy, type: :boolean,
45
45
  desc: 'If backup copies should be created'
46
- option(
47
- :keep_final,
48
- type: :boolean,
49
- desc: 'If final backups should be kept when databases are ' \
50
- 'deprovisioned'
51
- )
46
+ option :keep_final,
47
+ type: :boolean,
48
+ desc: 'If final backups should be kept when databases are ' \
49
+ 'deprovisioned'
50
+ option :force,
51
+ type: :boolean,
52
+ desc: 'Do not prompt for confirmation if the new policy ' \
53
+ 'retains fewer backups than the current policy'
52
54
  define_method 'backup_retention_policy:set' do |env|
53
55
  if options.empty?
54
56
  raise Thor::Error,
@@ -69,11 +71,42 @@ module Aptible
69
71
  # If any of the attribues are missing, raise an error so that
70
72
  # we're not relying on the server's defaults
71
73
  if attrs.values.any?(&:nil?)
72
- raise Thor::Error, "Environemnt #{env} does not have a " \
74
+ raise Thor::Error, "Environment #{env} does not have a " \
73
75
  'custom backup retention policy. Please ' \
74
76
  'specify all attributes to create one.'
75
77
  end
76
78
 
79
+ # Check if the number of backups over any period have been reduced
80
+ do_confirm = %i(daily monthly yearly).any? do |a|
81
+ cur = current_policy.try(a)
82
+ next if cur.nil?
83
+ cur > attrs[a]
84
+ end
85
+
86
+ # Check if any of the boolean fields have been disabled
87
+ do_confirm ||= %i(make_copy keep_final).any? do |a|
88
+ cur = current_policy.try(a)
89
+ next if cur.nil?
90
+ cur && !attrs[a]
91
+ end
92
+
93
+ if do_confirm && !options[:force]
94
+ m = 'The specified backup retention policy retains fewer ' \
95
+ "backups than the environment's current policy. This may " \
96
+ 'result in the deletion of existing, automated backups ' \
97
+ "if they exceed the new policy's rules and it may " \
98
+ "violate your company's internal compliance controls. " \
99
+ 'For more information, see https://www.aptible.com/docs' \
100
+ '/core-concepts/managed-databases/managing-databases' \
101
+ '/database-backups.'
102
+
103
+ m = set_color(m, :yellow)
104
+ print_wrapped m
105
+ confirmation = yes?('Do you want to proceed [y/N]:')
106
+ puts ''
107
+ raise Thor::Error, 'Aborting' unless confirmation
108
+ end
109
+
77
110
  new_policy = account.create_backup_retention_policy!(**attrs)
78
111
 
79
112
  Formatter.render(Renderer.current) do |root|
@@ -54,6 +54,7 @@ module Aptible
54
54
  desc 'db:create HANDLE ' \
55
55
  '[--type TYPE] [--version VERSION] ' \
56
56
  '[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
57
+ '[--container-profile PROFILE] [--iops IOPS] ' \
57
58
  '[--key-arn KEY_ARN]',
58
59
  'Create a new database'
59
60
  option :type, type: :string
@@ -63,6 +64,9 @@ module Aptible
63
64
  option :size, type: :numeric
64
65
  option :key_arn, type: :string
65
66
  option :environment
67
+ option :container_profile, type: :string,
68
+ desc: 'Examples: m c r'
69
+ option :iops, type: :numeric
66
70
  define_method 'db:create' do |handle|
67
71
  account = ensure_environment(options)
68
72
 
@@ -100,8 +104,11 @@ module Aptible
100
104
  op_opts = {
101
105
  type: 'provision',
102
106
  container_size: options[:container_size],
103
- disk_size: options[:disk_size]
107
+ disk_size: options[:disk_size],
108
+ instance_profile: options[:container_profile],
109
+ provisioned_iops: options[:iops]
104
110
  }.delete_if { |_, v| v.nil? }
111
+
105
112
  op = database.create_operation(op_opts)
106
113
 
107
114
  if op.errors.any?
@@ -129,6 +136,7 @@ module Aptible
129
136
 
130
137
  desc 'db:replicate HANDLE REPLICA_HANDLE ' \
131
138
  '[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
139
+ '[--container-profile PROFILE] [--iops IOPS] ' \
132
140
  '[--logical --version VERSION] [--key-arn KEY_ARN]',
133
141
  'Create a replica/follower of a database'
134
142
  option :environment
@@ -138,6 +146,9 @@ module Aptible
138
146
  option :logical, type: :boolean
139
147
  option :version, type: :string
140
148
  option :key_arn, type: :string
149
+ option :container_profile, type: :string,
150
+ desc: 'Examples: m c r'
151
+ option :iops, type: :numeric
141
152
  define_method 'db:replicate' do |source_handle, dest_handle|
142
153
  source = ensure_database(options.merge(db: source_handle))
143
154
 
@@ -162,7 +173,9 @@ module Aptible
162
173
  size: options[:disk_size],
163
174
  logical: options[:logical],
164
175
  database_image: image || nil,
165
- key_arn: options[:key_arn]
176
+ key_arn: options[:key_arn],
177
+ instance_profile: options[:container_profile],
178
+ provisioned_iops: options[:iops]
166
179
  }.delete_if { |_, v| v.nil? }
167
180
 
168
181
  if options[:size]
@@ -284,10 +297,13 @@ module Aptible
284
297
 
285
298
  desc 'db:restart HANDLE ' \
286
299
  '[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
287
- '[--iops IOPS] [--volume-type [gp2, gp3]]',
300
+ '[--container-profile PROFILE] [--iops IOPS] ' \
301
+ '[--volume-type [gp2, gp3]]',
288
302
  'Restart a database'
289
303
  option :environment
290
304
  option :container_size, type: :numeric
305
+ option :container_profile, type: :string,
306
+ desc: 'Examples: m c r'
291
307
  option :disk_size, type: :numeric
292
308
  option :size, type: :numeric
293
309
  option :iops, type: :numeric
@@ -300,7 +316,8 @@ module Aptible
300
316
  container_size: options[:container_size],
301
317
  disk_size: options[:disk_size],
302
318
  provisioned_iops: options[:iops],
303
- ebs_volume_type: options[:volume_type]
319
+ ebs_volume_type: options[:volume_type],
320
+ instance_profile: options[:container_profile]
304
321
  }.delete_if { |_, v| v.nil? }
305
322
 
306
323
  if options[:size]
@@ -327,7 +344,8 @@ module Aptible
327
344
  opts = {
328
345
  type: 'modify',
329
346
  provisioned_iops: options[:iops],
330
- ebs_volume_type: options[:volume_type]
347
+ ebs_volume_type: options[:volume_type],
348
+ instance_profile: options[:container_profile]
331
349
  }.delete_if { |_, v| v.nil? }
332
350
 
333
351
  CLI.logger.info "Modifying #{database.handle}..."
@@ -29,6 +29,16 @@ module Aptible
29
29
  desc: 'Detach this app from its git repository: ' \
30
30
  'its Procfile, Dockerfile, and .aptible.yml will be ' \
31
31
  'ignored until you deploy again with git'
32
+ option :container_count, type: :numeric,
33
+ desc: 'This option only affects new ' \
34
+ 'services, not existing ones.'
35
+ option :container_size, type: :numeric,
36
+ desc: 'This option only affects new ' \
37
+ 'services, not existing ones.'
38
+ option :container_profile, type: :string,
39
+ desc: 'This option only affects new ' \
40
+ 'services, not existing ones. ' \
41
+ 'Examples: m c r'
32
42
  DOCKER_IMAGE_DEPLOY_ARGS.each_pair do |opt, var|
33
43
  option opt,
34
44
  type: :string, banner: var,
@@ -63,8 +73,11 @@ module Aptible
63
73
  opts = {
64
74
  type: 'deploy',
65
75
  env: env,
66
- git_ref: git_ref
67
- }.delete_if { |_, v| v.nil? || v.empty? }
76
+ git_ref: git_ref,
77
+ container_count: options[:container_count],
78
+ container_size: options[:container_size],
79
+ instance_profile: options[:container_profile]
80
+ }.delete_if { |_, v| v.nil? || v.try(:empty?) }
68
81
 
69
82
  allow_it = [
70
83
  opts[:git_ref],
@@ -175,7 +175,7 @@ module Aptible
175
175
 
176
176
  WARNING: review the documentation on rate limits before using
177
177
  this command automatically
178
- (http://go.aptible.com/managed-tls-rate-limits).
178
+ (https://www.aptible.com/docs/core-concepts/apps/connecting-to-apps/app-endpoints/managed-tls#rate-limits).
179
179
  LONGDESC
180
180
  app_options
181
181
  define_method 'endpoints:renew' do |hostname|
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.20.0'.freeze
3
+ VERSION = '0.21.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,115 @@
1
+ require 'spec_helper'
2
+
3
+ describe Aptible::CLI::Agent do
4
+ let(:token) { 'some-token' }
5
+ let(:account) { Fabricate(:account, handle: 'test') }
6
+ let(:database) { Fabricate(:database, account: account, handle: 'some-db') }
7
+ let!(:policy) do
8
+ # created_at: 2016-06-14 13:24:11 +0000
9
+ Fabricate(:backup_retention_policy, account: account)
10
+ end
11
+
12
+ let(:default_handle) { 'some-db-at-2016-06-14-13-24-11' }
13
+
14
+ before do
15
+ allow(subject).to receive(:fetch_token).and_return(token)
16
+ allow(Aptible::Api::Account).to receive(:all) { [account] }
17
+ end
18
+
19
+ describe '#backup_retention_policy' do
20
+ it 'raises an error if the environment has no policy' do
21
+ allow(account).to receive(:backup_retention_policies).and_return([])
22
+ expect { subject.backup_retention_policy('test') }
23
+ .to raise_error(/does not have a custom backup retention policy/)
24
+ end
25
+
26
+ it "prints the enviroment's current policy" do
27
+ subject.backup_retention_policy('test')
28
+ out = captured_output_text
29
+ expect(out).to match(/daily: 30/i)
30
+ expect(out).to match(/monthly: 12/i)
31
+ expect(out).to match(/yearly: 6/i)
32
+ expect(out).to match(/make copy: true/i)
33
+ expect(out).to match(/keep final: true/i)
34
+ expect(out).to match(/environment: test/i)
35
+ end
36
+ end
37
+
38
+ describe '#backup_retention_policy:set' do
39
+ it 'requires all attributes if the environment has no policy' do
40
+ allow(account).to receive(:backup_retention_policies).and_return([])
41
+ opts = {
42
+ daily: 3,
43
+ monthly: 2,
44
+ yearly: 1,
45
+ make_copy: false,
46
+ keep_final: true
47
+ }
48
+
49
+ opts.each_key do |k|
50
+ missing_opts = opts.clone
51
+ missing_opts.delete(k)
52
+
53
+ subject.options = missing_opts
54
+ expect { subject.send('backup_retention_policy:set', 'test') }
55
+ .to raise_error(/please specify all attributes/i)
56
+ end
57
+
58
+ expect(account).to receive(:create_backup_retention_policy!)
59
+ .with(**opts).and_return(Fabricate(:backup_retention_policy))
60
+ subject.options = opts
61
+ subject.send('backup_retention_policy:set', 'test')
62
+ end
63
+
64
+ it 'merges provided options with the current policy' do
65
+ expected_opts = {
66
+ daily: 5,
67
+ monthly: policy.monthly,
68
+ yearly: policy.yearly,
69
+ make_copy: policy.make_copy,
70
+ keep_final: false
71
+ }
72
+
73
+ expect(account).to receive(:create_backup_retention_policy!)
74
+ .with(**expected_opts).and_return(Fabricate(:backup_retention_policy))
75
+ subject.options = { daily: 5, keep_final: false, force: true }
76
+ subject.send('backup_retention_policy:set', 'test')
77
+ end
78
+
79
+ it 'prompts the user if the new policy retains fewer backups' do
80
+ subject.options = { daily: 0 }
81
+
82
+ # Reject Prompt
83
+ expect(subject).to receive(:yes?).with(/do you want to proceed/i)
84
+
85
+ expect { subject.send('backup_retention_policy:set', 'test') }
86
+ .to raise_error(/aborting/i)
87
+
88
+ # Accept Prompt
89
+ expect(subject).to receive(:yes?).with(/do you want to proceed/i)
90
+ .and_return(true)
91
+
92
+ expect(account).to receive(:create_backup_retention_policy!)
93
+ .and_return(Fabricate(:backup_retention_policy))
94
+
95
+ subject.send('backup_retention_policy:set', 'test')
96
+ end
97
+
98
+ it '--force skips the confirmation promt' do
99
+ subject.options = { make_copy: false }
100
+
101
+ # Reject Prompt
102
+ expect(subject).to receive(:yes?).with(/do you want to proceed/i)
103
+
104
+ expect { subject.send('backup_retention_policy:set', 'test') }
105
+ .to raise_error(/aborting/i)
106
+
107
+ # --force
108
+ subject.options[:force] = true
109
+ expect(account).to receive(:create_backup_retention_policy!)
110
+ .and_return(Fabricate(:backup_retention_policy))
111
+
112
+ subject.send('backup_retention_policy:set', 'test')
113
+ end
114
+ end
115
+ end
@@ -116,6 +116,21 @@ describe Aptible::CLI::Agent do
116
116
  subject.send('backup:restore', 1)
117
117
  end
118
118
 
119
+ it 'accept scaling options' do
120
+ expect(backup).to receive(:create_operation!) do |options|
121
+ expect(options[:instance_profile]).to eq('m5')
122
+ expect(options[:provisioned_iops]).to eq(4000)
123
+ op
124
+ end
125
+
126
+ expect(subject).to receive(:attach_to_operation_logs).with(op) do
127
+ Fabricate(:database, account: account, handle: default_handle)
128
+ end
129
+
130
+ subject.options = { container_profile: 'm5', iops: 4000 }
131
+ subject.send('backup:restore', 1)
132
+ end
133
+
119
134
  it 'accepts an destination environment' do
120
135
  expect(backup).to receive(:create_operation!) do |options|
121
136
  expect(options[:handle]).to be_present
@@ -70,6 +70,20 @@ describe Aptible::CLI::Agent do
70
70
  subject.send('db:create', 'foo')
71
71
  end
72
72
 
73
+ it 'creates a new DB with container profile and iops' do
74
+ expect_provision_database(
75
+ { handle: 'foo', type: 'postgresql' },
76
+ { instance_profile: 'm5', provisioned_iops: 4000 }
77
+ )
78
+
79
+ subject.options = {
80
+ type: 'postgresql',
81
+ container_profile: 'm5',
82
+ iops: 4000
83
+ }
84
+ subject.send('db:create', 'foo')
85
+ end
86
+
73
87
  it 'deprovisions the database if the operation cannot be created' do
74
88
  db = Fabricate(:database)
75
89
 
@@ -160,6 +160,27 @@ describe Aptible::CLI::Agent do
160
160
  expect { subject.deploy }
161
161
  .to raise_error(/either from git.*docker/im)
162
162
  end
163
+
164
+ it 'allows providing scaling options' do
165
+ stub_options(
166
+ container_profile: 'm5',
167
+ container_size: 1024,
168
+ container_count: 2
169
+ )
170
+
171
+ expect(app).to receive(:create_operation!)
172
+ .with(
173
+ type: 'deploy',
174
+ container_size: 1024,
175
+ instance_profile: 'm5',
176
+ container_count: 2
177
+ )
178
+ .and_return(operation)
179
+ expect(subject).to receive(:attach_to_operation_logs)
180
+ .with(operation)
181
+
182
+ subject.deploy
183
+ end
163
184
  end
164
185
  end
165
186
  end
@@ -28,5 +28,6 @@ Fabricator(:account, from: :stub_account) do
28
28
  certificates { [] }
29
29
  log_drains { [] }
30
30
  metric_drains { [] }
31
+ backup_retention_policies { [] }
31
32
  created_at { Time.now }
32
33
  end
@@ -0,0 +1,18 @@
1
+ class StubBackupRetentionPolicy < OpenStruct
2
+ def reload
3
+ self
4
+ end
5
+ end
6
+
7
+ Fabricator(:backup_retention_policy, from: :stub_backup_retention_policy) do
8
+ id { sequence(:backup_retention_policy_id) }
9
+ created_at { Time.now }
10
+ daily { 30 }
11
+ monthly { 12 }
12
+ yearly { 6 }
13
+ make_copy { true }
14
+ keep_final { true }
15
+ account
16
+
17
+ after_create { |policy| policy.account.backup_retention_policies << policy }
18
+ 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.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-04 00:00:00.000000000 Z
11
+ date: 2024-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource
@@ -379,6 +379,7 @@ files:
379
379
  - spec/aptible/cli/renderer/text_spec.rb
380
380
  - spec/aptible/cli/resource_formatter_spec.rb
381
381
  - spec/aptible/cli/subcommands/apps_spec.rb
382
+ - spec/aptible/cli/subcommands/backup_retention_policy_spec.rb
382
383
  - spec/aptible/cli/subcommands/backup_spec.rb
383
384
  - spec/aptible/cli/subcommands/config_spec.rb
384
385
  - spec/aptible/cli/subcommands/db_spec.rb
@@ -399,6 +400,7 @@ files:
399
400
  - spec/fabricators/account_fabricator.rb
400
401
  - spec/fabricators/app_fabricator.rb
401
402
  - spec/fabricators/backup_fabricator.rb
403
+ - spec/fabricators/backup_retention_policy_fabricator.rb
402
404
  - spec/fabricators/certificate_fabricator.rb
403
405
  - spec/fabricators/configuration_fabricator.rb
404
406
  - spec/fabricators/database_credential_fabricator.rb
@@ -427,7 +429,7 @@ homepage: https://github.com/aptible/aptible-cli
427
429
  licenses:
428
430
  - MIT
429
431
  metadata: {}
430
- post_install_message:
432
+ post_install_message:
431
433
  rdoc_options: []
432
434
  require_paths:
433
435
  - lib
@@ -442,8 +444,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
442
444
  - !ruby/object:Gem::Version
443
445
  version: '0'
444
446
  requirements: []
445
- rubygems_version: 3.0.3.1
446
- signing_key:
447
+ rubygems_version: 3.1.6
448
+ signing_key:
447
449
  specification_version: 4
448
450
  summary: Command-line interface for Aptible services
449
451
  test_files:
@@ -463,6 +465,7 @@ test_files:
463
465
  - spec/aptible/cli/renderer/text_spec.rb
464
466
  - spec/aptible/cli/resource_formatter_spec.rb
465
467
  - spec/aptible/cli/subcommands/apps_spec.rb
468
+ - spec/aptible/cli/subcommands/backup_retention_policy_spec.rb
466
469
  - spec/aptible/cli/subcommands/backup_spec.rb
467
470
  - spec/aptible/cli/subcommands/config_spec.rb
468
471
  - spec/aptible/cli/subcommands/db_spec.rb
@@ -483,6 +486,7 @@ test_files:
483
486
  - spec/fabricators/account_fabricator.rb
484
487
  - spec/fabricators/app_fabricator.rb
485
488
  - spec/fabricators/backup_fabricator.rb
489
+ - spec/fabricators/backup_retention_policy_fabricator.rb
486
490
  - spec/fabricators/certificate_fabricator.rb
487
491
  - spec/fabricators/configuration_fabricator.rb
488
492
  - spec/fabricators/database_credential_fabricator.rb