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,37 @@
|
|
1
|
+
require "jdc/cli/service/base"
|
2
|
+
=begin
|
3
|
+
module JDC::Service
|
4
|
+
class Unbind < Base
|
5
|
+
desc "Unbind a service from an application"
|
6
|
+
group :services, :manage
|
7
|
+
input :service, :desc => "Service to unbind", :argument => :optional,
|
8
|
+
:from_given => by_name(:service_instance, :service)
|
9
|
+
input :app, :desc => "Application to unbind from", :argument => :optional,
|
10
|
+
:from_given => by_name(:app)
|
11
|
+
def unbind_service
|
12
|
+
app = input[:app]
|
13
|
+
service = input[:service, app]
|
14
|
+
|
15
|
+
with_progress(
|
16
|
+
"Unbinding #{c(service.name, :name)} from #{c(app.name, :name)}") do
|
17
|
+
app.unbind(service)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def ask_service(app)
|
24
|
+
services = app.services
|
25
|
+
fail "No bound services." if services.empty?
|
26
|
+
|
27
|
+
ask "Which service?", :choices => services,
|
28
|
+
:display => proc(&:name)
|
29
|
+
end
|
30
|
+
|
31
|
+
def ask_app
|
32
|
+
ask "Which application?", :choices => client.apps,
|
33
|
+
:display => proc(&:name)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
=end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "jdc/cli"
|
2
|
+
require "jdc/cli/populators/organization"
|
3
|
+
|
4
|
+
module JDC
|
5
|
+
module Space
|
6
|
+
class Base < CLI
|
7
|
+
attr_reader :org
|
8
|
+
|
9
|
+
def precondition
|
10
|
+
check_key
|
11
|
+
check_target
|
12
|
+
check_organization_and_space
|
13
|
+
#check_logged_in
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(name)
|
17
|
+
@org = JDC::Populators::Organization.new(input).populate_and_save!
|
18
|
+
super(name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.space_by_name
|
22
|
+
proc { |name, org, *_|
|
23
|
+
org.space_by_name(name) ||
|
24
|
+
fail("Unknown space '#{name}'.")
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require "jdc/cli/space/base"
|
2
|
+
=begin
|
3
|
+
module JDC
|
4
|
+
module Space
|
5
|
+
class Create < Base
|
6
|
+
desc "Create a space in an organization"
|
7
|
+
group :spaces
|
8
|
+
input :name, :desc => "Space name", :argument => :optional
|
9
|
+
input :organization, :desc => "Parent organization",
|
10
|
+
:argument => :optional, :aliases => ["--org", "-o"],
|
11
|
+
:from_given => by_name(:organization),
|
12
|
+
:default => proc { client.current_organization }
|
13
|
+
input :target, :desc => "Switch to the space after creation",
|
14
|
+
:alias => "-t", :default => false
|
15
|
+
input :manager, :desc => "Add yourself as manager", :default => true
|
16
|
+
input :developer, :desc => "Add yourself as developer", :default => true
|
17
|
+
input :auditor, :desc => "Add yourself as auditor", :default => false
|
18
|
+
input :find_if_exists, :desc => "Use an existing space if one already exists with the given name", :default => false
|
19
|
+
def create_space
|
20
|
+
space = client.space
|
21
|
+
space.organization = org
|
22
|
+
space.name = input[:name]
|
23
|
+
|
24
|
+
begin
|
25
|
+
with_progress("Creating space #{c(space.name, :name)}") { space.create! }
|
26
|
+
rescue JFoundry::SpaceNameTaken
|
27
|
+
raise unless input[:find_if_exists]
|
28
|
+
space = client.space_by_name(input[:name])
|
29
|
+
already_exists = true
|
30
|
+
end
|
31
|
+
|
32
|
+
if input[:manager]
|
33
|
+
with_progress("Adding you as a manager") { space.add_manager client.current_user }
|
34
|
+
end
|
35
|
+
|
36
|
+
if input[:developer]
|
37
|
+
with_progress("Adding you as a developer") { space.add_developer client.current_user }
|
38
|
+
end
|
39
|
+
|
40
|
+
if input[:auditor]
|
41
|
+
with_progress("Adding you as an auditor") { space.add_auditor client.current_user }
|
42
|
+
end
|
43
|
+
|
44
|
+
if input[:target]
|
45
|
+
invoke :target, :organization => org, :space => space
|
46
|
+
else
|
47
|
+
if already_exists
|
48
|
+
line c("Space already exists!", :good)
|
49
|
+
line
|
50
|
+
line "#{b("jdc switch-space #{space.name}")} # targets existing space"
|
51
|
+
else
|
52
|
+
line c("Space created!", :good)
|
53
|
+
line
|
54
|
+
line "#{b("jdc switch-space #{space.name}")} # targets new space"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def ask_name
|
62
|
+
ask("Name")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
=end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "jdc/cli/space/base"
|
2
|
+
=begin
|
3
|
+
module JDC::Space
|
4
|
+
class Delete < Base
|
5
|
+
desc "Delete a space and its contents"
|
6
|
+
group :spaces
|
7
|
+
input :organization, :desc => "Space's organization",
|
8
|
+
:aliases => ["--org", "-o"], :from_given => by_name(:organization),
|
9
|
+
:default => proc { client.current_organization }
|
10
|
+
input :space, :desc => "Space to delete", :argument => true,
|
11
|
+
:from_given => space_by_name
|
12
|
+
input :recursive, :desc => "Delete recursively", :alias => "-r",
|
13
|
+
:default => false, :forget => true
|
14
|
+
input :warn, :desc => "Show warning if it was the last space",
|
15
|
+
:default => true
|
16
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
17
|
+
:default => proc { force? || interact }
|
18
|
+
|
19
|
+
def delete_space
|
20
|
+
space = input[:space, org]
|
21
|
+
|
22
|
+
return unless input[:really, space]
|
23
|
+
|
24
|
+
deleting_current_space = (space == client.current_space)
|
25
|
+
|
26
|
+
with_progress("Deleting space #{c(space.name, :name)}") do
|
27
|
+
if input[:recursive]
|
28
|
+
space.delete!(:recursive => true)
|
29
|
+
else
|
30
|
+
space.delete!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if deleting_current_space
|
35
|
+
line
|
36
|
+
line c("The space that you were targeting has now been deleted. Please use #{b("`jdc target -s SPACE_NAME`")} to target a different one.", :warning)
|
37
|
+
end
|
38
|
+
rescue JFoundry::AssociationNotEmpty => boom
|
39
|
+
line
|
40
|
+
line c(boom.description, :bad)
|
41
|
+
line c("If you want to delete the space along with all dependent objects, rerun the command with the #{b("'--recursive'")} flag.", :bad)
|
42
|
+
exit_status(1)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def ask_really(space)
|
48
|
+
ask("Really delete #{c(space.name, :name)}?", :default => false)
|
49
|
+
end
|
50
|
+
|
51
|
+
def ask_recursive
|
52
|
+
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
=end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "jdc/cli/space/base"
|
2
|
+
|
3
|
+
module JDC::Space
|
4
|
+
class Rename < Base
|
5
|
+
desc "Rename a space"
|
6
|
+
group :spaces
|
7
|
+
input :organization, :desc => "Space's organization",
|
8
|
+
:aliases => ["--org", "-o"], :from_given => by_name(:organization),
|
9
|
+
:default => proc { client.current_organization }
|
10
|
+
input :space, :desc => "Space to rename", :argument => :optional,
|
11
|
+
:from_given => by_name(:space)
|
12
|
+
input :name, :desc => "New space name", :argument => :optional
|
13
|
+
def rename_space
|
14
|
+
space = input[:space, org]
|
15
|
+
name = input[:name]
|
16
|
+
|
17
|
+
space.name = name
|
18
|
+
|
19
|
+
with_progress("Renaming to #{c(name, :name)}") do
|
20
|
+
space.update!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def ask_space(org)
|
27
|
+
spaces = org.spaces
|
28
|
+
fail "No spaces." if spaces.empty?
|
29
|
+
|
30
|
+
ask("Rename which space?", :choices => spaces.sort_by(&:name),
|
31
|
+
:display => proc(&:name))
|
32
|
+
end
|
33
|
+
|
34
|
+
def ask_name
|
35
|
+
ask("New name")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "jdc/cli/space/base"
|
2
|
+
|
3
|
+
module JDC
|
4
|
+
module Space
|
5
|
+
class Space < Base
|
6
|
+
desc "Show space information"
|
7
|
+
group :spaces
|
8
|
+
input :organization, :desc => "Space's organization",
|
9
|
+
:aliases => %w{--org -o},
|
10
|
+
:default => proc { client.current_organization },
|
11
|
+
:from_given => by_name(:organization)
|
12
|
+
input :space, :desc => "Space to show", :argument => :optional,
|
13
|
+
:default => proc { client.current_space },
|
14
|
+
:from_given => space_by_name
|
15
|
+
input :full, :desc => "Show full information for apps, services, etc.",
|
16
|
+
:default => false
|
17
|
+
|
18
|
+
def space
|
19
|
+
space = JDC::Populators::Space.new(input, org).populate_and_save!
|
20
|
+
|
21
|
+
unless space
|
22
|
+
return if quiet?
|
23
|
+
fail "No current space."
|
24
|
+
end
|
25
|
+
|
26
|
+
if quiet?
|
27
|
+
puts space.name
|
28
|
+
return
|
29
|
+
end
|
30
|
+
|
31
|
+
line "#{c(space.name, :name)}:"
|
32
|
+
|
33
|
+
indented do
|
34
|
+
line "organization: #{c(space.organization.name, :name)}"
|
35
|
+
|
36
|
+
if input[:full]
|
37
|
+
line
|
38
|
+
line "apps:"
|
39
|
+
|
40
|
+
spaced(space.apps(:depth => 2)) do |a|
|
41
|
+
indented do
|
42
|
+
invoke :app, :app => a
|
43
|
+
end
|
44
|
+
end
|
45
|
+
else
|
46
|
+
line "apps: #{name_list(space.apps)}"
|
47
|
+
end
|
48
|
+
|
49
|
+
if input[:full]
|
50
|
+
line
|
51
|
+
line "services:"
|
52
|
+
spaced(space.service_instances(:depth => 2)) do |s|
|
53
|
+
indented do
|
54
|
+
invoke :service, :service => s
|
55
|
+
end
|
56
|
+
end
|
57
|
+
else
|
58
|
+
line "services: #{name_list(space.service_instances)}"
|
59
|
+
end
|
60
|
+
|
61
|
+
line "domains: #{name_list(space.domains)}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "jdc/cli/space/base"
|
2
|
+
|
3
|
+
module JDC
|
4
|
+
module Space
|
5
|
+
class Spaces < Base
|
6
|
+
desc "List spaces in an organization"
|
7
|
+
group :spaces
|
8
|
+
input :organization, :desc => "Organization to list spaces from",
|
9
|
+
:aliases => %w{--org -o}, :argument => :optional,
|
10
|
+
:from_given => by_name(:organization),
|
11
|
+
:default => proc { client.current_organization }
|
12
|
+
input :name, :desc => "Filter by name"
|
13
|
+
input :full, :desc => "Show full information for apps, services, etc.",
|
14
|
+
:default => false
|
15
|
+
|
16
|
+
def spaces
|
17
|
+
spaces =
|
18
|
+
with_progress("Getting spaces in #{c(org.name, :name)}") do
|
19
|
+
org.spaces(:depth => quiet? ? 0 : 1).sort_by(&:name)
|
20
|
+
end
|
21
|
+
|
22
|
+
return if spaces.empty?
|
23
|
+
|
24
|
+
line unless quiet?
|
25
|
+
|
26
|
+
spaces.reject! do |s|
|
27
|
+
!space_matches?(s, input)
|
28
|
+
end
|
29
|
+
|
30
|
+
if input[:full]
|
31
|
+
spaced(spaces) do |s|
|
32
|
+
invoke :space, :space => s, :full => input[:full]
|
33
|
+
end
|
34
|
+
else
|
35
|
+
table(
|
36
|
+
%w{name apps services},
|
37
|
+
spaces.collect { |s|
|
38
|
+
[c(s.name, :name),
|
39
|
+
name_list(s.apps),
|
40
|
+
name_list(s.service_instances)
|
41
|
+
]
|
42
|
+
})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def space_matches?(s, options)
|
49
|
+
if name = options[:name]
|
50
|
+
return false if s.name !~ /#{name}/
|
51
|
+
end
|
52
|
+
|
53
|
+
true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "jdc/cli/space/base"
|
2
|
+
=begin
|
3
|
+
module JDC::Space
|
4
|
+
class Switch < Base
|
5
|
+
desc "Switch to a space"
|
6
|
+
group :spaces
|
7
|
+
input :name, :desc => "Space name", :argument => true
|
8
|
+
def switch_space
|
9
|
+
space = client.space_by_name(input[:name])
|
10
|
+
|
11
|
+
if space
|
12
|
+
invoke :target, :space => space
|
13
|
+
else
|
14
|
+
raise JDC::UserError, "The space #{input[:name]} does not exist, please create the space first."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
=end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "jdc/cli"
|
2
|
+
|
3
|
+
module JDC
|
4
|
+
module Start
|
5
|
+
class Base < CLI
|
6
|
+
|
7
|
+
# Make sure we only show the target once
|
8
|
+
@@displayed_target = false
|
9
|
+
|
10
|
+
def precondition
|
11
|
+
check_key
|
12
|
+
check_organization_and_space
|
13
|
+
#check_logged_in
|
14
|
+
end
|
15
|
+
|
16
|
+
def displayed_target?
|
17
|
+
@@displayed_target
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def show_context
|
23
|
+
return if quiet? || displayed_target?
|
24
|
+
|
25
|
+
display_target
|
26
|
+
|
27
|
+
line
|
28
|
+
|
29
|
+
@@displayed_target = true
|
30
|
+
end
|
31
|
+
|
32
|
+
def display_target
|
33
|
+
if quiet?
|
34
|
+
line client.target
|
35
|
+
else
|
36
|
+
line "target: #{c(client.target, :name)}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "jdc/cli/start/base"
|
2
|
+
require "jdc/cli/populators/target"
|
3
|
+
|
4
|
+
module JDC::Start
|
5
|
+
class Target < Base
|
6
|
+
desc "Set or display the target cloud, organization, and space"
|
7
|
+
group :start
|
8
|
+
input :url, :desc => "Target URL to switch to", :argument => :optional
|
9
|
+
input :organization, :desc => "Organization" , :aliases => %w{--org -o},
|
10
|
+
:from_given => by_name(:organization)
|
11
|
+
input :space, :desc => "Space", :alias => "-s",
|
12
|
+
:from_given => by_name(:space)
|
13
|
+
|
14
|
+
def target
|
15
|
+
unless input.has?(:url) || input.has?(:organization) || input.has?(:space)
|
16
|
+
TargetPrettifier.prettify(client, self)
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
if input.has?(:url)
|
21
|
+
target = sane_target_url(input[:url])
|
22
|
+
with_progress("Setting target to #{c(target, :name)}") do
|
23
|
+
begin
|
24
|
+
build_client(target).info # check that it's valid before setting
|
25
|
+
rescue JFoundry::TargetRefused
|
26
|
+
fail "Target refused connection."
|
27
|
+
rescue JFoundry::InvalidTarget
|
28
|
+
fail "Invalid target URI."
|
29
|
+
end
|
30
|
+
|
31
|
+
set_target(target)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#return unless client.logged_in?
|
36
|
+
if input.has?(:organization) || input.has?(:space)
|
37
|
+
JDC::Populators::Target.new(input).populate_and_save!
|
38
|
+
end
|
39
|
+
|
40
|
+
return if quiet?
|
41
|
+
|
42
|
+
invalidate_client
|
43
|
+
|
44
|
+
line
|
45
|
+
TargetPrettifier.prettify(client, self)
|
46
|
+
end
|
47
|
+
|
48
|
+
public :c
|
49
|
+
end
|
50
|
+
end
|