aptible-cli 0.6.4 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/lib/aptible/cli/helpers/token.rb +6 -2
- data/lib/aptible/cli/subcommands/apps.rb +21 -1
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/subcommands/apps_spec.rb +65 -3
- data/spec/aptible/cli/subcommands/domains_spec.rb +14 -2
- data/spec/spec_helper.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5476287949f6306971e1400683283f93a8a07d5f
|
4
|
+
data.tar.gz: 8e1f9600ebc7787553c8c11e02b35dd80ae5af47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f63a2b3abaa73cfe3b61fcad53ad1701279e33ae7d2991646dbc1d997c6b5d8049f2e6515d2b79290e369ef5ce02195f6a30293e6439aae3a16e95685d862500
|
7
|
+
data.tar.gz: 1dcfcaad6fd98538bea9a3772c505ee4331d3016ead7ccf4fa42c41e957841617a91c13a1e8a57e3f2f483b79821c06ac37fc9a219e968d5b8cc0230315ecac0
|
data/Gemfile
CHANGED
@@ -4,10 +4,14 @@ module Aptible
|
|
4
4
|
module CLI
|
5
5
|
module Helpers
|
6
6
|
module Token
|
7
|
+
TOKEN_ENV_VAR = 'APTIBLE_ACCESS_TOKEN'
|
8
|
+
|
7
9
|
def fetch_token
|
8
|
-
@token ||=
|
10
|
+
@token ||= ENV[TOKEN_ENV_VAR] ||
|
11
|
+
current_token_hash[Aptible::Auth.configuration.root_url]
|
9
12
|
return @token if @token
|
10
|
-
fail Thor::Error, 'Could not read token: please run aptible login'
|
13
|
+
fail Thor::Error, 'Could not read token: please run aptible login ' \
|
14
|
+
"or set #{TOKEN_ENV_VAR}"
|
11
15
|
end
|
12
16
|
|
13
17
|
def save_token(token)
|
@@ -35,11 +35,31 @@ module Aptible
|
|
35
35
|
|
36
36
|
desc 'apps:scale TYPE NUMBER', 'Scale app to NUMBER of instances'
|
37
37
|
app_options
|
38
|
+
option :size, type: :numeric, enum: [512,
|
39
|
+
1024,
|
40
|
+
2048,
|
41
|
+
4096,
|
42
|
+
8192,
|
43
|
+
16384,
|
44
|
+
32768,
|
45
|
+
65536]
|
38
46
|
define_method 'apps:scale' do |type, n|
|
39
47
|
num = Integer(n)
|
40
48
|
app = ensure_app(options)
|
41
49
|
service = app.services.find { |s| s.process_type == type }
|
42
|
-
|
50
|
+
if service.nil?
|
51
|
+
valid_types = if app.services.empty?
|
52
|
+
'NONE (deploy the app first)'
|
53
|
+
else
|
54
|
+
app.services.map(&:process_type).join(', ')
|
55
|
+
end
|
56
|
+
fail Thor::Error, "Service with type #{type} does not " \
|
57
|
+
"exist for app #{app.handle}. Valid " \
|
58
|
+
"types: #{valid_types}."
|
59
|
+
end
|
60
|
+
op = service.create_operation(type: 'scale',
|
61
|
+
container_count: num,
|
62
|
+
container_size: options[:size])
|
43
63
|
attach_to_operation_logs(op)
|
44
64
|
end
|
45
65
|
|
data/lib/aptible/cli/version.rb
CHANGED
@@ -26,22 +26,49 @@ describe Aptible::CLI::Agent do
|
|
26
26
|
dumptruck_port: 1234,
|
27
27
|
handle: 'aptible')
|
28
28
|
end
|
29
|
+
let(:services) { [service] }
|
29
30
|
let(:apps) do
|
30
|
-
[App.new(handle: 'hello', services:
|
31
|
+
[App.new(handle: 'hello', services: services, account: account)]
|
31
32
|
end
|
32
33
|
|
33
34
|
describe '#apps:scale' do
|
34
35
|
it 'should pass given correct parameters' do
|
35
36
|
allow(service).to receive(:create_operation) { op }
|
36
|
-
allow(subject).to receive(:options)
|
37
|
+
allow(subject).to receive(:options) do
|
38
|
+
{ app: 'hello', environment: 'foobar' }
|
39
|
+
end
|
37
40
|
allow(op).to receive(:resource) { apps.first }
|
38
41
|
allow(Aptible::Api::App).to receive(:all) { apps }
|
39
42
|
|
43
|
+
expect(subject).to receive(:environment_from_handle)
|
44
|
+
.with('foobar')
|
45
|
+
.and_return(account)
|
46
|
+
expect(subject).to receive(:apps_from_handle).and_return(apps)
|
47
|
+
subject.send('apps:scale', 'web', 3)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should pass container size param to operation if given' do
|
51
|
+
expect(service).to receive(:create_operation)
|
52
|
+
.with(type: 'scale', container_count: 3, container_size: 90210)
|
53
|
+
.and_return(op)
|
54
|
+
allow(subject).to receive(:options) do
|
55
|
+
{ app: 'hello', size: 90210, environment: 'foobar' }
|
56
|
+
end
|
57
|
+
|
58
|
+
allow(op).to receive(:resource) { apps.first }
|
59
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
60
|
+
|
61
|
+
expect(subject).to receive(:environment_from_handle)
|
62
|
+
.with('foobar')
|
63
|
+
.and_return(account)
|
64
|
+
expect(subject).to receive(:apps_from_handle).and_return(apps)
|
40
65
|
subject.send('apps:scale', 'web', 3)
|
41
66
|
end
|
42
67
|
|
43
68
|
it 'should fail if environment is non-existent' do
|
44
|
-
allow(subject).to receive(:options)
|
69
|
+
allow(subject).to receive(:options) do
|
70
|
+
{ environment: 'foo', app: 'web' }
|
71
|
+
end
|
45
72
|
allow(service).to receive(:create_operation) { op }
|
46
73
|
allow(Aptible::Api::Account).to receive(:all) { [] }
|
47
74
|
allow(account).to receive(:apps) { [apps] }
|
@@ -70,5 +97,40 @@ describe Aptible::CLI::Agent do
|
|
70
97
|
subject.send('apps:scale', 'web', 'potato')
|
71
98
|
end.to raise_error(ArgumentError)
|
72
99
|
end
|
100
|
+
|
101
|
+
it 'should fail if the service does not exist' do
|
102
|
+
allow(subject).to receive(:options) do
|
103
|
+
{ app: 'hello', environment: 'foobar' }
|
104
|
+
end
|
105
|
+
expect(subject).to receive(:environment_from_handle)
|
106
|
+
.with('foobar')
|
107
|
+
.and_return(account)
|
108
|
+
expect(subject).to receive(:apps_from_handle).and_return(apps)
|
109
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
110
|
+
|
111
|
+
expect do
|
112
|
+
subject.send('apps:scale', 'potato', 1)
|
113
|
+
end.to raise_error(Thor::Error, /Service.* potato.* does not exist/)
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'no service' do
|
117
|
+
let(:services) { [] }
|
118
|
+
|
119
|
+
it 'should fail if the app has no services' do
|
120
|
+
expect(subject).to receive(:environment_from_handle)
|
121
|
+
.with('foobar')
|
122
|
+
.and_return(account)
|
123
|
+
expect(subject).to receive(:apps_from_handle).and_return(apps)
|
124
|
+
allow(subject).to receive(:options) do
|
125
|
+
{ app: 'hello', environment: 'foobar' }
|
126
|
+
end
|
127
|
+
|
128
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
129
|
+
|
130
|
+
expect do
|
131
|
+
subject.send('apps:scale', 'web', 1)
|
132
|
+
end.to raise_error(Thor::Error, /deploy the app first/)
|
133
|
+
end
|
134
|
+
end
|
73
135
|
end
|
74
136
|
end
|
@@ -33,8 +33,14 @@ describe Aptible::CLI::Agent do
|
|
33
33
|
|
34
34
|
describe '#domains' do
|
35
35
|
it 'should print out the hostnames' do
|
36
|
+
expect(subject).to receive(:environment_from_handle)
|
37
|
+
.with('foobar')
|
38
|
+
.and_return(account)
|
39
|
+
expect(subject).to receive(:apps_from_handle).and_return(apps)
|
36
40
|
allow(service).to receive(:create_operation) { op }
|
37
|
-
allow(subject).to receive(:options)
|
41
|
+
allow(subject).to receive(:options) do
|
42
|
+
{ environment: 'foobar', app: 'web' }
|
43
|
+
end
|
38
44
|
allow(Aptible::Api::App).to receive(:all) { apps }
|
39
45
|
|
40
46
|
expect(app).to receive(:vhosts) { [vhost1, vhost2] }
|
@@ -65,8 +71,14 @@ describe Aptible::CLI::Agent do
|
|
65
71
|
end
|
66
72
|
|
67
73
|
it 'should print hostnames if -v is passed' do
|
74
|
+
expect(subject).to receive(:environment_from_handle)
|
75
|
+
.with('foobar')
|
76
|
+
.and_return(account)
|
77
|
+
expect(subject).to receive(:apps_from_handle).and_return(apps)
|
68
78
|
allow(service).to receive(:create_operation) { op }
|
69
|
-
allow(subject).to receive(:options)
|
79
|
+
allow(subject).to receive(:options) do
|
80
|
+
{ verbose: true, app: 'hello', environment: 'foobar' }
|
81
|
+
end
|
70
82
|
allow(Aptible::Api::App).to receive(:all) { apps }
|
71
83
|
|
72
84
|
expect(app).to receive(:vhosts) { [vhost1, vhost2] }
|
data/spec/spec_helper.rb
CHANGED
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.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Macreery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-api
|
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
200
200
|
version: '0'
|
201
201
|
requirements: []
|
202
202
|
rubyforge_project:
|
203
|
-
rubygems_version: 2.
|
203
|
+
rubygems_version: 2.4.5.1
|
204
204
|
signing_key:
|
205
205
|
specification_version: 4
|
206
206
|
summary: Command-line interface for Aptible services
|