aptible-cli 0.5.7 → 0.5.8
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/lib/aptible/cli/agent.rb +4 -1
- data/lib/aptible/cli/helpers/app.rb +2 -1
- data/lib/aptible/cli/helpers/env.rb +11 -0
- data/lib/aptible/cli/subcommands/apps.rb +12 -0
- data/lib/aptible/cli/subcommands/config.rb +1 -0
- data/lib/aptible/cli/subcommands/logs.rb +3 -1
- data/lib/aptible/cli/subcommands/ps.rb +35 -0
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/subcommands/apps_spec.rb +50 -0
- data/spec/aptible/cli/subcommands/ps_spec.rb +37 -0
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4b91444b0b662e1ab07c80526ba3f5054fd7ea6
|
4
|
+
data.tar.gz: f587f3803827f79e03f917134427cbad12aeff42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78a8eab1b55ba1e03c80eb102bece4876ac0f9dc873e551d552ee3a79e6a11610548cfc22fcc14e906f7149eb27bf41c0cb2aed94ce146f9dc0abdd0d9772bac
|
7
|
+
data.tar.gz: c44a10640e89b53dee298aa13044d2211ceeeaea3de1cc59173fd694b70f99be98c91e3af29bfdc2bc27e045a39ebd392772343976174453be6ce03d70d0e374
|
data/lib/aptible/cli/agent.rb
CHANGED
@@ -6,11 +6,13 @@ require_relative 'helpers/token'
|
|
6
6
|
require_relative 'helpers/operation'
|
7
7
|
require_relative 'helpers/account'
|
8
8
|
require_relative 'helpers/app'
|
9
|
+
require_relative 'helpers/env'
|
9
10
|
|
10
11
|
require_relative 'subcommands/apps'
|
11
12
|
require_relative 'subcommands/config'
|
12
13
|
require_relative 'subcommands/db'
|
13
14
|
require_relative 'subcommands/logs'
|
15
|
+
require_relative 'subcommands/ps'
|
14
16
|
require_relative 'subcommands/rebuild'
|
15
17
|
require_relative 'subcommands/restart'
|
16
18
|
require_relative 'subcommands/ssh'
|
@@ -24,10 +26,11 @@ module Aptible
|
|
24
26
|
include Subcommands::Apps
|
25
27
|
include Subcommands::Config
|
26
28
|
include Subcommands::DB
|
29
|
+
include Subcommands::Logs
|
30
|
+
include Subcommands::Ps
|
27
31
|
include Subcommands::Rebuild
|
28
32
|
include Subcommands::Restart
|
29
33
|
include Subcommands::SSH
|
30
|
-
include Subcommands::Tail
|
31
34
|
|
32
35
|
desc 'version', 'Print Aptible CLI version'
|
33
36
|
def version
|
@@ -8,8 +8,9 @@ module Aptible
|
|
8
8
|
include Helpers::Token
|
9
9
|
|
10
10
|
def ensure_app(options = {})
|
11
|
+
remote = options[:remote] || ENV['APTIBLE_REMOTE']
|
11
12
|
handle = options[:app] ||
|
12
|
-
handle_from_remote(
|
13
|
+
handle_from_remote(remote) ||
|
13
14
|
ensure_default_handle
|
14
15
|
app = app_from_handle(handle)
|
15
16
|
return app if app
|
@@ -37,6 +37,18 @@ module Aptible
|
|
37
37
|
say "App #{handle} created!"
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
desc 'apps:scale TYPE NUMBER', 'Scale app to NUMBER of instances'
|
42
|
+
option :app
|
43
|
+
option :account
|
44
|
+
define_method 'apps:scale' do |type, n|
|
45
|
+
num = Integer(n)
|
46
|
+
app = ensure_app(options)
|
47
|
+
service = app.services.find { |s| s.process_type == type }
|
48
|
+
op = service.create_operation(type: 'scale', container_count: num)
|
49
|
+
poll_for_success(op)
|
50
|
+
say "Scaled #{app.handle} to #{num} instances."
|
51
|
+
end
|
40
52
|
end
|
41
53
|
end
|
42
54
|
end
|
@@ -3,7 +3,7 @@ require 'shellwords'
|
|
3
3
|
module Aptible
|
4
4
|
module CLI
|
5
5
|
module Subcommands
|
6
|
-
module
|
6
|
+
module Logs
|
7
7
|
def self.included(thor)
|
8
8
|
thor.class_eval do
|
9
9
|
include Helpers::Operation
|
@@ -14,11 +14,13 @@ module Aptible
|
|
14
14
|
option :remote, aliases: '-r'
|
15
15
|
def logs
|
16
16
|
app = ensure_app(options)
|
17
|
+
|
17
18
|
host = app.account.bastion_host
|
18
19
|
port = app.account.dumptruck_port
|
19
20
|
|
20
21
|
ENV['ACCESS_TOKEN'] = fetch_token
|
21
22
|
ENV['APTIBLE_APP'] = app.handle
|
23
|
+
ENV['APTIBLE_CLI_COMMAND'] = 'logs'
|
22
24
|
|
23
25
|
opts = " -o 'SendEnv=*' -o StrictHostKeyChecking=no " \
|
24
26
|
'-o UserKnownHostsFile=/dev/null'
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'shellwords'
|
2
|
+
|
3
|
+
module Aptible
|
4
|
+
module CLI
|
5
|
+
module Subcommands
|
6
|
+
module Ps
|
7
|
+
def self.included(thor)
|
8
|
+
thor.class_eval do
|
9
|
+
include Helpers::Operation
|
10
|
+
include Helpers::App
|
11
|
+
include Helpers::Env
|
12
|
+
|
13
|
+
desc 'ps', 'Display running processes for an app'
|
14
|
+
option :app
|
15
|
+
option :remote, aliases: '-r'
|
16
|
+
def ps
|
17
|
+
app = ensure_app(options)
|
18
|
+
|
19
|
+
host = app.account.bastion_host
|
20
|
+
port = app.account.dumptruck_port
|
21
|
+
|
22
|
+
set_env('ACCESS_TOKEN', fetch_token)
|
23
|
+
set_env('APTIBLE_APP', app.handle)
|
24
|
+
set_env('APTIBLE_CLI_COMMAND', 'ps')
|
25
|
+
|
26
|
+
opts = " -o 'SendEnv=*' -o StrictHostKeyChecking=no " \
|
27
|
+
'-o UserKnownHostsFile=/dev/null'
|
28
|
+
Kernel.exec "ssh #{opts} -p #{port} root@#{host}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/aptible/cli/version.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
class App < OpenStruct
|
5
|
+
end
|
6
|
+
|
7
|
+
class Service < OpenStruct
|
8
|
+
end
|
9
|
+
|
10
|
+
class Operation < OpenStruct
|
11
|
+
end
|
12
|
+
|
13
|
+
describe Aptible::CLI::Agent do
|
14
|
+
before { subject.stub(:ask) }
|
15
|
+
before { subject.stub(:save_token) }
|
16
|
+
before { subject.stub(:fetch_token) { double 'token' } }
|
17
|
+
|
18
|
+
service = Service.new(process_type: 'web')
|
19
|
+
op = Operation.new(status: 'succeeded')
|
20
|
+
apps = [App.new(handle: 'hello', services: [service])]
|
21
|
+
|
22
|
+
describe '#apps:scale' do
|
23
|
+
it 'should pass given correct parameters' do
|
24
|
+
allow(service).to receive(:create_operation) { op }
|
25
|
+
allow(subject).to receive(:options) { { app: 'hello' } }
|
26
|
+
|
27
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
28
|
+
subject.send('apps:scale', 'web', 3)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should fail if app is non-existent' do
|
32
|
+
allow(service).to receive(:create_operation) { op }
|
33
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
34
|
+
|
35
|
+
expect do
|
36
|
+
subject.send('apps:scale', 'web', 3)
|
37
|
+
end.to raise_error(Thor::Error)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should fail if number is not a valid number' do
|
41
|
+
allow(service).to receive(:create_operation) { op }
|
42
|
+
allow(subject).to receive(:options) { { app: 'hello' } }
|
43
|
+
|
44
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
45
|
+
expect do
|
46
|
+
subject.send('apps:scale', 'web', 'potato')
|
47
|
+
end.to raise_error(ArgumentError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
class App < OpenStruct
|
5
|
+
end
|
6
|
+
|
7
|
+
class Account < OpenStruct
|
8
|
+
end
|
9
|
+
|
10
|
+
describe Aptible::CLI::Agent do
|
11
|
+
before { subject.stub(:ask) }
|
12
|
+
before { subject.stub(:save_token) }
|
13
|
+
before { subject.stub(:fetch_token) { double 'token' } }
|
14
|
+
before { subject.stub(:ensure_app) { app } }
|
15
|
+
before { subject.stub(:set_env) }
|
16
|
+
before { Kernel.stub(:exec) }
|
17
|
+
|
18
|
+
let(:account) do
|
19
|
+
Account.new(bastion_host: 'bastion.com', dumptruck_port: 45022)
|
20
|
+
end
|
21
|
+
let(:app) { App.new(handle: 'hello', account: account) }
|
22
|
+
|
23
|
+
describe '#ps' do
|
24
|
+
it 'should set ENV["APTIBLE_CLI_COMMAND"]' do
|
25
|
+
expect(subject).to receive(:set_env).with('APTIBLE_CLI_COMMAND', 'ps')
|
26
|
+
subject.send('ps')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should construct a proper SSH call' do
|
30
|
+
expect(Kernel).to receive(:exec) do |*args|
|
31
|
+
cmd = args.first
|
32
|
+
expect(cmd).to match(/ssh.*-p 45022 root@bastion.com/)
|
33
|
+
end
|
34
|
+
subject.send('ps')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
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.5.
|
4
|
+
version: 0.5.8
|
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
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-api
|
@@ -158,17 +158,21 @@ files:
|
|
158
158
|
- lib/aptible/cli/agent.rb
|
159
159
|
- lib/aptible/cli/helpers/account.rb
|
160
160
|
- lib/aptible/cli/helpers/app.rb
|
161
|
+
- lib/aptible/cli/helpers/env.rb
|
161
162
|
- lib/aptible/cli/helpers/operation.rb
|
162
163
|
- lib/aptible/cli/helpers/token.rb
|
163
164
|
- lib/aptible/cli/subcommands/apps.rb
|
164
165
|
- lib/aptible/cli/subcommands/config.rb
|
165
166
|
- lib/aptible/cli/subcommands/db.rb
|
166
167
|
- lib/aptible/cli/subcommands/logs.rb
|
168
|
+
- lib/aptible/cli/subcommands/ps.rb
|
167
169
|
- lib/aptible/cli/subcommands/rebuild.rb
|
168
170
|
- lib/aptible/cli/subcommands/restart.rb
|
169
171
|
- lib/aptible/cli/subcommands/ssh.rb
|
170
172
|
- lib/aptible/cli/version.rb
|
171
173
|
- spec/aptible/cli/agent_spec.rb
|
174
|
+
- spec/aptible/cli/subcommands/apps_spec.rb
|
175
|
+
- spec/aptible/cli/subcommands/ps_spec.rb
|
172
176
|
- spec/spec_helper.rb
|
173
177
|
homepage: https://github.com/aptible/aptible-cli
|
174
178
|
licenses:
|
@@ -190,10 +194,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
194
|
version: '0'
|
191
195
|
requirements: []
|
192
196
|
rubyforge_project:
|
193
|
-
rubygems_version: 2.
|
197
|
+
rubygems_version: 2.4.6
|
194
198
|
signing_key:
|
195
199
|
specification_version: 4
|
196
200
|
summary: Command-line interface for Aptible services
|
197
201
|
test_files:
|
198
202
|
- spec/aptible/cli/agent_spec.rb
|
203
|
+
- spec/aptible/cli/subcommands/apps_spec.rb
|
204
|
+
- spec/aptible/cli/subcommands/ps_spec.rb
|
199
205
|
- spec/spec_helper.rb
|