aptible-cli 0.26.2 → 0.26.5
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 +4 -4
- data/.rubocop.yml +5 -0
- data/Gemfile.lock +1 -1
- data/lib/aptible/cli/agent.rb +7 -4
- data/lib/aptible/cli/helpers/app.rb +29 -16
- data/lib/aptible/cli/helpers/database.rb +49 -32
- data/lib/aptible/cli/helpers/environment.rb +5 -4
- data/lib/aptible/cli/helpers/log_drain.rb +3 -1
- data/lib/aptible/cli/helpers/metric_drain.rb +3 -1
- data/lib/aptible/cli/resource_formatter.rb +14 -1
- data/lib/aptible/cli/subcommands/backup.rb +1 -1
- data/lib/aptible/cli/subcommands/config.rb +2 -2
- data/lib/aptible/cli/subcommands/db.rb +4 -3
- data/lib/aptible/cli/subcommands/log_drain.rb +2 -0
- data/lib/aptible/cli/subcommands/logs.rb +5 -5
- data/lib/aptible/cli/subcommands/metric_drain.rb +2 -0
- data/lib/aptible/cli/version.rb +1 -1
- data/lib/aptible/cli.rb +14 -0
- data/spec/aptible/cli/subcommands/apps_spec.rb +34 -21
- data/spec/aptible/cli/subcommands/backup_retention_policy_spec.rb +3 -1
- data/spec/aptible/cli/subcommands/backup_spec.rb +28 -3
- data/spec/aptible/cli/subcommands/config_spec.rb +11 -3
- data/spec/aptible/cli/subcommands/db_spec.rb +49 -95
- data/spec/aptible/cli/subcommands/deploy_spec.rb +8 -3
- data/spec/aptible/cli/subcommands/endpoints_spec.rb +20 -4
- data/spec/aptible/cli/subcommands/environment_spec.rb +4 -0
- data/spec/aptible/cli/subcommands/log_drain_spec.rb +15 -0
- data/spec/aptible/cli/subcommands/logs_spec.rb +16 -4
- data/spec/aptible/cli/subcommands/maintenance_spec.rb +7 -2
- data/spec/aptible/cli/subcommands/metric_drain_spec.rb +14 -2
- data/spec/aptible/cli/subcommands/services_spec.rb +3 -4
- data/spec/fabricators/account_fabricator.rb +9 -1
- data/spec/fabricators/app_external_aws_rds_connection_fabricator.rb +1 -1
- data/spec/fabricators/app_fabricator.rb +1 -1
- data/spec/fabricators/backup_fabricator.rb +1 -1
- data/spec/fabricators/backup_retention_policy_fabricator.rb +1 -1
- data/spec/fabricators/certificate_fabricator.rb +1 -1
- data/spec/fabricators/configuration_fabricator.rb +1 -1
- data/spec/fabricators/database_credential_fabricator.rb +1 -1
- data/spec/fabricators/database_disk_fabricator.rb +1 -1
- data/spec/fabricators/database_fabricator.rb +10 -1
- data/spec/fabricators/database_image_fabricator.rb +1 -1
- data/spec/fabricators/external_aws_account_fabricator.rb +1 -1
- data/spec/fabricators/external_aws_database_credential_fabricator.rb +1 -1
- data/spec/fabricators/external_aws_resource_fabricator.rb +1 -1
- data/spec/fabricators/log_drain_fabricator.rb +1 -1
- data/spec/fabricators/maintenance_app_fabricator.rb +1 -1
- data/spec/fabricators/maintenance_database_fabricator.rb +1 -1
- data/spec/fabricators/metric_drain_fabricator.rb +15 -1
- data/spec/fabricators/operation_fabricator.rb +1 -1
- data/spec/fabricators/service_fabricator.rb +1 -1
- data/spec/fabricators/service_sizing_policy_fabricator.rb +1 -1
- data/spec/fabricators/stack_fabricator.rb +1 -1
- data/spec/fabricators/vhost_fabricator.rb +1 -1
- data/spec/spec_helper.rb +7 -0
- data/spec/support/stub_aptible_resource.rb +25 -0
- metadata +5 -2
|
@@ -14,9 +14,17 @@ describe Aptible::CLI::Agent do
|
|
|
14
14
|
.with(token: token, href: '/metric_drains?per_page=5000')
|
|
15
15
|
.and_return([metric_drain])
|
|
16
16
|
|
|
17
|
+
allow(Aptible::Api::MetricDrain).to receive(:all)
|
|
18
|
+
.with(token: token, href: "/accounts/#{account.id}/metric_drains")
|
|
19
|
+
.and_return([metric_drain])
|
|
20
|
+
|
|
17
21
|
allow(Aptible::Api::Account).to receive(:all)
|
|
18
22
|
.with(token: token, href: '/accounts?per_page=5000&no_embed=true')
|
|
19
23
|
.and_return([account])
|
|
24
|
+
|
|
25
|
+
allow(Aptible::Api::Account).to receive(:find_by_url)
|
|
26
|
+
.with("/find/account?handle=#{account.handle}", token: token)
|
|
27
|
+
.and_return(account)
|
|
20
28
|
end
|
|
21
29
|
|
|
22
30
|
describe '#metric_drain:list' do
|
|
@@ -53,8 +61,6 @@ describe Aptible::CLI::Agent do
|
|
|
53
61
|
it 'lists metric drains for a single account with --environment' do
|
|
54
62
|
other_account = Fabricate(:account)
|
|
55
63
|
Fabricate(:metric_drain, handle: 'test2', account: other_account)
|
|
56
|
-
accounts = [account, other_account]
|
|
57
|
-
allow(Aptible::Api::Account).to receive(:all).and_return(accounts)
|
|
58
64
|
|
|
59
65
|
subject.options = { environment: account.handle }
|
|
60
66
|
subject.send('metric_drain:list')
|
|
@@ -82,6 +88,12 @@ describe Aptible::CLI::Agent do
|
|
|
82
88
|
context 'influxdb' do
|
|
83
89
|
let(:db) { Fabricate(:database, account: account, id: 5) }
|
|
84
90
|
|
|
91
|
+
before do
|
|
92
|
+
allow(Aptible::Api::Database).to receive(:find_by_url)
|
|
93
|
+
.with("/find/database?handle=#{db.handle}&environment=#{db.account.handle}", token: token)
|
|
94
|
+
.and_return(db)
|
|
95
|
+
end
|
|
96
|
+
|
|
85
97
|
it 'creates a new InfluxDB metric drain' do
|
|
86
98
|
opts = {
|
|
87
99
|
handle: 'test-influxdb',
|
|
@@ -6,10 +6,9 @@ describe Aptible::CLI::Agent do
|
|
|
6
6
|
|
|
7
7
|
before do
|
|
8
8
|
allow(subject).to receive(:fetch_token) { token }
|
|
9
|
-
allow(Aptible::Api::App)
|
|
10
|
-
.
|
|
11
|
-
.
|
|
12
|
-
.and_return([app])
|
|
9
|
+
allow(Aptible::Api::App).to receive(:find_by_url)
|
|
10
|
+
.with("/find/app?handle=#{app.handle}", token: token)
|
|
11
|
+
.and_return(app)
|
|
13
12
|
end
|
|
14
13
|
|
|
15
14
|
describe '#services' do
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class StubAccount <
|
|
1
|
+
class StubAccount < StubAptibleResource
|
|
2
2
|
def each_app(&block)
|
|
3
3
|
return enum_for(:each_app) if block.nil?
|
|
4
4
|
apps.each(&block)
|
|
@@ -34,6 +34,14 @@ Fabricator(:account, from: :stub_account) do
|
|
|
34
34
|
hash = {
|
|
35
35
|
self: OpenStruct.new(
|
|
36
36
|
href: "/accounts/#{attrs[:id]}"
|
|
37
|
+
),
|
|
38
|
+
metric_drains: OpenStruct.new(
|
|
39
|
+
base_href: "/accounts/#{attrs[:id]}/metric_drains",
|
|
40
|
+
href: "/accounts/#{attrs[:id]}/metric_drains"
|
|
41
|
+
),
|
|
42
|
+
log_drains: OpenStruct.new(
|
|
43
|
+
base_href: "/accounts/#{attrs[:id]}/log_drains",
|
|
44
|
+
href: "/accounts/#{attrs[:id]}/log_drains"
|
|
37
45
|
)
|
|
38
46
|
}
|
|
39
47
|
OpenStruct.new(hash)
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
class StubDatabase <
|
|
1
|
+
class StubDatabase < StubAptibleResource
|
|
2
2
|
def provisioned?
|
|
3
3
|
status == 'provisioned'
|
|
4
4
|
end
|
|
5
|
+
|
|
6
|
+
def objects
|
|
7
|
+
{
|
|
8
|
+
'database_credentials' => database_credentials
|
|
9
|
+
}
|
|
10
|
+
end
|
|
5
11
|
end
|
|
6
12
|
|
|
7
13
|
Fabricator(:database, from: :stub_database) do
|
|
@@ -23,6 +29,9 @@ Fabricator(:database, from: :stub_database) do
|
|
|
23
29
|
hash = {
|
|
24
30
|
account: OpenStruct.new(
|
|
25
31
|
href: "/accounts/#{attrs[:account].id}"
|
|
32
|
+
),
|
|
33
|
+
database_credentials: OpenStruct.new(
|
|
34
|
+
href: "/databases/#{attrs[:handle]}/database_credentials"
|
|
26
35
|
)
|
|
27
36
|
}
|
|
28
37
|
OpenStruct.new(hash)
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
class StubMetricDrain <
|
|
1
|
+
class StubMetricDrain < StubAptibleResource
|
|
2
|
+
def attributes
|
|
3
|
+
# Don't blame me, I'm just following the example in StubLogDrain,
|
|
4
|
+
# see the comment there.
|
|
5
|
+
{
|
|
6
|
+
'drain_configuration' => drain_configuration
|
|
7
|
+
}
|
|
8
|
+
end
|
|
9
|
+
end
|
|
2
10
|
|
|
3
11
|
Fabricator(:metric_drain, from: :stub_metric_drain) do
|
|
4
12
|
id { sequence(:metric_drain_id) }
|
|
13
|
+
drain_configuration do
|
|
14
|
+
{
|
|
15
|
+
'api_key' => 'asdf',
|
|
16
|
+
'series_url' => 'https://localhost.aptible.in/api/v1/series'
|
|
17
|
+
}
|
|
18
|
+
end
|
|
5
19
|
account
|
|
6
20
|
links do |attrs|
|
|
7
21
|
hash = {
|
data/spec/spec_helper.rb
CHANGED
|
@@ -8,6 +8,11 @@ Dir["#{File.dirname(__FILE__)}/shared/**/*.rb"].each do |file|
|
|
|
8
8
|
require file
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
# Load support files (shared classes used by fabricators, etc.)
|
|
12
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |file|
|
|
13
|
+
require file
|
|
14
|
+
end
|
|
15
|
+
|
|
11
16
|
# Require library up front
|
|
12
17
|
require 'aptible/cli'
|
|
13
18
|
|
|
@@ -76,6 +81,8 @@ module SpecHarness
|
|
|
76
81
|
end
|
|
77
82
|
|
|
78
83
|
RSpec.configure do |config|
|
|
84
|
+
config.example_status_persistence_file_path = 'spec/reports/examples.txt'
|
|
85
|
+
|
|
79
86
|
config.before(:each) do
|
|
80
87
|
reset_spec_harness
|
|
81
88
|
begin
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
class StubAptibleResource < OpenStruct
|
|
2
|
+
def headers
|
|
3
|
+
@headers ||= {}
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def find_by_url(_url)
|
|
7
|
+
self
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def href
|
|
11
|
+
self[:href] || "/#{self.class.resource_path}/#{id}"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.resource_path
|
|
15
|
+
name = to_s.sub(/^Stub/, '')
|
|
16
|
+
snake = name.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
|
17
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
|
18
|
+
.downcase
|
|
19
|
+
if snake.end_with?('y')
|
|
20
|
+
snake.sub(/y$/, 'ies')
|
|
21
|
+
else
|
|
22
|
+
"#{snake}s"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
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.26.
|
|
4
|
+
version: 0.26.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Frank Macreery
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-03-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -478,6 +478,7 @@ files:
|
|
|
478
478
|
- ".github/workflows/test.yml"
|
|
479
479
|
- ".gitignore"
|
|
480
480
|
- ".rspec"
|
|
481
|
+
- ".rubocop.yml"
|
|
481
482
|
- Dockerfile
|
|
482
483
|
- Gemfile
|
|
483
484
|
- Gemfile.lock
|
|
@@ -619,6 +620,7 @@ files:
|
|
|
619
620
|
- spec/script/ssh-spawn
|
|
620
621
|
- spec/shared/mock_ssh_context.rb
|
|
621
622
|
- spec/spec_helper.rb
|
|
623
|
+
- spec/support/stub_aptible_resource.rb
|
|
622
624
|
homepage: https://github.com/aptible/aptible-cli
|
|
623
625
|
licenses:
|
|
624
626
|
- MIT
|
|
@@ -712,3 +714,4 @@ test_files:
|
|
|
712
714
|
- spec/script/ssh-spawn
|
|
713
715
|
- spec/shared/mock_ssh_context.rb
|
|
714
716
|
- spec/spec_helper.rb
|
|
717
|
+
- spec/support/stub_aptible_resource.rb
|