aptible-cli 0.5.12 → 0.5.13

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
  SHA1:
3
- metadata.gz: 3b91df96ab6a1f0df93fa8c72e66c6a6a5099e71
4
- data.tar.gz: b1eaf8c6e6d4977757d69056257ebb127bba4b62
3
+ metadata.gz: afe6307751ef50d084ce1b378adc2f94b203c289
4
+ data.tar.gz: 99a3c232ebef3b35e327f958fc4c61628ef6639b
5
5
  SHA512:
6
- metadata.gz: 0c464c35948b299c8ea1dbdba6eb6aaa09ecdee76410b7e9ea80337fbbc9fc25c0b1cf5c53e400cd0aa810933b585230beb1bbdd9684531c1f15db3d09d248a7
7
- data.tar.gz: a8b6e992a70e29e3fcb5ec9682d1527ab11b72f13f2b19732d4b90420adbe9db2a8e5b5b83f5e950adcdf10aaa6b330761f08d66d3821b69ca68325bad5df402
6
+ metadata.gz: 7f6b5177638c5c3a69215e8bee64e7d560fd22cae00db83112b51b0f53098c2737a92dbf666817b6d0689d513c0d27533e642d9af2a8fb06ed3a981afe30d0b7
7
+ data.tar.gz: 5f7ed6c2a95c266fe018a7fcb026f5b6ad21d28d005a86b4e013c8eefc4a9d47b3ad4e3d401bdcce72410279cc8624c7934a2cfee19c4471649e68d2ec02b39c
@@ -32,6 +32,11 @@ module Aptible
32
32
  include Subcommands::Restart
33
33
  include Subcommands::SSH
34
34
 
35
+ # Forward return codes on failures.
36
+ def self.exit_on_failure?
37
+ true
38
+ end
39
+
35
40
  desc 'version', 'Print Aptible CLI version'
36
41
  def version
37
42
  puts "aptible-cli v#{Aptible::CLI::VERSION}"
@@ -19,6 +19,23 @@ module Aptible
19
19
  operation.get
20
20
  end
21
21
  end
22
+
23
+ def attach_to_operation_logs(operation)
24
+ host = operation.resource.account.bastion_host
25
+ port = operation.resource.account.dumptruck_port
26
+
27
+ set_env('ACCESS_TOKEN', fetch_token)
28
+ set_env('APTIBLE_OPERATION', operation.id.to_s)
29
+ set_env('APTIBLE_CLI_COMMAND', 'oplog')
30
+
31
+ opts = " -o 'SendEnv=*' -o StrictHostKeyChecking=no " \
32
+ '-o UserKnownHostsFile=/dev/null -o LogLevel=quiet'
33
+ result = Kernel.system "ssh #{opts} -p #{port} root@#{host}"
34
+ # If Dumptruck is down, fall back to polling for success. If the
35
+ # operation failed, poll_for_success will immediately fall through to
36
+ # the error message.
37
+ poll_for_success(operation) unless result
38
+ end
22
39
  end
23
40
  end
24
41
  end
@@ -45,8 +45,7 @@ module Aptible
45
45
  app = ensure_app(options)
46
46
  service = app.services.find { |s| s.process_type == type }
47
47
  op = service.create_operation(type: 'scale', container_count: num)
48
- poll_for_success(op)
49
- say "Scaled #{app.handle} to #{num} instances."
48
+ attach_to_operation_logs(op)
50
49
  end
51
50
 
52
51
  option :app
@@ -28,7 +28,7 @@ module Aptible
28
28
  env = Hash[args.map { |arg| arg.split('=', 2) }]
29
29
  operation = app.create_operation(type: 'configure', env: env)
30
30
  puts 'Updating configuration and restarting app...'
31
- poll_for_success(operation)
31
+ attach_to_operation_logs(operation)
32
32
  end
33
33
 
34
34
  desc 'config:set', 'Alias for config:add'
@@ -47,7 +47,7 @@ module Aptible
47
47
  env = Hash[args.map { |arg| [arg, ''] }]
48
48
  operation = app.create_operation(type: 'configure', env: env)
49
49
  puts 'Updating configuration and restarting app...'
50
- poll_for_success(operation)
50
+ attach_to_operation_logs(operation)
51
51
  end
52
52
 
53
53
  desc 'config:unset', 'Alias for config:rm'
@@ -14,7 +14,7 @@ module Aptible
14
14
  app = ensure_app(options)
15
15
  operation = app.create_operation(type: 'rebuild')
16
16
  puts 'Rebuilding app...'
17
- poll_for_success(operation)
17
+ attach_to_operation_logs(operation)
18
18
  end
19
19
  end
20
20
  end
@@ -14,7 +14,7 @@ module Aptible
14
14
  app = ensure_app(options)
15
15
  operation = app.create_operation(type: 'restart')
16
16
  puts 'Restarting app...'
17
- poll_for_success(operation)
17
+ attach_to_operation_logs(operation)
18
18
  end
19
19
  end
20
20
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module CLI
3
- VERSION = '0.5.12'
3
+ VERSION = '0.5.13'
4
4
  end
5
5
  end
@@ -10,21 +10,29 @@ end
10
10
  class Operation < OpenStruct
11
11
  end
12
12
 
13
+ class Account < OpenStruct
14
+ end
15
+
13
16
  describe Aptible::CLI::Agent do
14
17
  before { subject.stub(:ask) }
15
18
  before { subject.stub(:save_token) }
16
19
  before { subject.stub(:fetch_token) { double 'token' } }
20
+ before { subject.stub(:attach_to_operation_logs) }
17
21
 
18
22
  let(:service) { Service.new(process_type: 'web') }
19
23
  let(:op) { Operation.new(status: 'succeeded') }
20
- let(:apps) { [App.new(handle: 'hello', services: [service])] }
24
+ let(:account) { Account.new(bastion_host: 'localhost', dumptruck_port: 1234) }
25
+ let(:apps) do
26
+ [App.new(handle: 'hello', services: [service], account: account)]
27
+ end
21
28
 
22
29
  describe '#apps:scale' do
23
30
  it 'should pass given correct parameters' do
24
31
  allow(service).to receive(:create_operation) { op }
25
32
  allow(subject).to receive(:options) { { app: 'hello' } }
26
-
33
+ allow(op).to receive(:resource) { apps.first }
27
34
  allow(Aptible::Api::App).to receive(:all) { apps }
35
+
28
36
  subject.send('apps:scale', 'web', 3)
29
37
  end
30
38
 
@@ -40,8 +48,8 @@ describe Aptible::CLI::Agent do
40
48
  it 'should fail if number is not a valid number' do
41
49
  allow(service).to receive(:create_operation) { op }
42
50
  allow(subject).to receive(:options) { { app: 'hello' } }
43
-
44
51
  allow(Aptible::Api::App).to receive(:all) { apps }
52
+
45
53
  expect do
46
54
  subject.send('apps:scale', 'web', 'potato')
47
55
  end.to raise_error(ArgumentError)
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.5.12
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-06 00:00:00.000000000 Z
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aptible-api
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.4.5
213
+ rubygems_version: 2.2.2
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Command-line interface for Aptible services