aptible-cli 0.19.0 → 0.19.1

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: ee325f4c1746513670e64830cd10d8856fc39cc96e836c8f822e4c34ed6c45ea
4
- data.tar.gz: 0dab373981390ea9d3429a6f0f43634eef13285bd090542329866bb1ff24620c
3
+ metadata.gz: 8984c4633a4c6cfa79a8cba5fa5856079e4388677a4a6726f55eab3506ba82b5
4
+ data.tar.gz: d593ebd83e743458ea09ea1ffea94bf76679d6a10d12091d0f044701f85e4f5b
5
5
  SHA512:
6
- metadata.gz: 27fb8c12ceb02f977f29777bd418a2aa943c754d6b8cdc6a37ee55995bbe4a45dea9683c7191b4529017484b37dd3ef6dfcd3f2d70d2010ea032a0d1199409fd
7
- data.tar.gz: b30888eb2d2855b388d04013eca773f4e69f77734c92aeee442499e7a266708c5a85800e0552ad0e739a40d1beb41956babcc4a2b9a0483d12be86939ac95c32
6
+ metadata.gz: cc247fe45bb6ec934de142e4ca51e19c369a792ac92defc717b91436b293bb80c3fbbedeebc03efe4dd3cda4e3e983f8c53e95d8da5b30de53dc684bdd2d1a5e
7
+ data.tar.gz: ac409bc0d1e171f48f1a72035f31e8a69edc9b69e8aa586f6fcc70d52628ff698bc499f21e7b90fd38749b9779473ad6a9701606a843848217b1b3b732551f2c
data/README.md CHANGED
@@ -57,6 +57,7 @@ Commands:
57
57
  aptible db:versions # List available database versions
58
58
  aptible deploy [OPTIONS] [VAR1=VAL1] [VAR2=VAL2] [...] # Deploy an app
59
59
  aptible endpoints:database:create DATABASE # Create a Database Endpoint
60
+ aptible endpoints:database:modify --database DATABASE ENDPOINT_HOSTNAME # Modify a Database Endpoint
60
61
  aptible endpoints:deprovision [--app APP | --database DATABASE] ENDPOINT_HOSTNAME # Deprovision an App or Database Endpoint
61
62
  aptible endpoints:https:create [--app APP] SERVICE # Create an App HTTPS Endpoint
62
63
  aptible endpoints:https:modify [--app APP] ENDPOINT_HOSTNAME # Modify an App HTTPS Endpoint
@@ -80,9 +81,9 @@ Commands:
80
81
  aptible log_drain:list # List all Log Drains
81
82
  aptible login # Log in to Aptible
82
83
  aptible logs [--app APP | --database DATABASE] # Follows logs from a running app or database
83
- aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --environment ENVIRONMENT # Create a Datadog Metric Drain
84
+ aptible metric_drain:create:datadog HANDLE --api_key DATADOG_API_KEY --site DATADOG_SITE --environment ENVIRONMENT # Create a Datadog Metric Drain
84
85
  aptible metric_drain:create:influxdb HANDLE --db DATABASE_HANDLE --environment ENVIRONMENT # Create an InfluxDB Metric Drain
85
- aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT # Create an InfluxDB Metric Drain
86
+ aptible metric_drain:create:influxdb:custom HANDLE --username USERNAME --password PASSWORD --url URL_INCLUDING_PORT --db INFLUX_DATABASE_NAME --environment ENVIRONMENT # Create an InfluxDB Metric Drain
86
87
  aptible metric_drain:deprovision HANDLE --environment ENVIRONMENT # Deprovisions a Metric Drain
87
88
  aptible metric_drain:list # List all Metric Drains
88
89
  aptible operation:cancel OPERATION_ID # Cancel a running operation
@@ -22,7 +22,9 @@ module Aptible
22
22
  thor.instance_exec(self) do |builder|
23
23
  option :environment
24
24
 
25
- if builder.app?
25
+ if builder.database?
26
+ option :database
27
+ elsif builder.app?
26
28
  app_options
27
29
 
28
30
  if builder.create?
@@ -32,11 +34,6 @@ module Aptible
32
34
  desc: 'Enable Default Domain on this Endpoint'
33
35
  )
34
36
 
35
- option(
36
- :internal,
37
- type: :boolean,
38
- desc: 'Restrict this Endpoint to internal traffic'
39
- )
40
37
  end
41
38
 
42
39
  if builder.ports?
@@ -56,6 +53,14 @@ module Aptible
56
53
  end
57
54
  end
58
55
 
