aptible-cli 0.6.0 → 0.6.1
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/helpers/app.rb +47 -32
- data/lib/aptible/cli/helpers/environment.rb +1 -0
- data/lib/aptible/cli/subcommands/apps.rb +3 -4
- data/lib/aptible/cli/subcommands/config.rb +5 -10
- data/lib/aptible/cli/subcommands/domains.rb +1 -3
- data/lib/aptible/cli/subcommands/logs.rb +1 -2
- data/lib/aptible/cli/subcommands/ps.rb +1 -2
- data/lib/aptible/cli/subcommands/rebuild.rb +1 -2
- data/lib/aptible/cli/subcommands/restart.rb +1 -2
- data/lib/aptible/cli/subcommands/ssh.rb +1 -2
- data/lib/aptible/cli/version.rb +1 -1
- data/spec/aptible/cli/subcommands/apps_spec.rb +1 -2
- data/spec/aptible/cli/subcommands/domains_spec.rb +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a4dc9b3d5de431e99e8aef2e76fdf0a352c03f7
|
4
|
+
data.tar.gz: eaaba80a605eff86cdddb3bec822a57ae928d871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d86fdfec7a75ba6aa0234551c0b7c326ee6b408175ea41d7fb8e44c96f0f2db2ecd9346029f4ac36295f1e68d9690f9928a74efdba79c6f8e63d88a6905d5253
|
7
|
+
data.tar.gz: 7a115c06a8479359d96dade21f5467cdba4b50af226d828062b0b9a88722d46ef1772fc1e22c56f991e1d6e874bce0e0fb9105997d9a944d876c3fdd3df29852
|
@@ -10,56 +10,71 @@ module Aptible
|
|
10
10
|
|
11
11
|
class HandleFromGitRemote
|
12
12
|
PATTERN = %r{
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
:((?<environment_handle>[0-9a-z\-_\.]+?)/)?
|
14
|
+
(?<app_handle>[0-9a-z\-_\.]+)\.git
|
15
|
+
\z
|
16
|
+
}x
|
16
17
|
|
17
18
|
def self.parse(url)
|
18
|
-
PATTERN.match(url)
|
19
|
+
PATTERN.match(url) || {}
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
|
-
def
|
23
|
-
|
24
|
-
handle = options[:app]
|
25
|
-
if handle
|
26
|
-
environment = ensure_environment(options)
|
27
|
-
else
|
28
|
-
handles = handle_from_remote(remote) || ensure_default_handle
|
29
|
-
handle = handles[:app_handle]
|
30
|
-
env_handle = handles[:environment_handle] || options[:environment]
|
31
|
-
environment = ensure_environment(environment: env_handle)
|
32
|
-
end
|
33
|
-
|
34
|
-
app = app_from_handle(handle, environment)
|
35
|
-
return app if app
|
36
|
-
fail Thor::Error, "Could not find app #{handle}"
|
23
|
+
def self.included(base)
|
24
|
+
base.extend ClassMethods
|
37
25
|
end
|
38
26
|
|
39
|
-
|
40
|
-
|
41
|
-
|
27
|
+
module ClassMethods
|
28
|
+
def app_options
|
29
|
+
option :app
|
30
|
+
option :environment
|
31
|
+
option :remote, aliases: '-r'
|
42
32
|
end
|
43
33
|
end
|
44
34
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
def ensure_app(options = {})
|
36
|
+
remote = options[:remote] || ENV['APTIBLE_REMOTE'] || 'aptible'
|
37
|
+
app_handle = options[:app] || handles_from_remote(remote)[:app_handle]
|
38
|
+
environment_handle = options[:environment] ||
|
39
|
+
handles_from_remote(remote)[:environment_handle]
|
40
|
+
|
41
|
+
unless app_handle
|
42
|
+
fail Thor::Error, <<-ERR.gsub(/\s+/, ' ').strip
|
43
|
+
Could not find app in current working directory, please specify
|
44
|
+
with --app
|
45
|
+
ERR
|
46
|
+
end
|
47
|
+
|
48
|
+
environment = environment_from_handle(environment_handle)
|
49
|
+
if environment_handle && !environment
|
50
|
+
fail Thor::Error, "Could not find environment #{environment_handle}"
|
51
|
+
end
|
52
|
+
apps = apps_from_handle(app_handle, environment)
|
53
|
+
case apps.count
|
54
|
+
when 1
|
55
|
+
return apps.first
|
56
|
+
when 0
|
57
|
+
fail Thor::Error, "Could not find app #{app_handle}"
|
58
|
+
else
|
59
|
+
fail Thor::Error, 'Multiple apps exist, please specify environment'
|
60
|
+
end
|
51
61
|
end
|
52
62
|
|
53
|
-
def
|
54
|
-
|
63
|
+
def apps_from_handle(handle, environment)
|
64
|
+
if environment
|
65
|
+
apps = environment.apps
|
66
|
+
else
|
67
|
+
apps = Aptible::Api::App.all(token: fetch_token)
|
68
|
+
end
|
69
|
+
apps.select { |a| a.handle == handle }
|
55
70
|
end
|
56
71
|
|
57
|
-
def
|
72
|
+
def handles_from_remote(remote_name)
|
58
73
|
git = Git.open(Dir.pwd)
|
59
74
|
aptible_remote = git.remote(remote_name).url || ''
|
60
75
|
HandleFromGitRemote.parse(aptible_remote)
|
61
76
|
rescue
|
62
|
-
|
77
|
+
{}
|
63
78
|
end
|
64
79
|
end
|
65
80
|
end
|
@@ -4,6 +4,7 @@ module Aptible
|
|
4
4
|
module Apps
|
5
5
|
def self.included(thor)
|
6
6
|
thor.class_eval do
|
7
|
+
include Helpers::App
|
7
8
|
include Helpers::Environment
|
8
9
|
include Helpers::Token
|
9
10
|
|
@@ -33,8 +34,7 @@ module Aptible
|
|
33
34
|
end
|
34
35
|
|
35
36
|
desc 'apps:scale TYPE NUMBER', 'Scale app to NUMBER of instances'
|
36
|
-
|
37
|
-
option :environment
|
37
|
+
app_options
|
38
38
|
define_method 'apps:scale' do |type, n|
|
39
39
|
num = Integer(n)
|
40
40
|
app = ensure_app(options)
|
@@ -43,9 +43,8 @@ module Aptible
|
|
43
43
|
attach_to_operation_logs(op)
|
44
44
|
end
|
45
45
|
|
46
|
-
option :app
|
47
|
-
option :environment
|
48
46
|
desc 'apps:deprovision', 'Deprovision an app'
|
47
|
+
app_options
|
49
48
|
define_method 'apps:deprovision' do
|
50
49
|
app = ensure_app(options)
|
51
50
|
say "Deprovisioning #{app.handle}..."
|
@@ -10,8 +10,7 @@ module Aptible
|
|
10
10
|
include Helpers::App
|
11
11
|
|
12
12
|
desc 'config', "Print an app's current configuration"
|
13
|
-
|
14
|
-
option :remote, aliases: '-r'
|
13
|
+
app_options
|
15
14
|
def config
|
16
15
|
app = ensure_app(options)
|
17
16
|
config = app.current_configuration
|
@@ -20,8 +19,7 @@ module Aptible
|
|
20
19
|
end
|
21
20
|
|
22
21
|
desc 'config:add', 'Add an ENV variable to an app'
|
23
|
-
|
24
|
-
option :remote, aliases: '-r'
|
22
|
+
app_options
|
25
23
|
define_method 'config:add' do |*args|
|
26
24
|
# FIXME: define_method - ?! Seriously, WTF Thor.
|
27
25
|
app = ensure_app(options)
|
@@ -32,15 +30,13 @@ module Aptible
|
|
32
30
|
end
|
33
31
|
|
34
32
|
desc 'config:set', 'Alias for config:add'
|
35
|
-
|
36
|
-
option :remote, aliases: '-r'
|
33
|
+
app_options
|
37
34
|
define_method 'config:set' do |*args|
|
38
35
|
send('config:add', *args)
|
39
36
|
end
|
40
37
|
|
41
38
|
desc 'config:rm', 'Remove an ENV variable from an app'
|
42
|
-
|
43
|
-
option :remote, aliases: '-r'
|
39
|
+
app_options
|
44
40
|
define_method 'config:rm' do |*args|
|
45
41
|
# FIXME: define_method - ?! Seriously, WTF Thor.
|
46
42
|
app = ensure_app(options)
|
@@ -51,8 +47,7 @@ module Aptible
|
|
51
47
|
end
|
52
48
|
|
53
49
|
desc 'config:unset', 'Alias for config:rm'
|
54
|
-
|
55
|
-
option :remote, aliases: '-r'
|
50
|
+
app_options
|
56
51
|
define_method 'config:unset' do |*args|
|
57
52
|
send('config:add', *args)
|
58
53
|
end
|
@@ -10,10 +10,8 @@ module Aptible
|
|
10
10
|
include Helpers::App
|
11
11
|
|
12
12
|
desc 'domains', "Print an app's current virtual domains"
|
13
|
-
|
14
|
-
option :environment
|
13
|
+
app_options
|
15
14
|
option :verbose, aliases: '-v'
|
16
|
-
option :remote, aliases: '-r'
|
17
15
|
def domains
|
18
16
|
app = ensure_app(options)
|
19
17
|
print_vhosts(app) do |vhost|
|
@@ -8,8 +8,7 @@ module Aptible
|
|
8
8
|
include Helpers::App
|
9
9
|
|
10
10
|
desc 'restart', 'Restart all services associated with an app'
|
11
|
-
|
12
|
-
option :remote, aliases: '-r'
|
11
|
+
app_options
|
13
12
|
def restart
|
14
13
|
app = ensure_app(options)
|
15
14
|
operation = app.create_operation(type: 'restart')
|
data/lib/aptible/cli/version.rb
CHANGED
@@ -35,8 +35,7 @@ describe Aptible::CLI::Agent do
|
|
35
35
|
allow(service).to receive(:create_operation) { op }
|
36
36
|
allow(subject).to receive(:options) { { app: 'hello' } }
|
37
37
|
allow(op).to receive(:resource) { apps.first }
|
38
|
-
allow(Aptible::Api::
|
39
|
-
allow(account).to receive(:apps) { apps }
|
38
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
40
39
|
|
41
40
|
subject.send('apps:scale', 'web', 3)
|
42
41
|
end
|
@@ -35,8 +35,7 @@ describe Aptible::CLI::Agent do
|
|
35
35
|
it 'should print out the hostnames' do
|
36
36
|
allow(service).to receive(:create_operation) { op }
|
37
37
|
allow(subject).to receive(:options) { { app: 'hello' } }
|
38
|
-
allow(Aptible::Api::
|
39
|
-
allow(account).to receive(:apps) { apps }
|
38
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
40
39
|
|
41
40
|
expect(app).to receive(:vhosts) { [vhost1, vhost2] }
|
42
41
|
expect(subject).to receive(:say).with('domain1')
|
@@ -68,8 +67,7 @@ describe Aptible::CLI::Agent do
|
|
68
67
|
it 'should print hostnames if -v is passed' do
|
69
68
|
allow(service).to receive(:create_operation) { op }
|
70
69
|
allow(subject).to receive(:options) { { verbose: true, app: 'hello' } }
|
71
|
-
allow(Aptible::Api::
|
72
|
-
allow(account).to receive(:apps) { apps }
|
70
|
+
allow(Aptible::Api::App).to receive(:all) { apps }
|
73
71
|
|
74
72
|
expect(app).to receive(:vhosts) { [vhost1, vhost2] }
|
75
73
|
expect(subject).to receive(:say).with('domain1 -> host1')
|
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.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: 2016-02-
|
11
|
+
date: 2016-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aptible-api
|