aptible-cli 0.16.7 → 0.17.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: 35f34899ac1d54918f9f5852b665196f65f8a40daa70a405ffd10c64f0a6014a
4
- data.tar.gz: 8c0703501a28277b3775fe85b80b53ccdfc9a36256073da64119995f84b17534
3
+ metadata.gz: ec0eedcd128407794469d7da0f0b89edcbc60b659118cab8a278166440d00e9b
4
+ data.tar.gz: ed5663f602a43c54b6a13930a9f271face5c30e65c6d70d4c48eb633abb7ba63
5
5
  SHA512:
6
- metadata.gz: 3da14de30e9885ee58a3d03141a6c854beaf499825faac9dae1deeebb676ceab16ee57b0a68f6148592ccca8b87d385c3052c426cf6fc028d34b86eb84d3b8d2
7
- data.tar.gz: 634ece7c98758d5164ef56fa5a82bfbbe7974568f5d806d8e93cfd4e50c027ec7834785eaebb05307eb00dfa2a6e9b769b5b20c1415f84c4b026e73c5a14bbe1
6
+ metadata.gz: a77a1f7c55957bd2f08e00ee3cd98d7d29c2058e989b152c7939be33b7e385c0a75dc95db6682948477f4c400654a5a1aa629476f12ff94c5b17e17103cb18e2
7
+ data.tar.gz: a9fdc5310c266fe98565ff1c2aa363a16d3b58f6943f1d5fac7184717ac9c4f0d62229b7ad651cfc71d03849d1eb3d80d72ae2fafa14b4beaacb168426cf1156
data/.gitignore CHANGED
@@ -17,4 +17,4 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  /.idea
20
-
20
+ /.vscode
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
+ dist: xenial
1
2
  sudo: false
2
3
 
3
4
  rvm:
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ gem 'rack', '~> 1.0'
6
6
 
7
7
  group :test do
8
8
  gem 'webmock'
9
- gem 'codecov', '~> 0.1.0', require: false
10
9
  end
11
10
 
12
11
  # Specify your gem's dependencies in aptible-cli.gemspec
