aptible-cli 0.19.8 → 0.19.9

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: 5297ec1eb7d106b2b69705d31ab05426fb64d8c553b170918c4090aaf582398f
4
- data.tar.gz: d0478f4e443b88f9def1a45a9db9b029f62d36e6d73bc53c6a686c858bfd3e83
3
+ metadata.gz: 32982651526f1859445bcdfa762881e25f68b72dbce3ecca1a0169a900f4cca5
4
+ data.tar.gz: 21a14594b144844b6e833ba2f5811736d0c642839375aadbbea356853478c8ec
5
5
  SHA512:
6
- metadata.gz: 9e0490170403f7272b481a09272115aafc5d1a3c65b21c26d357e149fc305b5ffef0c04903d8e677f865b992d76551828e3621a338d2bc6c6ee69a33222b8ddf
7
- data.tar.gz: fa77c4fd5462b8b99a5f0ae8146e876e163e8faf6b2e34aa1275cdbea6d920d40b48b9f1fb08820b92d3b5ab02de681c17b20a4192305b7c674760cdfbd80ba3
6
+ metadata.gz: 50a22a2a0c8eee1b4c65912a0e986cb723250b7541a6ded2e31112ae11d06cca48ae05329395d1d8f44704e917818d037f3b5d47eac74f3f320ab39ed1496527
7
+ data.tar.gz: 398cc5e09a3c0b1458a633ad4e5b0bcdb09040160207052face94142dee4b171ecfbe9c68af51007cb8e16cff03249e7821cd041834c4a161e66a10e770d0ea5
data/Dockerfile ADDED
@@ -0,0 +1,10 @@
1
+ FROM ruby:2.7.8
2
+
3
+ WORKDIR /app
4
+ COPY . /app
5
+
6
+ RUN ./cleanup_bundler
7
+ RUN gem install bundler -v '< 2'
8
+ RUN bundle install
9
+
10
+ CMD ["/app/bin/aptible"]
data/README.md CHANGED
@@ -35,8 +35,11 @@ Commands:
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
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
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] # Set the environemnt's backup retention policy
38
40
  aptible config # Print an app's current configuration
39
41
  aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
42
+ aptible config:get [VAR1] # Print a specific key within an app's current configuration
40
43
  aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
41
44
  aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
42
45
  aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
@@ -0,0 +1,10 @@
1
+ services:
2
+ # docker compose run cli bash
3
+ # export APTIBLE_ACCESS_TOKEN=xxx
4
+ # bundle exec ./bin/aptible help
5
+ cli:
6
+ build: .
7
+ volumes:
8
+ - type: bind
9
+ source: .
10
+ target: /app
@@ -42,6 +42,7 @@ require_relative 'subcommands/endpoints'
42
42
  require_relative 'subcommands/log_drain'
43
43
  require_relative 'subcommands/metric_drain'
44
44
  require_relative 'subcommands/maintenance'
45
+ require_relative 'subcommands/backup_retention_policy'
45
46
 
46
47
  module Aptible
47
48
  module CLI
@@ -70,6 +71,7 @@ module Aptible
70
71
  include Subcommands::LogDrain
71
72
  include Subcommands::MetricDrain
72
73
  include Subcommands::Maintenance
74
+ include Subcommands::BackupRetentionPolicy
73
75
 
74
76
  # Forward return codes on failures.
75
77
  def self.exit_on_failure?
@@ -247,10 +247,10 @@ module Aptible
247
247
  raw_start, raw_end = maintenance_resource.maintenance_deadline
248
248
  window_start = utc_string(raw_start)
249
249
  window_end = utc_string(raw_end)
250
- label = "#{maintenance_resource.handle} between #{window_start} "\
250
+ label = "#{maintenance_resource.handle} between #{window_start} " \
251
251
  "and #{window_end}"
252
- restart_command = "#{command_prefix}"\
253
- " #{maintenance_resource.handle}"\
252
+ restart_command = "#{command_prefix}" \
253
+ " #{maintenance_resource.handle}" \
254
254
  " --environment #{account.handle}"
255
255
  node.value('label', label)
256
256
  node.value('handle', maintenance_resource.handle)
@@ -259,6 +259,17 @@ module Aptible
259
259
  attach_account(node, account)
260
260
  end
261
261
 
262
+ def inject_backup_retention_policy(node, policy, account)
263
+ node.value('id', policy.id)
264
+ node.value('daily', policy.daily)
265
+ node.value('monthly', policy.monthly)
266
+ node.value('yearly', policy.yearly)
267
+ node.value('make_copy', policy.make_copy)
268
+ node.value('keep_final', policy.keep_final)
269
+
270
+ attach_account(node, account)
271
+ end
272
+
262
273
  private
263
274
 
264
275
  def attach_account(node, account)
