aptible-cli 0.8.1 → 0.8.2
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/aptible-cli.gemspec +2 -2
- data/lib/aptible/cli/agent.rb +12 -7
- data/lib/aptible/cli/helpers/app.rb +4 -4
- data/lib/aptible/cli/helpers/database.rb +6 -5
- data/lib/aptible/cli/helpers/environment.rb +3 -3
- data/lib/aptible/cli/helpers/operation.rb +1 -1
- data/lib/aptible/cli/helpers/ssh.rb +0 -4
- data/lib/aptible/cli/helpers/token.rb +2 -2
- data/lib/aptible/cli/helpers/tunnel.rb +2 -2
- data/lib/aptible/cli/subcommands/apps.rb +4 -4
- data/lib/aptible/cli/subcommands/backup.rb +2 -2
- data/lib/aptible/cli/subcommands/db.rb +1 -1
- data/lib/aptible/cli/subcommands/logs.rb +3 -3
- data/lib/aptible/cli/subcommands/operation.rb +1 -1
- data/lib/aptible/cli/subcommands/restart.rb +1 -1
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/mock/ssh +1 -1
- data/spec/mock/ssh_mock.rb +1 -1
- metadata +6 -7
- data/.rubocop.yml +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08df5d523ff73a1a0d859f2285538f709987a729
|
4
|
+
data.tar.gz: 03b0d0d1e71ec42fb5e1c93fee8612a72d1b86ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d236987c6f258313027496882c7bbcbd438ceb23ee56027ba96dee02aaf5020e33e7fa12e7695c431594f0c59f82f5a51e33d244061878f4ea18869b9c10f3a
|
7
|
+
data.tar.gz: 1d9b8f8407f61df638451f183cda662a4385c8a34e7d3fda11fe0146d3bb3c97800c483b35a8ff3c0e6a770d2a25298ff8578b6c4cd4bbb862ebb1bcc7dcb976
|
data/aptible-cli.gemspec
CHANGED
@@ -20,8 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{spec/})
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.add_dependency 'aptible-api', '~> 0.9.
|
24
|
-
spec.add_dependency 'aptible-auth', '~> 0.11.
|
23
|
+
spec.add_dependency 'aptible-api', '~> 0.9.16'
|
24
|
+
spec.add_dependency 'aptible-auth', '~> 0.11.12'
|
25
25
|
spec.add_dependency 'aptible-resource', '~> 0.3.6'
|
26
26
|
spec.add_dependency 'thor', '~> 0.19.1'
|
27
27
|
spec.add_dependency 'git'
|
data/lib/aptible/cli/agent.rb
CHANGED
@@ -49,17 +49,13 @@ module Aptible
|
|
49
49
|
|
50
50
|
def initialize(*)
|
51
51
|
nag_toolbelt unless toolbelt?
|
52
|
+
Aptible::Resource.configure { |conf| conf.user_agent = version_string }
|
52
53
|
super
|
53
54
|
end
|
54
55
|
|
55
56
|
desc 'version', 'Print Aptible CLI version'
|
56
57
|
def version
|
57
|
-
|
58
|
-
'aptible-cli',
|
59
|
-
"v#{Aptible::CLI::VERSION}"
|
60
|
-
]
|
61
|
-
bits << 'toolbelt' if toolbelt?
|
62
|
-
puts bits.join ' '
|
58
|
+
puts version_string
|
63
59
|
end
|
64
60
|
|
65
61
|
desc 'login', 'Log in to Aptible'
|
@@ -85,7 +81,7 @@ module Aptible
|
|
85
81
|
|
86
82
|
duration = ChronicDuration.parse(lifetime)
|
87
83
|
if duration.nil?
|
88
|
-
|
84
|
+
raise Thor::Error, "Invalid token lifetime requested: #{lifetime}"
|
89
85
|
end
|
90
86
|
|
91
87
|
token_options[:expires_in] = duration
|
@@ -148,6 +144,15 @@ module Aptible
|
|
148
144
|
end
|
149
145
|
end
|
150
146
|
|
147
|
+
def version_string
|
148
|
+
bits = [
|
149
|
+
'aptible-cli',
|
150
|
+
"v#{Aptible::CLI::VERSION}"
|
151
|
+
]
|
152
|
+
bits << 'toolbelt' if toolbelt?
|
153
|
+
bits.join ' '
|
154
|
+
end
|
155
|
+
|
151
156
|
def toolbelt?
|
152
157
|
ENV['APTIBLE_TOOLBELT']
|
153
158
|
end
|
@@ -97,7 +97,7 @@ module Aptible
|
|
97
97
|
if s.nil?
|
98
98
|
err = 'Could not find app in current working directory, please ' \
|
99
99
|
'specify with --app'
|
100
|
-
|
100
|
+
raise Thor::Error, err
|
101
101
|
end
|
102
102
|
|
103
103
|
environment = nil
|
@@ -106,7 +106,7 @@ module Aptible
|
|
106
106
|
if environment.nil?
|
107
107
|
err_bits = ['Could not find environment', s.env_handle]
|
108
108
|
err_bits << s.explain
|
109
|
-
|
109
|
+
raise Thor::Error, err_bits.join(' ')
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
@@ -124,11 +124,11 @@ module Aptible
|
|
124
124
|
err_bits << 'in any environment'
|
125
125
|
end
|
126
126
|
err_bits << s.explain
|
127
|
-
|
127
|
+
raise Thor::Error, err_bits.join(' ')
|
128
128
|
else
|
129
129
|
err = "Multiple apps named #{s.app_handle} exist, please specify " \
|
130
130
|
'with --environment'
|
131
|
-
|
131
|
+
raise Thor::Error, err
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -12,21 +12,22 @@ module Aptible
|
|
12
12
|
db_handle = options[:db]
|
13
13
|
environment_handle = options[:environment]
|
14
14
|
|
15
|
-
|
15
|
+
raise Thor::Error, 'Database handle not specified' unless db_handle
|
16
16
|
|
17
17
|
environment = environment_from_handle(environment_handle)
|
18
18
|
if environment_handle && !environment
|
19
|
-
|
19
|
+
raise Thor::Error,
|
20
|
+
"Could not find environment #{environment_handle}"
|
20
21
|
end
|
21
22
|
databases = databases_from_handle(db_handle, environment)
|
22
23
|
case databases.count
|
23
24
|
when 1
|
24
25
|
return databases.first
|
25
26
|
when 0
|
26
|
-
|
27
|
+
raise Thor::Error, "Could not find database #{db_handle}"
|
27
28
|
else
|
28
29
|
err = 'Multiple databases exist, please specify with --environment'
|
29
|
-
|
30
|
+
raise Thor::Error, err
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -74,7 +75,7 @@ module Aptible
|
|
74
75
|
|
75
76
|
def with_postgres_tunnel(database)
|
76
77
|
if database.type != 'postgresql'
|
77
|
-
|
78
|
+
raise Thor::Error, 'This command only works for PostgreSQL'
|
78
79
|
end
|
79
80
|
|
80
81
|
with_local_tunnel(database) do |tunnel_helper|
|
@@ -11,7 +11,7 @@ module Aptible
|
|
11
11
|
if (environment = environment_from_handle(options[:environment]))
|
12
12
|
[environment]
|
13
13
|
else
|
14
|
-
|
14
|
+
raise Thor::Error, 'Specified account does not exist'
|
15
15
|
end
|
16
16
|
else
|
17
17
|
Aptible::Api::Account.all(token: fetch_token)
|
@@ -22,7 +22,7 @@ module Aptible
|
|
22
22
|
if (handle = options[:environment])
|
23
23
|
environment = environment_from_handle(handle)
|
24
24
|
return environment if environment
|
25
|
-
|
25
|
+
raise Thor::Error, "Could not find environment #{handle}"
|
26
26
|
else
|
27
27
|
ensure_default_environment
|
28
28
|
end
|
@@ -39,7 +39,7 @@ module Aptible
|
|
39
39
|
environments = Aptible::Api::Account.all(token: fetch_token)
|
40
40
|
return environments.first if environments.count == 1
|
41
41
|
|
42
|
-
|
42
|
+
raise Thor::Error, <<-ERR.gsub(/\s+/, ' ').strip
|
43
43
|
Multiple environments available, please specify with --environment
|
44
44
|
ERR
|
45
45
|
end
|
@@ -12,7 +12,7 @@ module Aptible
|
|
12
12
|
wait_for_completion operation
|
13
13
|
return if operation.status == 'succeeded'
|
14
14
|
|
15
|
-
|
15
|
+
raise Thor::Error, "Operation ##{operation.id} failed."
|
16
16
|
end
|
17
17
|
|
18
18
|
def wait_for_completion(operation)
|
@@ -37,7 +37,6 @@ module Aptible
|
|
37
37
|
|
38
38
|
# If we're missing *some* files, then we should clean them up.
|
39
39
|
|
40
|
-
# rubocop:disable Lint/HandleExceptions
|
41
40
|
key_files.each do |key_file|
|
42
41
|
begin
|
43
42
|
File.delete(key_file)
|
@@ -45,7 +44,6 @@ module Aptible
|
|
45
44
|
# We don't care, that's what we want.
|
46
45
|
end
|
47
46
|
end
|
48
|
-
# rubocop:enable Lint/HandleExceptions
|
49
47
|
|
50
48
|
begin
|
51
49
|
cmd = ['ssh-keygen', '-t', 'rsa', '-N', '', '-f', private_key_file]
|
@@ -76,8 +74,6 @@ module Aptible
|
|
76
74
|
log_level = ENV['APTIBLE_SSH_DEBUG'] ? 'DEBUG3' : 'ERROR'
|
77
75
|
|
78
76
|
[
|
79
|
-
'-o', 'StrictHostKeyChecking=no',
|
80
|
-
'-o', 'UserKnownHostsFile=/dev/null',
|
81
77
|
'-o', 'TCPKeepAlive=yes',
|
82
78
|
'-o', 'KeepAlive=yes',
|
83
79
|
'-o', 'ServerAliveInterval=60',
|
@@ -10,8 +10,8 @@ module Aptible
|
|
10
10
|
@token ||= ENV[TOKEN_ENV_VAR] ||
|
11
11
|
current_token_hash[Aptible::Auth.configuration.root_url]
|
12
12
|
return @token if @token
|
13
|
-
|
14
|
-
|
13
|
+
raise Thor::Error, 'Could not read token: please run aptible login ' \
|
14
|
+
"or set #{TOKEN_ENV_VAR}"
|
15
15
|
end
|
16
16
|
|
17
17
|
def save_token(token)
|
@@ -60,7 +60,7 @@ module Aptible
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def stop
|
63
|
-
|
63
|
+
raise 'You must call #start before calling #stop' if @pid.nil?
|
64
64
|
begin
|
65
65
|
Process.kill(STOP_SIGNAL, @pid)
|
66
66
|
rescue Errno::ESRCH
|
@@ -76,7 +76,7 @@ module Aptible
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def port
|
79
|
-
|
79
|
+
raise 'You must call #start before calling #port!' if @local_port.nil?
|
80
80
|
@local_port
|
81
81
|
end
|
82
82
|
|
@@ -27,7 +27,7 @@ module Aptible
|
|
27
27
|
app = environment.create_app(handle: handle)
|
28
28
|
|
29
29
|
if app.errors.any?
|
30
|
-
|
30
|
+
raise Thor::Error, app.errors.full_messages.first
|
31
31
|
else
|
32
32
|
say "App #{handle} created!"
|
33
33
|
say "Git remote: #{app.git_repo}"
|
@@ -54,9 +54,9 @@ module Aptible
|
|
54
54
|
else
|
55
55
|
app.services.map(&:process_type).join(', ')
|
56
56
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
raise Thor::Error, "Service with type #{type} does not " \
|
58
|
+
"exist for app #{app.handle}. Valid " \
|
59
|
+
"types: #{valid_types}."
|
60
60
|
end
|
61
61
|
op = service.create_operation!(type: 'scale',
|
62
62
|
container_count: num,
|
@@ -13,7 +13,7 @@ module Aptible
|
|
13
13
|
option :size, type: :numeric
|
14
14
|
define_method 'backup:restore' do |backup_id|
|
15
15
|
backup = Aptible::Api::Backup.find(backup_id, token: fetch_token)
|
16
|
-
|
16
|
+
raise Thor::Error, "Backup ##{backup_id} not found" if backup.nil?
|
17
17
|
handle = options[:handle]
|
18
18
|
unless handle
|
19
19
|
ts_suffix = backup.created_at.getgm.strftime '%Y-%m-%d-%H-%M-%S'
|
@@ -38,7 +38,7 @@ module Aptible
|
|
38
38
|
desc: 'Limit backups returned (example usage: 1w, 1y, etc.)'
|
39
39
|
define_method 'backup:list' do |handle|
|
40
40
|
age = ChronicDuration.parse(options[:max_age])
|
41
|
-
|
41
|
+
raise Thor::Error, "Invalid age: #{options[:max_age]}" if age.nil?
|
42
42
|
min_created_at = Time.now - age
|
43
43
|
|
44
44
|
database = ensure_database(options.merge(db: handle))
|
@@ -30,7 +30,7 @@ module Aptible
|
|
30
30
|
type: options[:type])
|
31
31
|
|
32
32
|
if database.errors.any?
|
33
|
-
|
33
|
+
raise Thor::Error, database.errors.full_messages.first
|
34
34
|
else
|
35
35
|
op = database.create_operation!(type: 'provision',
|
36
36
|
disk_size: options[:size])
|
@@ -16,7 +16,7 @@ module Aptible
|
|
16
16
|
def logs
|
17
17
|
if options[:app] && options[:database]
|
18
18
|
m = 'You must specify only one of --app and --database'
|
19
|
-
|
19
|
+
raise Thor::Error, m
|
20
20
|
end
|
21
21
|
|
22
22
|
resource = \
|
@@ -27,8 +27,8 @@ module Aptible
|
|
27
27
|
end
|
28
28
|
|
29
29
|
unless resource.status == 'provisioned'
|
30
|
-
|
31
|
-
|
30
|
+
raise Thor::Error, 'Unable to retrieve logs. ' \
|
31
|
+
"Have you deployed #{resource.handle} yet?"
|
32
32
|
end
|
33
33
|
|
34
34
|
op = resource.create_operation!(type: 'logs', status: 'succeeded')
|
@@ -10,7 +10,7 @@ module Aptible
|
|
10
10
|
desc 'operation:cancel OPERATION_ID', 'Cancel a running operation'
|
11
11
|
define_method 'operation:cancel' do |operation_id|
|
12
12
|
o = Aptible::Api::Operation.find(operation_id, token: fetch_token)
|
13
|
-
|
13
|
+
raise "Operation ##{operation_id} not found" if o.nil?
|
14
14
|
|
15
15
|
puts "Requesting cancellation on #{prettify_operation(o)}..."
|
16
16
|
o.update!(cancelled: true)
|
data/lib/aptible/cli/version.rb
CHANGED
data/spec/mock/ssh
CHANGED
data/spec/mock/ssh_mock.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.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Macreery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-api
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.9.
|
19
|
+
version: 0.9.16
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.9.
|
26
|
+
version: 0.9.16
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: aptible-auth
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.11.
|
33
|
+
version: 0.11.12
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.11.
|
40
|
+
version: 0.11.12
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: aptible-resource
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -216,7 +216,6 @@ extra_rdoc_files: []
|
|
216
216
|
files:
|
217
217
|
- ".gitignore"
|
218
218
|
- ".rspec"
|
219
|
-
- ".rubocop.yml"
|
220
219
|
- ".travis.yml"
|
221
220
|
- Gemfile
|
222
221
|
- LICENSE.md
|
data/.rubocop.yml
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
GuardClause:
|
2
|
-
Enabled: false
|
3
|
-
|
4
|
-
Documentation:
|
5
|
-
Enabled: false
|
6
|
-
|
7
|
-
Encoding:
|
8
|
-
Enabled: false
|
9
|
-
|
10
|
-
DoubleNegation:
|
11
|
-
Enabled: false
|
12
|
-
|
13
|
-
NumericLiterals:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
FileName:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
MethodLength:
|
20
|
-
Enabled: false
|
21
|
-
|
22
|
-
CyclomaticComplexity:
|
23
|
-
Enabled: false
|
24
|
-
|
25
|
-
PerceivedComplexity:
|
26
|
-
Enabled: false
|
27
|
-
|
28
|
-
AbcSize:
|
29
|
-
Enabled: false
|
30
|
-
|
31
|
-
SignalException:
|
32
|
-
Enabled: false
|
33
|
-
|
34
|
-
AllCops:
|
35
|
-
Include:
|
36
|
-
- !ruby/regexp /\.rb$/
|
37
|
-
- !ruby/regexp /\.rake$/
|
38
|
-
- !ruby/regexp /\.gemspec$/
|
39
|
-
- !ruby/regexp /Rakefile$/
|
40
|
-
Exclude:
|
41
|
-
# Exclude line length check from autogenerated files
|
42
|
-
- !ruby/regexp /\/db\/schema\.rb$/
|
43
|
-
- !ruby/regexp /node_modules\//
|
44
|
-
- !ruby/regexp /tmp\//
|
45
|
-
- !ruby/regexp /vendor\//
|