data/README.md CHANGED
@@ -3,7 +3,6 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/aptible-cli.png)](https://rubygems.org/gems/aptible-cli)
4
4
  [![Build Status](https://travis-ci.org/aptible/aptible-cli.png?branch=master)](https://travis-ci.org/aptible/aptible-cli)
5
5
  [![Dependency Status](https://gemnasium.com/aptible/aptible-cli.png)](https://gemnasium.com/aptible/aptible-cli)
6
- [![codecov](https://codecov.io/gh/aptible/aptible-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/aptible/aptible-cli)
7
6
  [![Roadmap](https://badge.waffle.io/aptible/aptible-cli.svg?label=ready&title=roadmap)](http://waffle.io/aptible/aptible-cli)
8
7
 
9
8
  Command-line interface for Aptible services.
@@ -29,54 +28,55 @@ From `aptible help`:
29
28
  <!-- BEGIN USAGE -->
30
29
  ```
31
30
  Commands:
32
- aptible apps # List all applications
33
- aptible apps:create HANDLE # Create a new application
34
- aptible apps:deprovision # Deprovision an app
35
- aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] # Scale a service
36
- aptible backup:list DB_HANDLE # List backups for a database
37
- aptible backup:orphaned # List backups associated with deprovisioned databases
38
- aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
39
- aptible backup:restore BACKUP_ID [--environment ENVIRONMENT_HANDLE] [--handle HANDLE] [--container-size SIZE_MB] [--disk-size SIZE_GB] # Restore a backup
40
- aptible config # Print an app's current configuration
41
- aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
42
- aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
43
- aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
44
- aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
45
- aptible db:backup HANDLE # Backup a database
46
- aptible db:clone SOURCE DEST # Clone a database to create a new one
47
- aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] # Create a new database
48
- aptible db:deprovision HANDLE # Deprovision a database
49
- aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
50
- aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
51
- aptible db:list # List all databases
52
- aptible db:reload HANDLE # Reload a database
53
- aptible db:replicate HANDLE REPLICA_HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] [--logical --version VERSION] # Create a replica/follower of a database
54
- aptible db:restart HANDLE [--container-size SIZE_MB] [--disk-size SIZE_GB] # Restart a database
55
- aptible db:tunnel HANDLE # Create a local tunnel to a database
56
- aptible db:url HANDLE # Display a database URL
57
- aptible db:versions # List available database versions
58
- aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
59
- aptible domains # Print an app's current virtual domains - DEPRECATED
60
- aptible endpoints:database:create DATABASE # Create a Database Endpoint
61
- aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
62
- aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
63
- aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
64
- aptible endpoints:list [--app APP | --database DATABASE] # List Endpoints for an App or Database
65
- aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME # Renew an App Managed TLS Endpoint
66
- aptible endpoints:tcp:create [--app APP] SERVICE # Create an App TCP Endpoint
67
- aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
68
- aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
69
- aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
70
- aptible help [COMMAND] # Describe available commands or one specific command
71
- aptible login # Log in to Aptible
72
- aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
73
- aptible operation:cancel OPERATION_ID # Cancel a running operation
74
- aptible ps # Display running processes for an app - DEPRECATED
75
- aptible rebuild # Rebuild an app, and restart its services
76
- aptible restart # Restart all services associated with an app
77
- aptible services # List Services for an App
78
- aptible ssh [COMMAND] # Run a command against an app
79
- aptible version # Print Aptible CLI version
31
+ aptible apps # List all applications
32
+ aptible apps:create HANDLE # Create a new application
33
+ aptible apps:deprovision # Deprovision an app
34
+ aptible apps:scale SERVICE [--container-count COUNT] [--container-size SIZE_MB] # Scale a service
35
+ aptible backup:list DB_HANDLE # List backups for a database
36
+ aptible backup:orphaned # List backups associated with deprovisioned databases
37
+ aptible backup:purge BACKUP_ID # Permanently delete a backup and any copies of it
38
+ 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
39
+ aptible config # Print an app's current configuration
40
+ aptible config:add [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
41
+ aptible config:rm [VAR1] [VAR2] [...] # Remove an ENV variable from an app
42
+ aptible config:set [VAR1=VAL1] [VAR2=VAL2] [...] # Add an ENV variable to an app
43
+ aptible config:unset [VAR1] [VAR2] [...] # Remove an ENV variable from an app
44
+ aptible db:backup HANDLE # Backup a database
45
+ aptible db:clone SOURCE DEST # Clone a database to create a new one
46
+ aptible db:create HANDLE [--type TYPE] [--version VERSION] [--container-size SIZE_MB] [--disk-size SIZE_GB] [--key-arn KEY_ARN] # Create a new database
47
+ aptible db:deprovision HANDLE # Deprovision a database
48
+ aptible db:dump HANDLE [pg_dump options] # Dump a remote database to file
49
+ aptible db:execute HANDLE SQL_FILE [--on-error-stop] # Executes sql against a database
50
+ aptible db:list # List all databases
51
+ aptible db:reload HANDLE # Reload a database
52
+ 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:tunnel HANDLE # Create a local tunnel to a database
55
+ aptible db:url HANDLE # Display a database URL
56
+ aptible db:versions # List available database versions
57
+ aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
58
+ aptible domains # Print an app's current virtual domains - DEPRECATED
59
+ aptible endpoints:database:create DATABASE # Create a Database Endpoint
60
+ aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
61
+ aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
62
+ aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
63
+ aptible endpoints:list [--app APP | --database DATABASE] # List Endpoints for an App or Database
64
+ aptible endpoints:renew [--app APP] ENDPOINT_HOSTNAME # Renew an App Managed TLS Endpoint
65
+ aptible endpoints:tcp:create [--app APP] SERVICE # Create an App TCP Endpoint
66
+ aptible endpoints:tcp:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TCP Endpoint
67
+ aptible endpoints:tls:create [--app APP] SERVICE # Create an App TLS Endpoint
68
+ aptible endpoints:tls:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App TLS Endpoint
69
+ aptible environment:ca_cert # Retrieve the CA certificate associated with the environment
70
+ aptible environment:list # List all environments
71
+ aptible help [COMMAND] # Describe available commands or one specific command
72
+ aptible login # Log in to Aptible
73
+ aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
74
+ aptible operation:cancel OPERATION_ID # Cancel a running operation
75
+ aptible rebuild # Rebuild an app, and restart its services
76
+ aptible restart # Restart all services associated with an app
77
+ aptible services # List Services for an App
78
+ aptible ssh [COMMAND] # Run a command against an app
79
+ aptible version # Print Aptible CLI version
80
80
  ```
81
81
  <!-- END USAGE -->
82
82
 
data/appveyor.yml CHANGED
@@ -8,12 +8,6 @@ environment:
8
8
  - RUBY_VERSION: 23
9
9
 
10
10
  install:
11
- # The SSL_CERT_* environment variables are here since otherwise calls to
12
- # codecov.io wtill not work. These variables do have to be set in order for
13
- # the gem to make calls to the Aptible API, since otherwise Ruby will fail
14
- # with a certificate verification error.
15
- - set SSL_CERT_DIR=%PROGRAMFILES%\Git\mingw64\ssl\certs
16
- - set SSL_CERT_FILE=%PROGRAMFILES%\Git\mingw64\ssl\cert.pem
17
11
  # Override PATHEXT so our ssh bat file has a higher precedence.
18
12
  - set PATHEXT=.BAT;.COM;.EXE;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
19
13
  - set PATH=C:\Ruby%RUBY_VERSION%-x64\bin;%PATH%
@@ -28,4 +22,4 @@ before_test:
28
22
  - bundle -v
29
23
 
30
24
  test_script:
31
- - bundle exec rake ci
25
+ - bundle exec rake ci
data/aptible-cli.gemspec CHANGED
@@ -22,13 +22,17 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency 'aptible-resource', '~> 1.1'
24
24
  spec.add_dependency 'aptible-api', '~> 1.2'
25
- spec.add_dependency 'aptible-auth', '~> 1.1.0'
25
+ spec.add_dependency 'aptible-auth', '~> 1.2.3'
26
26
  spec.add_dependency 'aptible-billing', '~> 1.0'
27
27
  spec.add_dependency 'thor', '~> 0.20.0'
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/bin/aptible CHANGED
@@ -10,7 +10,7 @@ end
10
10
  begin
11
11
  Aptible::CLI::Agent.start
12
12
  rescue HyperResource::ClientError => e
13
- m = if e.body['error'] == 'invalid_token'
13
+ m = if %w(invalid_token expired_token).include? e.body['error']
14
14
  'API authentication error: please run aptible login'
15
15
  else
16
16
  "An error occurred: #{e.body['message']}"
@@ -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
@@ -67,6 +67,7 @@ module Aptible
67
67
  def initialize(*)
68
68
  nag_toolbelt unless toolbelt?
69
69
  Aptible::Resource.configure { |conf| conf.user_agent = version_string }
70
+ warn_sso_enforcement
70
71
  super
71
72
  end
72
73
 
@@ -232,6 +233,19 @@ module Aptible
232
233
  end
233
234
  end
234
235
 
236
+ def warn_sso_enforcement
237
+ # If the user is also a member of
238
+ token = fetch_token
239
+ reauth = Aptible::Auth::ReauthenticateOrganization.all(token: token)
240
+ return if reauth.empty?
241
+
242
+ CLI.logger.warn(['WARNING: You will need to use the appropriate',
243
+ 'login method (SSO or Aptible credentials) to access',
244
+ 'these organizations:',
245
+ reauth.map(&:name)].join(' '))
246
+ rescue StandardError
247
+ end
248
+
235
249
  def version_string
236
250
  bits = [
237
251
  'aptible-cli',
@@ -51,7 +51,8 @@ module Aptible
51
51
  replication_params = {
52
52
  handle: dest_handle,
53
53
  container_size: options[:container_size],
54
- disk_size: options[:size]
54
+ disk_size: options[:size],
55
+ key_arn: options[:key_arn]
55
56
  }.reject { |_, v| v.nil? }
56
57
 
57
58
  if options[:logical]
@@ -104,10 +105,11 @@ module Aptible
104
105
 
105
106
  def local_url(credential, local_port)
106
107
  remote_url = credential.connection_url
107
- uri = URI.parse(remote_url)
108
108
 
109
+ uri = URI.parse(remote_url)
110
+ domain = credential.database.account.stack.internal_domain
109
111
  "#{uri.scheme}://#{uri.user}:#{uri.password}@" \
110
- "localhost.aptible.in:#{local_port}#{uri.path}"
112
+ "localhost.#{domain}:#{local_port}#{uri.path}"
111
113
  end
112
114
 
113
115
  def find_credential(database, type = nil)
@@ -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|
@@ -81,6 +82,7 @@ module Aptible
81
82
  node.value('handle', database.handle)
82
83
 
83
84
  node.value('type', database.type)
85
+ node.value('version', database.database_image.version)
84
86
  node.value('status', database.status)
85
87
 
86
88
  node.value('connection_url', database.connection_url)
@@ -91,6 +93,16 @@ module Aptible
91
93
  end
92
94
  end
93
95
  attach_account(node, account)
96
+
97
+ if database.disk
98
+ node.value('disk_type', database.disk.ebs_volume_type)
99
+ node.value('disk_size', database.disk.size)
100
+ end
101
+
102
+ if database.service
103
+ node.value('container_size', \
104
+ database.service.container_memory_limit_mb)
105
+ end
94
106
  end
95
107
 
96
108
  def inject_credential(node, credential)
@@ -9,13 +9,15 @@ module Aptible
9
9
 
10
10
  desc 'backup:restore BACKUP_ID ' \
11
11
  '[--environment ENVIRONMENT_HANDLE] [--handle HANDLE] ' \
12
- '[--container-size SIZE_MB] [--disk-size SIZE_GB]',
12
+ '[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
13
+ '[--key-arn KEY_ARN]',
13
14
  'Restore a backup'
14
15
  option :handle, desc: 'a name to use for the new database'
15
16
  option :environment, desc: 'a different environment to restore to'
16
17
  option :container_size, type: :numeric
17
18
  option :size, type: :numeric
18
19
  option :disk_size, type: :numeric
20
+ option :key_arn, type: :string
19
21
  define_method 'backup:restore' do |backup_id|
20
22
  backup = Aptible::Api::Backup.find(backup_id, token: fetch_token)
21
23
  raise Thor::Error, "Backup ##{backup_id} not found" if backup.nil?
@@ -38,7 +40,8 @@ module Aptible
38
40
  handle: handle,
39
41
  container_size: options[:container_size],
40
42
  disk_size: options[:disk_size] || options[:size],
41
- destination_account: destination_account
43
+ destination_account: destination_account,
44
+ key_arn: options[:key_arn]
42
45
  }.delete_if { |_, v| v.nil? }
43
46
 
44
47
  CLI.logger.warn([
@@ -53,13 +53,15 @@ module Aptible
53
53
 
54
54
  desc 'db:create HANDLE ' \
55
55
  '[--type TYPE] [--version VERSION] ' \
56
- '[--container-size SIZE_MB] [--disk-size SIZE_GB]',
56
+ '[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
57
+ '[--key-arn KEY_ARN]',
57
58
  'Create a new database'
58
59
  option :type, type: :string
59
60
  option :version, type: :string
60
61
  option :container_size, type: :numeric
61
62
  option :size, type: :numeric
62
63
  option :disk_size, default: 10, type: :numeric
64
+ option :key_arn, type: :string
63
65
  option :environment
64
66
  define_method 'db:create' do |handle|
65
67
  account = ensure_environment(options)
@@ -67,7 +69,8 @@ module Aptible
67
69
  db_opts = {
68
70
  handle: handle,
69
71
  initial_container_size: options[:container_size],
70
- initial_disk_size: options[:disk_size] || options[:size]
72
+ initial_disk_size: options[:disk_size] || options[:size],
73
+ current_kms_arn: options[:key_arn]
71
74
  }.delete_if { |_, v| v.nil? }
72
75
 
73
76
  CLI.logger.warn([
@@ -123,7 +126,7 @@ module Aptible
123
126
 
124
127
  desc 'db:replicate HANDLE REPLICA_HANDLE ' \
125
128
  '[--container-size SIZE_MB] [--disk-size SIZE_GB] ' \
126
- '[--logical --version VERSION]',
129
+ '[--logical --version VERSION] [--key-arn KEY_ARN]',
127
130
  'Create a replica/follower of a database'
128
131
  option :environment
129
132
  option :container_size, type: :numeric
@@ -131,6 +134,7 @@ module Aptible
131
134
  option :disk_size, type: :numeric
132
135
  option :logical, type: :boolean
133
136
  option :version, type: :string
137
+ option :key_arn, type: :string
134
138
  define_method 'db:replicate' do |source_handle, dest_handle|
135
139
  source = ensure_database(options.merge(db: source_handle))
136
140
 
@@ -154,7 +158,8 @@ module Aptible
154
158
  container_size: options[:container_size],
155
159
  size: options[:disk_size] || options[:size],
156
160
  logical: options[:logical],
157
- database_image: image || nil
161
+ database_image: image || nil,
162
+ key_arn: options[:key_arn]
158
163
  }.delete_if { |_, v| v.nil? }
159
164
 
160
165
  CLI.logger.warn([
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.16.7'.freeze
3
+ VERSION = '0.17.2'.freeze
4
4
  end
5
5
  end
@@ -13,7 +13,9 @@ describe Aptible::CLI::Agent do
13
13
  end
14
14
 
15
15
  let(:handle) { 'foobar' }
16
- let(:database) { Fabricate(:database, handle: handle) }
16
+ let(:stack) { Fabricate(:stack, internal_domain: 'aptible.in') }
17
+ let(:account) { Fabricate(:account, stack: stack) }
18
+ let(:database) { Fabricate(:database, handle: handle, account: account) }
17
19
  let(:socat_helper) { SocatHelperMock.new(port: 4242) }
18
20
 
19
21
  describe '#db:create' do
@@ -0,0 +1,54 @@
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
+ },
37
+ {
38
+ 'handle' => 'bar',
39
+ 'ca_body' => '--account 2 cert--'
40
+ }
41
+ ]
42
+ expect(captured_output_json.map! { |account| account.except('id') })
43
+ .to eq(expected_accounts)
44
+ end
45
+
46
+ it 'fetches certs for specified environment' do
47
+ subject.options = { environment: 'foo' }
48
+ subject.send('environment:ca_cert')
49
+
50
+ expect(captured_output_text.split("\n")).to include('account 1 cert')
51
+ expect(captured_output_text.split("\n"))
52
+ .to_not include('--account 2 cert--')
53
+ end
54
+ end
@@ -20,6 +20,7 @@ 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 { [] }
@@ -0,0 +1,7 @@
1
+ class StubDatabaseDisk < OpenStruct
2
+ end
3
+
4
+ Fabricator(:database_disk, from: :stub_database_disk) do
5
+ size 100
6
+ ebs_volume_type { 'gb2' }
7
+ end
@@ -16,6 +16,8 @@ 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 { [] }
data/spec/spec_helper.rb CHANGED
@@ -3,14 +3,6 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
 
4
4
  Bundler.require :development
5
5
 
6
- require 'simplecov'
7
- SimpleCov.start
8
-
9
- if ENV['CI']
10
- require 'codecov'
11
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
12
- end
13
-
14
6
  # Load shared spec files
15
7
  Dir["#{File.dirname(__FILE__)}/shared/**/*.rb"].each do |file|
16
8
  require file
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.16.7
4
+ version: 0.17.2
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: 2020-08-11 00:00:00.000000000 Z
11
+ date: 2021-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.1.0
47
+ version: 1.2.3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.1.0
54
+ version: 1.2.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: aptible-billing
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -359,7 +361,7 @@ homepage: https://github.com/aptible/aptible-cli
359
361
  licenses:
360
362
  - MIT
361
363
  metadata: {}
362
- post_install_message:
364
+ post_install_message:
363
365
  rdoc_options: []
364
366
  require_paths:
365
367
  - lib
@@ -375,7 +377,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
375
377
  version: '0'
376
378
  requirements: []
377
379
  rubygems_version: 3.0.3
378
- signing_key:
380
+ signing_key:
379
381
  specification_version: 4
380
382
  summary: Command-line interface for Aptible services
381
383
  test_files:
@@ -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