@@ -0,0 +1,80 @@
1
+ require 'term/ansicolor'
2
+ require 'uri'
3
+ require 'English'
4
+
5
+ module Aptible
6
+ module CLI
7
+ module Subcommands
8
+ module BackupRetentionPolicy
9
+ def self.included(thor)
10
+ thor.class_eval do
11
+ include Helpers::Environment
12
+ include Term::ANSIColor
13
+
14
+ desc 'backup_retention_policy [ENVIRONMENT_HANDLE]',
15
+ 'Show the current backup retention policy for the environment'
16
+ define_method 'backup_retention_policy' do |env|
17
+ account = ensure_environment(environment: env)
18
+ policy = account.backup_retention_policies.first
19
+ unless policy
20
+ # Show the default policy
21
+ policy = Aptible::Api::BackupRetentionPolicy.new
22
+ policy.attributes[:id] = 'default'
23
+ policy.attributes[:daily] = 90
24
+ policy.attributes[:monthly] = 72
25
+ policy.attributes[:yearly] = 0
26
+ policy.attributes[:make_copy] = true
27
+ policy.attributes[:keep_final] = true
28
+ end
29
+
30
+ Formatter.render(Renderer.current) do |root|
31
+ root.object do |node|
32
+ ResourceFormatter.inject_backup_retention_policy(
33
+ node, policy, account
34
+ )
35
+ end
36
+ end
37
+ end
38
+
39
+ desc 'backup_retention_policy:set [ENVIRONMENT_HANDLE] ' \
40
+ '[--daily DAILY_BACKUPS] [--monthly MONTHLY_BACKUPS] ' \
41
+ '[--yearly YEARLY_BACKUPS] [--make-copy|--no-make-copy] ' \
42
+ '[--keep-final|--no-keep-final]',
43
+ "Set the environemnt's backup retention policy"
44
+ option :daily, type: :numeric,
45
+ desc: 'Number of daily backups to retain',
46
+ default: 90
47
+ option :monthly, type: :numeric,
48
+ desc: 'Number of monthly backups to retain',
49
+ default: 72
50
+ option :yearly, type: :numeric,
51
+ desc: 'Number of yarly backups to retain',
52
+ default: 0
53
+ option :make_copy, type: :boolean,
54
+ desc: 'If backup copies should be created',
55
+ default: true
56
+ option(
57
+ :keep_final,
58
+ type: :boolean,
59
+ desc: 'If final backups should be kept when databases are '\
60
+ 'deprovisioned',
61
+ default: true
62
+ )
63
+ define_method 'backup_retention_policy:set' do |env|
64
+ account = ensure_environment(environment: env)
65
+ policy = account.create_backup_retention_policy!(**options)
66
+
67
+ Formatter.render(Renderer.current) do |root|
68
+ root.object do |node|
69
+ ResourceFormatter.inject_backup_retention_policy(
70
+ node, policy.reload, account
71
+ )
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -29,6 +29,23 @@ module Aptible
29
29
  end
30
30
  end
31
31
 
32
+ desc 'config:get [VAR1]',
33
+ "Print a specific key within an app's current configuration"
34
+ app_options
35
+ define_method 'config:get' do |*args|
36
+ app = ensure_app(options)
37
+ config = app.current_configuration
38
+ env = config ? config.env : {}
39
+
40
+ Formatter.render(Renderer.current) do |root|
41
+ key = args[0]
42
+ value = env
43
+ .select { |k| k == key }
44
+ .map { |_, v| v }
45
+ root.value(value)
46
+ end
47
+ end
48
+
32
49
  desc 'config:add [VAR1=VAL1] [VAR2=VAL2] [...]',
33
50
  'Add an ENV variable to an app'
34
51
  app_options
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.19.8'.freeze
3
+ VERSION = '0.19.9'.freeze
4
4
  end
5
5
  end
@@ -57,6 +57,28 @@ describe Aptible::CLI::Agent do
57
57
  end
58
58
  end
59
59
 
60
+ describe '#config:get' do
61
+ it 'should show single environment variable specified' do
62
+ app.current_configuration = Fabricate(
63
+ :configuration, app: app, env: { 'FOO' => 'BAR', 'QUX' => 'two words' }
64
+ )
65
+ subject.send('config:get', 'FOO')
66
+
67
+ expect(captured_output_text).to match(/BAR/)
68
+ expect(captured_output_text).not_to match(/two\\ words/)
69
+ expect(captured_output_json).to match_array(['BAR'])
70
+ end
71
+
72
+ it 'should show empty line when env var not found' do
73
+ app.current_configuration = Fabricate(
74
+ :configuration, app: app, env: { 'FOO' => 'BAR', 'QUX' => 'two words' }
75
+ )
76
+ subject.send('config:get', 'MIZ')
77
+
78
+ expect(captured_output_text).to eq('')
79
+ end
80
+ end
81
+
60
82
  describe '#config:set' do
61
83
  it 'sets environment variables' do
62
84
  expect(app).to receive(:create_operation!)
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.19.8
4
+ version: 0.19.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-15 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource
@@ -294,6 +294,7 @@ files:
294
294
  - ".gitignore"
295
295
  - ".rspec"
296
296
  - ".travis.yml"
297
+ - Dockerfile
297
298
  - Gemfile
298
299
  - LICENSE.md
299
300
  - README.md
@@ -304,6 +305,7 @@ files:
304
305
  - bin/aptible
305
306
  - cleanup_bundler
306
307
  - codecov.yml
308
+ - docker-compose.yml
307
309
  - lib/aptible/cli.rb
308
310
  - lib/aptible/cli/agent.rb
309
311
  - lib/aptible/cli/error.rb
@@ -341,6 +343,7 @@ files:
341
343
  - lib/aptible/cli/resource_formatter.rb
342
344
  - lib/aptible/cli/subcommands/apps.rb
343
345
  - lib/aptible/cli/subcommands/backup.rb
346
+ - lib/aptible/cli/subcommands/backup_retention_policy.rb
344
347
  - lib/aptible/cli/subcommands/config.rb
345
348
  - lib/aptible/cli/subcommands/db.rb
346
349
  - lib/aptible/cli/subcommands/deploy.rb