aptible-cli 0.24.2 → 0.24.3

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/Gemfile.lock +1 -1
  4. data/lib/aptible/cli/agent.rb +9 -1
  5. data/lib/aptible/cli/helpers/app.rb +16 -1
  6. data/lib/aptible/cli/helpers/database.rb +20 -5
  7. data/lib/aptible/cli/helpers/environment.rb +28 -3
  8. data/lib/aptible/cli/helpers/telemetry.rb +58 -0
  9. data/lib/aptible/cli/helpers/token.rb +6 -0
  10. data/lib/aptible/cli/renderer.rb +5 -1
  11. data/lib/aptible/cli/resource_formatter.rb +7 -0
  12. data/lib/aptible/cli/subcommands/apps.rb +31 -2
  13. data/lib/aptible/cli/subcommands/backup.rb +9 -0
  14. data/lib/aptible/cli/subcommands/backup_retention_policy.rb +5 -0
  15. data/lib/aptible/cli/subcommands/config.rb +11 -0
  16. data/lib/aptible/cli/subcommands/db.rb +68 -3
  17. data/lib/aptible/cli/subcommands/deploy.rb +3 -0
  18. data/lib/aptible/cli/subcommands/endpoints.rb +26 -0
  19. data/lib/aptible/cli/subcommands/environment.rb +11 -0
  20. data/lib/aptible/cli/subcommands/log_drain.rb +26 -5
  21. data/lib/aptible/cli/subcommands/logs.rb +5 -0
  22. data/lib/aptible/cli/subcommands/maintenance.rb +5 -0
  23. data/lib/aptible/cli/subcommands/metric_drain.rb +25 -5
  24. data/lib/aptible/cli/subcommands/operation.rb +7 -0
  25. data/lib/aptible/cli/subcommands/rebuild.rb +3 -0
  26. data/lib/aptible/cli/subcommands/restart.rb +3 -0
  27. data/lib/aptible/cli/subcommands/services.rb +12 -3
  28. data/lib/aptible/cli/subcommands/ssh.rb +3 -0
  29. data/lib/aptible/cli/version.rb +1 -1
  30. data/spec/aptible/cli/subcommands/apps_spec.rb +13 -1
  31. data/spec/aptible/cli/subcommands/config_spec.rb +4 -2
  32. data/spec/aptible/cli/subcommands/db_spec.rb +7 -1
  33. data/spec/aptible/cli/subcommands/endpoints_spec.rb +9 -3
  34. data/spec/aptible/cli/subcommands/environment_spec.rb +3 -1
  35. data/spec/aptible/cli/subcommands/log_drain_spec.rb +15 -2
  36. data/spec/aptible/cli/subcommands/maintenance_spec.rb +3 -2
  37. data/spec/aptible/cli/subcommands/metric_drain_spec.rb +15 -2
  38. data/spec/aptible/cli/subcommands/services_spec.rb +3 -1
  39. data/spec/fabricators/account_fabricator.rb +8 -0
  40. data/spec/fabricators/app_fabricator.rb +9 -0
  41. data/spec/fabricators/database_fabricator.rb +8 -0
  42. data/spec/fabricators/log_drain_fabricator.rb +8 -0
  43. data/spec/fabricators/metric_drain_fabricator.rb +8 -0
  44. data/spec/spec_helper.rb +9 -1
  45. metadata +6 -5
@@ -18,6 +18,7 @@ module Aptible
18
18
  thor.class_eval do
19
19
  include Helpers::Operation
20
20
  include Helpers::App
21
+ include Helpers::Telemetry
21
22
 
22
23
  desc 'deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...]',
23
24
  'Deploy an app'
@@ -46,6 +47,8 @@ module Aptible
46
47
  end
47
48
  app_options
48
49
  def deploy(*args)
50
+ telemetry(__method__, options)
51
+
49
52
  app = ensure_app(options)
50
53
 
51
54
  git_ref = options[:git_commitish]
@@ -10,6 +10,7 @@ module Aptible
10
10
  include Helpers::Operation
