jdc 0.2.1 → 0.2.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1277 -24
- data/Rakefile +13 -0
- data/bin/jdc +12 -2
- data/lib/admin/README.md +15 -0
- data/lib/admin/curl.rb +60 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +6 -0
- data/lib/admin/service_auth_token.rb +94 -0
- data/lib/admin/service_broker/add.rb +47 -0
- data/lib/admin/service_broker/service_brokers.rb +24 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/console/README.md +8 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +33 -0
- data/lib/jdc.rb +15 -2
- data/lib/jdc/cli.rb +556 -0
- data/lib/jdc/cli/app/app.rb +43 -0
- data/lib/jdc/cli/app/apps.rb +87 -0
- data/lib/jdc/cli/app/base.rb +72 -0
- data/lib/jdc/cli/app/delete.rb +95 -0
- data/lib/jdc/cli/app/deprecated.rb +11 -0
- data/lib/jdc/cli/app/env.rb +78 -0
- data/lib/jdc/cli/app/events.rb +45 -0
- data/lib/jdc/cli/app/files.rb +137 -0
- data/lib/jdc/cli/app/health.rb +26 -0
- data/lib/jdc/cli/app/instances.rb +53 -0
- data/lib/jdc/cli/app/logs.rb +76 -0
- data/lib/jdc/cli/app/push.rb +103 -0
- data/lib/jdc/cli/app/push/create.rb +108 -0
- data/lib/jdc/cli/app/push/interactions.rb +86 -0
- data/lib/jdc/cli/app/push/sync.rb +57 -0
- data/lib/jdc/cli/app/rename.rb +35 -0
- data/lib/jdc/cli/app/restart.rb +31 -0
- data/lib/jdc/cli/app/scale.rb +63 -0
- data/lib/jdc/cli/app/start.rb +161 -0
- data/lib/jdc/cli/app/stats.rb +67 -0
- data/lib/jdc/cli/app/stop.rb +27 -0
- data/lib/jdc/cli/domain/base.rb +9 -0
- data/lib/jdc/cli/domain/domains.rb +40 -0
- data/lib/jdc/cli/domain/map.rb +55 -0
- data/lib/jdc/cli/domain/unmap.rb +56 -0
- data/lib/jdc/cli/help.rb +15 -0
- data/lib/jdc/cli/interactive.rb +105 -0
- data/lib/jdc/cli/login_requirements.rb +15 -0
- data/lib/jdc/cli/organization/base.rb +14 -0
- data/lib/jdc/cli/organization/create.rb +37 -0
- data/lib/jdc/cli/organization/delete.rb +63 -0
- data/lib/jdc/cli/organization/org.rb +45 -0
- data/lib/jdc/cli/organization/orgs.rb +30 -0
- data/lib/jdc/cli/organization/rename.rb +37 -0
- data/lib/jdc/cli/populators/base.rb +16 -0
- data/lib/jdc/cli/populators/organization.rb +32 -0
- data/lib/jdc/cli/populators/populator_methods.rb +64 -0
- data/lib/jdc/cli/populators/space.rb +33 -0
- data/lib/jdc/cli/populators/target.rb +13 -0
- data/lib/jdc/cli/route/base.rb +9 -0
- data/lib/jdc/cli/route/delete.rb +28 -0
- data/lib/jdc/cli/route/map.rb +68 -0
- data/lib/jdc/cli/route/routes.rb +26 -0
- data/lib/jdc/cli/route/unmap.rb +56 -0
- data/lib/jdc/cli/service/base.rb +9 -0
- data/lib/jdc/cli/service/bind.rb +44 -0
- data/lib/jdc/cli/service/create.rb +159 -0
- data/lib/jdc/cli/service/delete.rb +83 -0
- data/lib/jdc/cli/service/rename.rb +36 -0
- data/lib/jdc/cli/service/service.rb +42 -0
- data/lib/jdc/cli/service/service_instance_helper.rb +99 -0
- data/lib/jdc/cli/service/services.rb +111 -0
- data/lib/jdc/cli/service/unbind.rb +37 -0
- data/lib/jdc/cli/space/base.rb +29 -0
- data/lib/jdc/cli/space/create.rb +67 -0
- data/lib/jdc/cli/space/delete.rb +56 -0
- data/lib/jdc/cli/space/rename.rb +38 -0
- data/lib/jdc/cli/space/space.rb +66 -0
- data/lib/jdc/cli/space/spaces.rb +57 -0
- data/lib/jdc/cli/space/switch.rb +19 -0
- data/lib/jdc/cli/start/base.rb +41 -0
- data/lib/jdc/cli/start/colors.rb +13 -0
- data/lib/jdc/cli/start/target.rb +50 -0
- data/lib/jdc/cli/start/target_prettifier.rb +17 -0
- data/lib/jdc/cli/start/targets.rb +16 -0
- data/lib/jdc/cli/user/base.rb +30 -0
- data/lib/jdc/cli/user/create.rb +52 -0
- data/lib/jdc/cli/user/passwd.rb +37 -0
- data/lib/jdc/cli/user/register.rb +43 -0
- data/lib/jdc/cli/user/users.rb +32 -0
- data/lib/jdc/constants.rb +11 -0
- data/lib/jdc/errors.rb +19 -0
- data/lib/jdc/object_extensions.rb +15 -0
- data/lib/jdc/plugin.rb +56 -0
- data/lib/jdc/spacing.rb +89 -0
- data/lib/jdc/spec_helper.rb +1 -0
- data/lib/jdc/test_support.rb +6 -0
- data/lib/jdc/version.rb +3 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +344 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +9 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/{jdc → micro}/micro.rb +15 -15
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/{jdc/micro → micro}/switcher/darwin.rb +5 -3
- data/lib/{jdc/micro → micro}/switcher/dummy.rb +1 -1
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/{jdc/micro → micro}/switcher/windows.rb +5 -5
- data/lib/{jdc/micro → micro}/vmrun.rb +26 -19
- data/lib/tasks/gem_release.rake +42 -0
- data/lib/tunnel/README.md +29 -0
- data/{config → lib/tunnel/config}/clients.yml +2 -2
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/{caldecott_helper → lib/tunnel/helper-app}/server.rb +5 -5
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- metadata +371 -210
- data/README.md +0 -102
- data/config/micro/paths.yml +0 -22
- data/config/micro/refresh_ip.rb +0 -20
- data/lib/cli.rb +0 -53
- data/lib/cli/commands/admin.rb +0 -58
- data/lib/cli/commands/apps.rb +0 -1129
- data/lib/cli/commands/base.rb +0 -228
- data/lib/cli/commands/manifest.rb +0 -56
- data/lib/cli/commands/micro.rb +0 -115
- data/lib/cli/commands/misc.rb +0 -126
- data/lib/cli/commands/services.rb +0 -178
- data/lib/cli/commands/user.rb +0 -14
- data/lib/cli/config.rb +0 -173
- data/lib/cli/console_helper.rb +0 -170
- data/lib/cli/core_ext.rb +0 -122
- data/lib/cli/errors.rb +0 -19
- data/lib/cli/frameworks.rb +0 -265
- data/lib/cli/manifest_helper.rb +0 -300
- data/lib/cli/runner.rb +0 -505
- data/lib/cli/services_helper.rb +0 -84
- data/lib/cli/tunnel_helper.rb +0 -332
- data/lib/cli/usage.rb +0 -86
- data/lib/cli/version.rb +0 -7
- data/lib/cli/zip_util.rb +0 -77
- data/lib/jdc/client.rb +0 -457
- data/lib/jdc/const.rb +0 -25
- data/lib/jdc/micro/switcher/base.rb +0 -97
- data/lib/jdc/micro/switcher/linux.rb +0 -16
- data/lib/jdc/signature/version.rb +0 -27
- data/lib/jdc/signer.rb +0 -13
- data/lib/jdc/timer.rb +0 -12
@@ -0,0 +1,30 @@
|
|
1
|
+
require "jdc/cli/organization/base"
|
2
|
+
|
3
|
+
module JDC::Organization
|
4
|
+
class Orgs < Base
|
5
|
+
desc "List available organizations"
|
6
|
+
group :organizations
|
7
|
+
input :full, :desc => "Show full information for apps, services, etc.",
|
8
|
+
:default => false
|
9
|
+
def orgs
|
10
|
+
orgs =
|
11
|
+
with_progress("Getting organizations") do
|
12
|
+
client.organizations(:depth => 0).sort_by(&:name)
|
13
|
+
end
|
14
|
+
|
15
|
+
return if orgs.empty?
|
16
|
+
|
17
|
+
line unless quiet?
|
18
|
+
|
19
|
+
if input[:full]
|
20
|
+
orgs.each do |o|
|
21
|
+
invoke :org, :organization => o, :full => true
|
22
|
+
end
|
23
|
+
else
|
24
|
+
table(
|
25
|
+
%w{name},
|
26
|
+
orgs.collect { |o| [c(o.name, :name)] })
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "jdc/cli/organization/base"
|
2
|
+
=begin
|
3
|
+
module JDC::Organization
|
4
|
+
class Rename < Base
|
5
|
+
desc "Rename an organization"
|
6
|
+
group :organizations
|
7
|
+
input :organization, :desc => "Organization to rename",
|
8
|
+
:aliases => ["--org", "-o"], :argument => :optional,
|
9
|
+
:from_given => by_name(:organization)
|
10
|
+
input :name, :desc => "New organization name", :argument => :optional
|
11
|
+
def rename_org
|
12
|
+
organization = input[:organization]
|
13
|
+
name = input[:name]
|
14
|
+
|
15
|
+
organization.name = name
|
16
|
+
|
17
|
+
with_progress("Renaming to #{c(name, :name)}") do
|
18
|
+
organization.update!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def ask_name
|
25
|
+
ask("New name")
|
26
|
+
end
|
27
|
+
|
28
|
+
def ask_organization
|
29
|
+
organizations = client.organizations(:depth => 0)
|
30
|
+
fail "No organizations." if organizations.empty?
|
31
|
+
|
32
|
+
ask("Rename which organization?", :choices => organizations.sort_by(&:name),
|
33
|
+
:display => proc(&:name))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
=end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "jdc/cli/populators/base"
|
2
|
+
require "jdc/cli/populators/populator_methods"
|
3
|
+
|
4
|
+
module JDC
|
5
|
+
module Populators
|
6
|
+
class Organization < Base
|
7
|
+
include PopulatorMethods
|
8
|
+
|
9
|
+
def changed
|
10
|
+
info[:space] = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def choices
|
16
|
+
organization_response = client.organizations_first_page(:depth => 0)
|
17
|
+
if organization_response[:next_page]
|
18
|
+
"Login successful. Too many organizations (>50) to list. Remember to set your target organization using 'target -o [ORGANIZATION]'."
|
19
|
+
else
|
20
|
+
organization_response[:results]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid?(organization)
|
25
|
+
return false unless organization.guid
|
26
|
+
organization.users.include? client.current_user
|
27
|
+
rescue JFoundry::APIError
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module JDC
|
2
|
+
module Populators
|
3
|
+
module PopulatorMethods
|
4
|
+
def self.included(klass)
|
5
|
+
klass.class_eval do
|
6
|
+
define_method(:type) do
|
7
|
+
klass.name.split("::").last.downcase.to_sym
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def populate_and_save!
|
13
|
+
obj = get_object
|
14
|
+
info[type] = obj.guid unless obj.nil?
|
15
|
+
save_target_info(info)
|
16
|
+
invalidate_client
|
17
|
+
|
18
|
+
obj
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def get_object
|
24
|
+
previous_object = client.send(type, (info[type])) if info[type]
|
25
|
+
|
26
|
+
if input.has?(type)
|
27
|
+
if respond_to?(:finder_argument, true)
|
28
|
+
object = input[type, finder_argument]
|
29
|
+
else
|
30
|
+
object = input[type]
|
31
|
+
end
|
32
|
+
|
33
|
+
with_progress("Switching to #{type} #{c(object.name, :name)}") {}
|
34
|
+
elsif info[type]
|
35
|
+
object = previous_object if valid?(previous_object)
|
36
|
+
end
|
37
|
+
|
38
|
+
object ||= prompt_user
|
39
|
+
|
40
|
+
if (previous_object != object) && respond_to?(:changed, true)
|
41
|
+
changed
|
42
|
+
end
|
43
|
+
|
44
|
+
object
|
45
|
+
end
|
46
|
+
|
47
|
+
def prompt_user
|
48
|
+
object_choices = choices
|
49
|
+
|
50
|
+
if object_choices.empty?
|
51
|
+
with_progress("There are no #{type}s. You may want to create one with #{c("create-#{type == :organization ? "org" : type}", :good)}.") {}
|
52
|
+
elsif object_choices.is_a?(String)
|
53
|
+
raise JDC::UserFriendlyError.new(object_choices)
|
54
|
+
elsif object_choices.size == 1 && !input.interactive?(type)
|
55
|
+
object_choices.first
|
56
|
+
else
|
57
|
+
ask(type.to_s.capitalize, :choices => object_choices.sort_by(&:name), :display => proc(&:name)).tap do |object|
|
58
|
+
with_progress("Switching to #{type} #{c(object.name, :name)}") {}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "jdc/cli/populators/base"
|
2
|
+
require "jdc/cli/populators/populator_methods"
|
3
|
+
|
4
|
+
module JDC
|
5
|
+
module Populators
|
6
|
+
class Space < Base
|
7
|
+
attr_reader :organization
|
8
|
+
include PopulatorMethods
|
9
|
+
|
10
|
+
def initialize(input, organization)
|
11
|
+
super(input)
|
12
|
+
@organization = organization
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def valid?(space)
|
18
|
+
return false unless space.guid
|
19
|
+
space.developers.include? client.current_user
|
20
|
+
rescue JFoundry::APIError
|
21
|
+
false
|
22
|
+
end
|
23
|
+
|
24
|
+
def choices
|
25
|
+
organization.spaces(:depth => 0)
|
26
|
+
end
|
27
|
+
|
28
|
+
def finder_argument
|
29
|
+
organization
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "jdc/cli/populators/organization"
|
2
|
+
require "jdc/cli/populators/space"
|
3
|
+
|
4
|
+
module JDC
|
5
|
+
module Populators
|
6
|
+
class Target < Base
|
7
|
+
def populate_and_save!
|
8
|
+
organization = JDC::Populators::Organization.new(input).populate_and_save!
|
9
|
+
JDC::Populators::Space.new(input, organization).populate_and_save!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "jdc/cli/route/base"
|
2
|
+
|
3
|
+
module JDC::Route
|
4
|
+
class Delete < Base
|
5
|
+
desc "Delete a route"
|
6
|
+
group :routes
|
7
|
+
input :route, :desc => "Route to unmap", :argument => true,
|
8
|
+
:from_given => find_by_name("route") { client.routes }
|
9
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
10
|
+
:default => proc { force? || interact }
|
11
|
+
|
12
|
+
def delete_route
|
13
|
+
route = input[:route, client.routes]
|
14
|
+
|
15
|
+
return unless input[:really, route]
|
16
|
+
|
17
|
+
with_progress("Deleting route #{c(route.name, :name)}") do
|
18
|
+
route.delete!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def ask_really(route)
|
25
|
+
ask("Really delete #{c(route.name, :name)}?", :default => false)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "jdc/cli/route/base"
|
2
|
+
|
3
|
+
module JDC::Route
|
4
|
+
class Map < Base
|
5
|
+
desc "Add a URL mapping"
|
6
|
+
group :apps, :info
|
7
|
+
input :app, :desc => "Application to add the URL to",
|
8
|
+
:argument => :optional, :from_given => by_name(:app)
|
9
|
+
input :host, :desc => "Host name for the route",
|
10
|
+
:argument => :optional, :default => ""
|
11
|
+
input :domain, :desc => "Domain to add the route to",
|
12
|
+
:argument => true,
|
13
|
+
:from_given => proc { |name, space|
|
14
|
+
space.domain_by_name(name) ||
|
15
|
+
fail_unknown("domain", name)
|
16
|
+
}
|
17
|
+
def map
|
18
|
+
app = input[:app]
|
19
|
+
space = app.space
|
20
|
+
|
21
|
+
host = input[:host]
|
22
|
+
domain = input[:domain, space]
|
23
|
+
|
24
|
+
route = find_or_create_route(domain, host, space)
|
25
|
+
|
26
|
+
bind_route(route, app) if app
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def bind_route(route, app)
|
32
|
+
with_progress("Binding #{c(route.name, :name)} to #{c(app.name, :name)}") do
|
33
|
+
app.add_route(route)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def find_or_create_route(domain, host, space)
|
38
|
+
find_route(domain, host) || create_route(domain, host, space)
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_route(domain, host)
|
42
|
+
client.routes_by_host(host, :depth => 0).find { |r| r.domain == domain }
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_route(domain, host, space)
|
46
|
+
route = client.route
|
47
|
+
route.host = host
|
48
|
+
route.domain = domain
|
49
|
+
route.space = space
|
50
|
+
|
51
|
+
with_progress("Creating route #{c(route.name, :name)}") do
|
52
|
+
route.create!
|
53
|
+
end
|
54
|
+
|
55
|
+
route
|
56
|
+
end
|
57
|
+
|
58
|
+
def find_domain(space, name)
|
59
|
+
domain = space.domain_by_name(name, :depth => 0)
|
60
|
+
fail "Invalid domain '#{name}'" unless domain
|
61
|
+
domain
|
62
|
+
end
|
63
|
+
|
64
|
+
def ask_app
|
65
|
+
ask("Which application?", :choices => client.apps, :display => proc(&:name))
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "jdc/cli/route/base"
|
2
|
+
|
3
|
+
module JDC::Route
|
4
|
+
class Routes < Base
|
5
|
+
desc "List routes in a space"
|
6
|
+
group :routes
|
7
|
+
|
8
|
+
def routes
|
9
|
+
# TODO: scope to space once space.routes is possible
|
10
|
+
routes =
|
11
|
+
with_progress("Getting routes") do
|
12
|
+
client.routes
|
13
|
+
end
|
14
|
+
|
15
|
+
line unless quiet?
|
16
|
+
|
17
|
+
table(
|
18
|
+
%w{host domain},
|
19
|
+
routes.sort_by { |r| "#{r.domain.name} #{r.host}" }.collect { |r|
|
20
|
+
[c(r.host, :name),
|
21
|
+
r.domain.name
|
22
|
+
]
|
23
|
+
})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "jdc/cli/route/base"
|
2
|
+
|
3
|
+
module JDC::Route
|
4
|
+
class Unmap < Base
|
5
|
+
desc "Remove a URL mapping"
|
6
|
+
group :apps, :info
|
7
|
+
input :url, :desc => "URL to unmap", :argument => :optional,
|
8
|
+
:from_given => find_by_name("route") { client.routes }
|
9
|
+
input :app, :desc => "Application to remove the URL from",
|
10
|
+
:argument => :optional, :from_given => by_name(:app)
|
11
|
+
input :all, :desc => "Act on all routes", :type => :boolean
|
12
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
13
|
+
:default => proc { force? || interact }
|
14
|
+
|
15
|
+
def unmap
|
16
|
+
if input[:all]
|
17
|
+
if input.has?(:app)
|
18
|
+
app = target = input[:app]
|
19
|
+
else
|
20
|
+
target = client
|
21
|
+
end
|
22
|
+
|
23
|
+
target.routes.each do |r|
|
24
|
+
begin
|
25
|
+
invoke :unmap, :url => r, :really => true, :app => app
|
26
|
+
rescue JFoundry::APIError => e
|
27
|
+
err "#{e.class}: #{e.message}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
app = input[:app]
|
35
|
+
url = input[:url, app ? app.routes : client.routes]
|
36
|
+
|
37
|
+
if app
|
38
|
+
with_progress("Unbinding #{c(url.name, :name)} from #{c(app.name, :name)}") do
|
39
|
+
app.remove_route(url)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
fail "Missing --app."
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def ask_url(choices)
|
49
|
+
ask("Which URL?", :choices => choices.sort_by(&:name), :display => proc(&:name))
|
50
|
+
end
|
51
|
+
|
52
|
+
def ask_really(name, color)
|
53
|
+
ask("Really delete #{c(name, color)}?", :default => false)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "jdc/cli/service/base"
|
2
|
+
=begin
|
3
|
+
module JDC::Service
|
4
|
+
class Bind < Base
|
5
|
+
desc "Bind a service to an application"
|
6
|
+
group :services, :manage
|
7
|
+
input :service, :desc => "Service to bind", :argument => :optional,
|
8
|
+
:from_given => by_name(:service_instance, "service")
|
9
|
+
input :app, :desc => "Application to bind to", :argument => :optional,
|
10
|
+
:from_given => by_name(:app)
|
11
|
+
def bind_service
|
12
|
+
app = input[:app]
|
13
|
+
service = input[:service, app]
|
14
|
+
finalize
|
15
|
+
|
16
|
+
with_progress(
|
17
|
+
"Binding #{c(service.name, :name)} to #{c(app.name, :name)}") do |s|
|
18
|
+
if app.binds?(service)
|
19
|
+
s.skip do
|
20
|
+
err "App #{b(app.name)} already binds #{b(service.name)}."
|
21
|
+
end
|
22
|
+
else
|
23
|
+
app.bind(service)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def ask_service(app)
|
31
|
+
services = client.service_instances
|
32
|
+
fail "No services." if services.empty?
|
33
|
+
|
34
|
+
ask "Which service?", :choices => services - app.services,
|
35
|
+
:display => proc(&:name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def ask_app
|
39
|
+
ask "Which application?", :choices => client.apps,
|
40
|
+
:display => proc(&:name)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
=end
|