56
+ if builder.create?
57
+ option(
58
+ :internal,
59
+ type: :boolean,
60
+ desc: 'Restrict this Endpoint to internal traffic'
61
+ )
62
+ end
63
+
59
64
  option(
60
65
  :ip_whitelist,
61
66
  type: :array,
@@ -151,6 +156,12 @@ module Aptible
151
156
  end
152
157
 
153
158
  options.delete(:app)
159
+ elsif database?
160
+ params[:internal] = options.delete(:internal) do
161
+ create? ? false : nil
162
+ end
163
+
164
+ options.delete(:database)
154
165
  else
155
166
  params[:internal] = false
156
167
  end
@@ -33,6 +33,22 @@ module Aptible
33
33
  provision_vhost_and_explain(service, vhost)
34
34
  end
35
35
 
36
+ database_modify_flags = Helpers::Vhost::OptionSetBuilder.new do
37
+ database!
38
+ end
39
+
40
+ desc 'endpoints:database:modify --database DATABASE ' \
41
+ 'ENDPOINT_HOSTNAME',
42
+ 'Modify a Database Endpoint'
43
+ database_modify_flags.declare_options(self)
44
+ define_method 'endpoints:database:modify' do |hostname|
45
+ database = ensure_database(options.merge(db: options[:database]))
46
+ vhost = find_vhost(each_service(database), hostname)
47
+ vhost.update!(**database_modify_flags.prepare(database.account,
48
+ options))
49
+ provision_vhost_and_explain(vhost.service, vhost)
50
+ end
51
+
36
52
  tcp_create_flags = Helpers::Vhost::OptionSetBuilder.new do
37
53
  app!
38
54
  create!
@@ -55,7 +55,9 @@ module Aptible
55
55
 
56
56
  desc 'metric_drain:create:influxdb:custom HANDLE '\
57
57
  '--username USERNAME --password PASSWORD ' \
58
- '--url URL_INCLUDING_PORT',
58
+ '--url URL_INCLUDING_PORT ' \
59
+ '--db INFLUX_DATABASE_NAME ' \
60
+ '--environment ENVIRONMENT',
59
61
  'Create an InfluxDB Metric Drain'
60
62
  option :db, type: :string
61
63
  option :username, type: :string
@@ -82,7 +84,9 @@ module Aptible
82
84
  end
83
85
 
84
86
  desc 'metric_drain:create:datadog HANDLE '\
85
- '--api_key DATADOG_API_KEY --environment ENVIRONMENT',
87
+ '--api_key DATADOG_API_KEY '\
88
+ '--site DATADOG_SITE ' \
89
+ '--environment ENVIRONMENT',
86
90
  'Create a Datadog Metric Drain'
87
91
  option :api_key, type: :string
88
92
  option :site, type: :string
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.19.0'.freeze
3
+ VERSION = '0.19.1'.freeze
4
4
  end
5
5
  end
@@ -94,6 +94,45 @@ describe Aptible::CLI::Agent do
94
94
  stub_options(ip_whitelist: %w(1.1.1.1))
95
95
  subject.send('endpoints:database:create', 'mydb')
96
96
  end
97
+
98
+ it 'creates an internal Database Endpoint' do
99
+ expect_create_vhost(db.service, internal: true)
100
+ stub_options(internal: true)
101
+ subject.send('endpoints:database:create', 'mydb')
102
+ end
103
+ end
104
+
105
+ describe 'endpoints:database:modify' do
106
+ it 'does not change anything if no options are passed' do
107
+ v = Fabricate(:vhost, service: db.service)
108
+ expect_modify_vhost(v, {})
109
+ stub_options(database: 'mydb')
110
+ subject.send('endpoints:database:modify', v.external_host)
111
+ end
112
+
113
+ it 'adds an IP whitelist' do
114
+ v = Fabricate(:vhost, service: db.service)
115
+ expect_modify_vhost(v, ip_whitelist: %w(1.1.1.1))
116
+
117
+ stub_options(database: 'mydb', ip_whitelist: %w(1.1.1.1))
118
+ subject.send('endpoints:database:modify', v.external_host)
119
+ end
120
+
121
+ it 'removes an IP whitelist' do
122
+ v = Fabricate(:vhost, service: db.service)
123
+ expect_modify_vhost(v, ip_whitelist: [])
124
+
125
+ stub_options(database: 'mydb', :'no-ip_whitelist' => true)
126
+ subject.send('endpoints:database:modify', v.external_host)
127
+ end
128
+
129
+ it 'does not allow disabling and adding an IP whitelist' do
130
+ v = Fabricate(:vhost, service: db.service)
131
+ stub_options(database: 'mydb', ip_whitelist: %w(1.1.1.1),
132
+ :'no-ip_whitelist' => true)
133
+ expect { subject.send('endpoints:database:modify', v.external_host) }
134
+ .to raise_error(/conflicting.*no-ip-whitelist.*ip-whitelist/im)
135
+ end
97
136
  end
98
137
 
99
138
  describe 'endpoints:list' do
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.0
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-27 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-resource