11
11
  include Helpers::AppOrDatabase
12
12
  include Helpers::Vhost
13
+ include Helpers::Telemetry
13
14
 
14
15
  database_create_flags = Helpers::Vhost::OptionSetBuilder.new do
15
16
  create!
@@ -20,6 +21,8 @@ module Aptible
20
21
  'Create a Database Endpoint'
21
22
  database_create_flags.declare_options(self)
22
23
  define_method 'endpoints:database:create' do |handle|
24
+ telemetry(__method__, options.merge(handle: handle))
25
+
23
26
  database = ensure_database(options.merge(db: handle))
24
27
  service = database.service
25
28
  raise Thor::Error, 'Database is not provisioned' if service.nil?
@@ -42,6 +45,8 @@ module Aptible
42
45
  'Modify a Database Endpoint'
43
46
  database_modify_flags.declare_options(self)
44
47
  define_method 'endpoints:database:modify' do |hostname|
48
+ telemetry(__method__, options.merge(hostname: hostname))
49
+
45
50
  database = ensure_database(options.merge(db: options[:database]))
46
51
  vhost = find_vhost(each_service(database), hostname)
47
52
  vhost.update!(**database_modify_flags.prepare(database.account,
@@ -59,6 +64,8 @@ module Aptible
59
64
  'Create an App TCP Endpoint'
60
65
  tcp_create_flags.declare_options(self)
61
66
  define_method 'endpoints:tcp:create' do |type|
67
+ telemetry(__method__, options.merge(type: type))
68
+
62
69
  create_app_vhost(
63
70
  tcp_create_flags, options, type,
64
71
  type: 'tcp', platform: 'elb'
@@ -74,6 +81,8 @@ module Aptible
74
81
  'Modify an App TCP Endpoint'
75
82
  tcp_modify_flags.declare_options(self)
76
83
  define_method 'endpoints:tcp:modify' do |hostname|
84
+ telemetry(__method__, options.merge(hostname: hostname))
85
+
77
86
  modify_app_vhost(tcp_modify_flags, options, hostname)
78
87
  end
79
88
 
@@ -88,6 +97,8 @@ module Aptible
88
97
  'Create an App TLS Endpoint'
89
98
  tls_create_flags.declare_options(self)
90
99
  define_method 'endpoints:tls:create' do |type|
100
+ telemetry(__method__, options.merge(type: type))
101
+
91
102
  create_app_vhost(
92
103
  tls_create_flags, options, type,
93
104
  type: 'tls', platform: 'elb'
@@ -104,6 +115,8 @@ module Aptible
104
115
  'Modify an App TLS Endpoint'
105
116
  tls_modify_flags.declare_options(self)
106
117
  define_method 'endpoints:tls:modify' do |hostname|
118
+ telemetry(__method__, options.merge(hostname: hostname))
119
+
107
120
  modify_app_vhost(tls_modify_flags, options, hostname)
108
121
  end
109
122
 
@@ -118,6 +131,8 @@ module Aptible
118
131
  'Create an App gRPC Endpoint'
119
132
  grpc_create_flags.declare_options(self)
120
133
  define_method 'endpoints:grpc:create' do |type|
134
+ telemetry(__method__, options.merge(type: type))
135
+
121
136
  create_app_vhost(
122
137
  grpc_create_flags, options, type,
123
138
  type: 'grpc', platform: 'elb'
@@ -134,6 +149,8 @@ module Aptible
134
149
  'Modify an App gRPC Endpoint'
135
150
  grpc_modify_flags.declare_options(self)
136
151
  define_method 'endpoints:grpc:modify' do |hostname|
152
+ telemetry(__method__, options.merge(hostname: hostname))
153
+
137
154
  modify_app_vhost(grpc_modify_flags, options, hostname)
138
155
  end
139
156
 
@@ -148,6 +165,8 @@ module Aptible
148
165
  'Create an App HTTPS Endpoint'
149
166
  https_create_flags.declare_options(self)
150
167
  define_method 'endpoints:https:create' do |type|
168
+ telemetry(__method__, options.merge(type: type))
169
+
151
170
  create_app_vhost(
152
171
  https_create_flags, options, type,
153
172
  type: 'http', platform: 'alb'
@@ -164,6 +183,7 @@ module Aptible
164
183
  'Modify an App HTTPS Endpoint'
165
184
  https_modify_flags.declare_options(self)
166
185
  define_method 'endpoints:https:modify' do |hostname|
186
+ telemetry(__method__, options.merge(hostname: hostname))
167
187
  modify_app_vhost(https_modify_flags, options, hostname)
168
188
  end
169
189
 
@@ -171,6 +191,8 @@ module Aptible
171
191
  'List Endpoints for an App or Database'
172
192
  app_or_database_options
173
193
  define_method 'endpoints:list' do
194
+ telemetry(__method__, options)
195
+
174
196
  resource = ensure_app_or_database(options)
175
197
 
176
198
  Formatter.render(Renderer.current) do |root|
@@ -191,6 +213,8 @@ module Aptible
191
213
  'Deprovision an App or Database Endpoint'
192
214
  app_or_database_options
193
215
  define_method 'endpoints:deprovision' do |hostname|
216
+ telemetry(__method__, options.merge(hostname: hostname))
217
+
194
218
  resource = ensure_app_or_database(options)
195
219
  vhost = find_vhost(each_service(resource), hostname)
196
220
  op = vhost.create_operation!(type: 'deprovision')
@@ -209,6 +233,8 @@ module Aptible
209
233
  LONGDESC
210
234
  app_options
211
235
  define_method 'endpoints:renew' do |hostname|
236
+ telemetry(__method__, options.merge(hostname: hostname))
237
+
212
238
  app = ensure_app(options)
213
239
  vhost = find_vhost(app.each_service, hostname)
214
240
  op = vhost.create_operation!(type: 'renew')
@@ -6,10 +6,13 @@ module Aptible
6
6
  thor.class_eval do
7
7
  include Helpers::Environment
8
8
  include Helpers::Token
9
+ include Helpers::Telemetry
9
10
 
10
11
  desc 'environment:list', 'List all environments'
11
12
  option :environment, aliases: '--env'
12
13
  define_method 'environment:list' do
14
+ telemetry(__method__, options)
15
+
13
16
  Formatter.render(Renderer.current) do |root|
14
17
  root.keyed_list(
15
18
  'handle'
@@ -27,6 +30,8 @@ module Aptible
27
30
  'Retrieve the CA certificate associated with the environment'
28
31
  option :environment, aliases: '--env'
29
32
  define_method 'environment:ca_cert' do
33
+ telemetry(__method__, options)
34
+
30
35
  Formatter.render(Renderer.current) do |root|
31
36
  root.grouped_keyed_list(
32
37
  'handle',
@@ -48,6 +53,12 @@ module Aptible
48
53
  ' destinations, you must restart the apps/databases in'\
49
54
  ' this environment.'
50
55
  define_method 'environment:rename' do |old_handle, new_handle|
56
+ opts = options.merge(
57
+ old_handle: old_handle,
58
+ new_handle: new_handle
59
+ )
60
+ telemetry(__method__, opts)
61
+
51
62
  env = ensure_environment(options.merge(environment: old_handle))
52
63
  env.update!(handle: new_handle)
53
64
  m1 = "In order for the new environment handle (#{new_handle})"\
@@ -7,6 +7,7 @@ module Aptible
7
7
  include Helpers::Token
8
8
  include Helpers::Database
9
9
  include Helpers::LogDrain
10
+ include Helpers::Telemetry
10
11
 
11
12
  drain_flags = '--environment ENVIRONMENT ' \
12
13
  '[--drain-apps true/false] ' \
@@ -25,16 +26,25 @@ module Aptible
25
26
  desc 'log_drain:list', 'List all Log Drains'
26
27
  option :environment, aliases: '--env'
27
28
  define_method 'log_drain:list' do
29
+ telemetry(__method__, options)
30
+
28
31
  Formatter.render(Renderer.current) do |root|
29
32
  root.grouped_keyed_list(
30
33
  { 'environment' => 'handle' },
31
34
  'handle'
32
35
  ) do |node|
33
- scoped_environments(options).each do |account|
34
- account.log_drains.each do |drain|
35
- node.object do |n|
36
- ResourceFormatter.inject_log_drain(n, drain, account)
37
- end
36
+ accounts = scoped_environments(options)
37
+ acc_map = environment_map(accounts)
38
+
39
+ Aptible::Api::LogDrain.all(
40
+ token: fetch_token,
41
+ href: '/log_drains?per_page=5000'
42
+ ).each do |drain|
43
+ account = acc_map[drain.links.account.href]
44
+ next if account.nil?
45
+
46
+ node.object do |n|
47
+ ResourceFormatter.inject_log_drain(n, drain, account)
38
48
  end
39
49
  end
40
50
  end
@@ -49,6 +59,8 @@ module Aptible
49
59
  option :db, type: :string
50
60
  option :pipeline, type: :string
51
61
  define_method 'log_drain:create:elasticsearch' do |handle|
62
+ telemetry(__method__, options.merge(handle: handle))
63
+
52
64
  account = ensure_environment(options)
53
65
  database = ensure_database(options)
54
66
 
@@ -73,6 +85,8 @@ module Aptible
73
85
  drain_options
74
86
  option :url, type: :string
75
87
  define_method 'log_drain:create:datadog' do |handle|
88
+ telemetry(__method__, options.merge(handle: handle))
89
+
76
90
  msg = 'Must be in the format of ' \
77
91
  '"https://http-intake.logs.datadoghq.com' \
78
92
  '/v1/input/<DD_API_KEY>".'
@@ -86,6 +100,7 @@ module Aptible
86
100
  option :url, type: :string
87
101
  drain_options
88
102
  define_method 'log_drain:create:https' do |handle|
103
+ telemetry(__method__, options.merge(handle: handle))
89
104
  create_https_based_log_drain(handle, options)
90
105
  end
91
106
 
@@ -96,6 +111,7 @@ module Aptible
96
111
  option :url, type: :string
97
112
  drain_options
98
113
  define_method 'log_drain:create:sumologic' do |handle|
114
+ telemetry(__method__, options.merge(handle: handle))
99
115
  create_https_based_log_drain(handle, options)
100
116
  end
101
117
 
@@ -106,6 +122,8 @@ module Aptible
106
122
  option :url, type: :string
107
123
  drain_options
108
124
  define_method 'log_drain:create:logdna' do |handle|
125
+ telemetry(__method__, options.merge(handle: handle))
126
+
109
127
  msg = 'Must be in the format of ' \
110
128
  '"https://logs.logdna.com/aptible/ingest/<INGESTION KEY>".'
111
129
  create_https_based_log_drain(handle, options, url_format_msg: msg)
@@ -119,6 +137,7 @@ module Aptible
119
137
  option :port, type: :string
120
138
  drain_options
121
139
  define_method 'log_drain:create:papertrail' do |handle|
140
+ telemetry(__method__, options.merge(handle: handle))
122
141
  create_syslog_based_log_drain(handle, options)
123
142
  end
124
143
 
@@ -132,6 +151,7 @@ module Aptible
132
151
  option :token, type: :string
133
152
  drain_options
134
153
  define_method 'log_drain:create:syslog' do |handle|
154
+ telemetry(__method__, options.merge(handle: handle))
135
155
  create_syslog_based_log_drain(handle, options)
136
156
  end
137
157
 
@@ -139,6 +159,7 @@ module Aptible
139
159
  'Deprovisions a log drain'
140
160
  option :environment, aliases: '--env'
141
161
  define_method 'log_drain:deprovision' do |handle|
162
+ telemetry(__method__, options.merge(handle: handle))
142
163
  account = ensure_environment(options)
143
164
  drain = ensure_log_drain(account, handle)
144
165
  op = drain.create_operation(type: :deprovision)
@@ -12,11 +12,14 @@ module Aptible
12
12
  include Helpers::AppOrDatabase
13
13
  include Helpers::S3LogHelpers
14
14
  include Helpers::DateHelpers
15
+ include Helpers::Telemetry
15
16
 
16
17
  desc 'logs [--app APP | --database DATABASE]',
17
18
  'Follows logs from a running app or database'
18
19
  app_or_database_options
19
20
  def logs
21
+ telemetry(__method__, options)
22
+
20
23
  resource = ensure_app_or_database(options)
21
24
 
22
25
  unless resource.status == 'provisioned'
@@ -89,6 +92,8 @@ module Aptible
89
92
  type: :string
90
93
 
91
94
  def logs_from_archive
95
+ telemetry(__method__, options)
96
+
92
97
  ensure_aws_creds
93
98
  validate_log_search_options(options)
94
99
 
@@ -7,12 +7,15 @@ module Aptible
7
7
  include Helpers::Environment
8
8
  include Helpers::Maintenance
9
9
  include Helpers::Token
10
+ include Helpers::Telemetry
10
11
 
11
12
  desc 'maintenance:apps',
12
13
  'List Apps impacted by maintenance schedules where '\
13
14
  'restarts are required'
14
15
  option :environment, aliases: '--env'
15
16
  define_method 'maintenance:apps' do
17
+ telemetry(__method__, options)
18
+
16
19
  found_maintenance = false
17
20
  m = maintenance_apps
18
21
  Formatter.render(Renderer.current) do |root|
@@ -48,6 +51,8 @@ module Aptible
48
51
  'restarts are required'
49
52
  option :environment, aliases: '--env'
50
53
  define_method 'maintenance:dbs' do
54
+ telemetry(__method__, options)
55
+
51
56
  found_maintenance = false
52
57
  m = maintenance_databases
53
58
  Formatter.render(Renderer.current) do |root|
@@ -16,20 +16,30 @@ module Aptible
16
16
  include Helpers::Token
17
17
  include Helpers::Database
18
18
  include Helpers::MetricDrain
19
+ include Helpers::Telemetry
19
20
 
20
21
  desc 'metric_drain:list', 'List all Metric Drains'
21
22
  option :environment, aliases: '--env'
22
23
  define_method 'metric_drain:list' do
24
+ telemetry(__method__, options)
25
+
23
26
  Formatter.render(Renderer.current) do |root|
24
27
  root.grouped_keyed_list(
25
28
  { 'environment' => 'handle' },
26
29
  'handle'
27
30
  ) do |node|
28
- scoped_environments(options).each do |account|
29
- account.metric_drains.each do |drain|
30
- node.object do |n|
31
- ResourceFormatter.inject_metric_drain(n, drain, account)
32
- end
31
+ accounts = scoped_environments(options)
32
+ acc_map = environment_map(accounts)
33
+
34
+ Aptible::Api::MetricDrain.all(
35
+ token: fetch_token,
36
+ href: '/metric_drains?per_page=5000'
37
+ ).each do |drain|
38
+ account = acc_map[drain.links.account.href]
39
+ next if account.nil?
40
+
41
+ node.object do |n|
42
+ ResourceFormatter.inject_metric_drain(n, drain, account)
33
43
  end
34
44
  end
35
45
  end
@@ -43,6 +53,8 @@ module Aptible
43
53
  option :environment, aliases: '--env'
44
54
 
45
55
  define_method 'metric_drain:create:influxdb' do |handle|
56
+ telemetry(__method__, options.merge(handle: handle))
57
+
46
58
  account = ensure_environment(options)
47
59
  database = ensure_database(options)
48
60
 
@@ -68,6 +80,8 @@ module Aptible
68
80
  option :db, type: :string
69
81
  option :environment, aliases: '--env'
70
82
  define_method 'metric_drain:create:influxdb:custom' do |handle|
83
+ telemetry(__method__, options.merge(handle: handle))
84
+
71
85
  account = ensure_environment(options)
72
86
 
73
87
  config = {
@@ -97,6 +111,8 @@ module Aptible
97
111
  option :url, type: :string
98
112
  option :environment, aliases: '--env'
99
113
  define_method 'metric_drain:create:influxdb:customv2' do |handle|
114
+ telemetry(__method__, options.merge(handle: handle))
115
+
100
116
  account = ensure_environment(options)
101
117
 
102
118
  config = {
@@ -123,6 +139,8 @@ module Aptible
123
139
  option :site, type: :string
124
140
  option :environment, aliases: '--env'
125
141
  define_method 'metric_drain:create:datadog' do |handle|
142
+ telemetry(__method__, options.merge(handle: handle))
143
+
126
144
  account = ensure_environment(options)
127
145
 
128
146
  config = {
@@ -152,6 +170,8 @@ module Aptible
152
170
  'Deprovisions a Metric Drain'
153
171
  option :environment, aliases: '--env'
154
172
  define_method 'metric_drain:deprovision' do |handle|
173
+ telemetry(__method__, options.merge(handle: handle))
174
+
155
175
  account = ensure_environment(options)
156
176
  drain = ensure_metric_drain(account, handle)
157
177
  op = drain.create_operation(type: :deprovision)
@@ -6,9 +6,12 @@ module Aptible
6
6
  thor.class_eval do
7
7
  include Helpers::Token
8
8
  include Helpers::Operation
9
+ include Helpers::Telemetry
9
10
 
10
11
  desc 'operation:cancel OPERATION_ID', 'Cancel a running operation'
11
12
  define_method 'operation:cancel' do |operation_id|
13
+ telemetry(__method__, options.merge(operation_id: operation_id))
14
+
12
15
  o = Aptible::Api::Operation.find(operation_id, token: fetch_token)
13
16
  raise "Operation ##{operation_id} not found" if o.nil?
14
17
 
@@ -20,6 +23,8 @@ module Aptible
20
23
  desc 'operation:follow OPERATION_ID',
21
24
  'Follow logs of a running operation'
22
25
  define_method 'operation:follow' do |operation_id|
26
+ telemetry(__method__, options.merge(operation_id: operation_id))
27
+
23
28
  o = Aptible::Api::Operation.find(operation_id, token: fetch_token)
24
29
  raise "Operation ##{operation_id} not found" if o.nil?
25
30
 
@@ -37,6 +42,8 @@ module Aptible
37
42
 
38
43
  desc 'operation:logs OPERATION_ID', 'View logs for given operation'
39
44
  define_method 'operation:logs' do |operation_id|
45
+ telemetry(__method__, options.merge(operation_id: operation_id))
46
+
40
47
  o = Aptible::Api::Operation.find(operation_id, token: fetch_token)
41
48
  raise "Operation ##{operation_id} not found" if o.nil?
42
49
 
@@ -6,10 +6,13 @@ module Aptible
6
6
  thor.class_eval do
7
7
  include Helpers::Operation
8
8
  include Helpers::App
9
+ include Helpers::Telemetry
9
10
 
10
11
  desc 'rebuild', 'Rebuild an app, and restart its services'
11
12
  app_options
12
13
  def rebuild
14
+ telemetry(__method__, options)
15
+
13
16
  app = ensure_app(options)
14
17
  operation = app.create_operation!(type: 'rebuild')
15
18
  CLI.logger.info 'Rebuilding app...'
@@ -6,6 +6,7 @@ module Aptible
6
6
  thor.class_eval do
7
7
  include Helpers::Operation
8
8
  include Helpers::App
9
+ include Helpers::Telemetry
9
10
 
10
11
  desc 'restart', 'Restart all services associated with an app'
11
12
  option :simulate_oom,
@@ -20,6 +21,8 @@ module Aptible
20
21
  'default.'
21
22
  app_options
22
23
  def restart
24
+ telemetry(__method__, options)
25
+
23
26
  app = ensure_app(options)
24
27
  type = 'restart'
25
28
 
@@ -5,10 +5,13 @@ module Aptible
5
5
  def self.included(thor)
6
6
  thor.class_eval do
7
7
  include Helpers::App
8
+ include Helpers::Telemetry
8
9
 
9
10
  desc 'services', 'List Services for an App'
10
11
  app_options
11
12
  def services
13
+ telemetry(__method__, options)
14
+
12
15
  app = ensure_app(options)
13
16
 
14
17
  Formatter.render(Renderer.current) do |root|
@@ -35,6 +38,8 @@ module Aptible
35
38
  type: :boolean, default: false,
36
39
  desc: 'Use a simple uptime healthcheck during deployments'
37
40
  define_method 'services:settings' do |service|
41
+ telemetry(__method__, options.merge(service: service))
42
+
38
43
  service = ensure_service(options, service)
39
44
  updates = {}
40
45
  updates[:force_zero_downtime] =
@@ -49,6 +54,8 @@ module Aptible
49
54
  'Returns the associated sizing policy, if any'
50
55
  app_options
51
56
  define_method 'services:autoscaling_policy' do |service|
57
+ telemetry(__method__, options.merge(service: service))
58
+
52
59
  service = ensure_service(options, service)
53
60
  policy = service.service_sizing_policy
54
61
 
@@ -119,9 +126,9 @@ module Aptible
119
126
  'be considered.'
120
127
  option :post_release_cooldown_seconds,
121
128
  type: :numeric,
122
- desc: '(Default: 300) The time in seconds to wait '\
123
- 'following a deploy before another scaling action can '\
124
- 'be considered.'
129
+ desc: '(Default: 60) The time in seconds to ignore in '\
130
+ 'metrics following a deploy to allow for service '\
131
+ 'stabilization.'
125
132
  option :mem_cpu_ratio_r_threshold,
126
133
  type: :numeric,
127
134
  desc: '(Default: 4.0) Establishes the ratio of Memory '\
@@ -187,6 +194,8 @@ module Aptible
187
194
  ' a value of 2 will go from 4->2->1). Container count '\
188
195
  'will never exceed the configured minimum.'
189
196
  define_method 'services:autoscaling_policy:set' do |service|
197
+ telemetry(__method__, options.merge(service: service))
198
+
190
199
  service = ensure_service(options, service)
191
200
  ignored_attrs = %i(autoscaling_type app environment remote)
192
201
  args = options.except(*ignored_attrs)
@@ -8,6 +8,7 @@ module Aptible
8
8
  thor.class_eval do
9
9
  include Helpers::Operation
10
10
  include Helpers::App
11
+ include Helpers::Telemetry
11
12
 
12
13
  desc 'ssh [COMMAND]', 'Run a command against an app'
13
14
  long_desc <<-LONGDESC
@@ -18,6 +19,8 @@ module Aptible
18
19
  app_options
19
20
  option :force_tty, type: :boolean
20
21
  def ssh(*args)
22
+ telemetry(__method__, options)
23
+
21
24
  app = ensure_app(options)
22
25
 
23
26
  # SSH's default behavior is as follows:
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.24.2'.freeze
3
+ VERSION = '0.24.3'.freeze
4
4
  end
5
5
  end
@@ -31,6 +31,9 @@ describe Aptible::CLI::Agent do
31
31
  describe '#apps' do
32
32
  it 'lists an app in an account' do
33
33
  allow(Aptible::Api::Account).to receive(:all).and_return([account])
34
+ allow(Aptible::Api::App)
35
+ .to receive(:all)
36
+ .and_return([app])
34
37
  subject.send('apps')
35
38
 
36
39
  expect(captured_output_text)
@@ -40,8 +43,11 @@ describe Aptible::CLI::Agent do
40
43
  it 'lists multiple apps in an account' do
41
44
  allow(Aptible::Api::Account).to receive(:all).and_return([account])
42
45
  app2 = Fabricate(:app, handle: 'foobar', account: account)
43
- subject.send('apps')
46
+ allow(Aptible::Api::App)
47
+ .to receive(:all)
48
+ .and_return([app, app2])
44
49
 
50
+ subject.send('apps')
45
51
  expect(captured_output_text)
46
52
  .to eq("=== #{account.handle}\n#{app.handle}\n#{app2.handle}\n")
47
53
  end
@@ -54,6 +60,9 @@ describe Aptible::CLI::Agent do
54
60
  app21 = Fabricate(:app, account: account2, handle: 'app21')
55
61
  app22 = Fabricate(:app, account: account2, handle: 'app21')
56
62
 
63
+ allow(Aptible::Api::App)
64
+ .to receive(:all)
65
+ .and_return([app11, app21, app22])
57
66
  allow(Aptible::Api::Account).to receive(:all)
58
67
  .and_return([account1, account2])
59
68
 
@@ -77,6 +86,7 @@ describe Aptible::CLI::Agent do
77
86
  app2 = Fabricate(:app, account: account2, handle: 'app2')
78
87
  allow(subject).to receive(:options)
79
88
  .and_return(environment: account2.handle)
89
+ allow(Aptible::Api::App).to receive(:all).and_return([app2])
80
90
 
81
91
  allow(Aptible::Api::Account).to receive(:all)
82
92
  .and_return([account, account2])
@@ -90,6 +100,7 @@ describe Aptible::CLI::Agent do
90
100
  account = Fabricate(:account, handle: 'account')
91
101
  app = Fabricate(:app, account: account, handle: 'app')
92
102
  allow(Aptible::Api::Account).to receive(:all).and_return([account])
103
+ allow(Aptible::Api::App).to receive(:all).and_return([app])
93
104
 
94
105
  s1 = Fabricate(
95
106
  :service,
@@ -148,6 +159,7 @@ describe Aptible::CLI::Agent do
148
159
  app = Fabricate(:app, account: account, handle: 'app',
149
160
  last_deploy_operation: op)
150
161
  allow(Aptible::Api::Account).to receive(:all).and_return([account])
162
+ allow(Aptible::Api::App).to receive(:all).and_return([app])
151
163
 
152
164
  expected_json = [
153
165
  {
@@ -9,9 +9,11 @@ describe Aptible::CLI::Agent do
9
9
 
10
10
  before do
11
11
  allow(Aptible::Api::App).to receive(:all)
12
- .with(token: token).and_return([app])
12
+ .with(token: token, href: '/apps?per_page=5000&no_embed=true')
13
+ .and_return([app])
13
14
  allow(Aptible::Api::Account).to receive(:all)
14
- .with(token: token).and_return([account])
15
+ .with(token: token, href: '/apps?per_page=5000&no_embed=true')
16
+ .and_return([account])
15
17
  end
16
18
 
17
19
  before { allow(subject).to receive(:options) { { app: app.handle } } }
@@ -269,6 +269,7 @@ describe Aptible::CLI::Agent do
269
269
  staging = Fabricate(:account, handle: 'staging')
270
270
  prod = Fabricate(:account, handle: 'production')
271
271
 
272
+ dbs = []
272
273
  [
273
274
  [staging, 'staging-redis-db'],
274
275
  [staging, 'staging-postgres-db'],
@@ -276,12 +277,17 @@ describe Aptible::CLI::Agent do
276
277
  [prod, 'prod-postgres-db']
277
278
  ].each do |a, h|
278
279
  d = Fabricate(:database, account: a, handle: h)
280
+ dbs << d
279
281
  Fabricate(:database_credential, database: d)
280
282
  end
281
283
 
282
284
  token = 'the-token'
283
285
  allow(subject).to receive(:fetch_token) { token }
284
- allow(Aptible::Api::Account).to receive(:all).with(token: token)
286
+ allow(Aptible::Api::Database).to receive(:all)
287
+ .with(token: token, href: '/databases?per_page=5000&no_embed=true')
288
+ .and_return(dbs)
289
+ allow(Aptible::Api::Account).to receive(:all)
290
+ .with(token: token, href: '/accounts?per_page=5000&no_embed=true')
285
291
  .and_return([staging, prod])
286
292
  end
287
293