jdc 0.2.1.pre → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +24 -1277
- data/README.md +102 -0
- data/bin/jdc +2 -12
- data/{lib/tunnel/helper-app → caldecott_helper}/server.rb +5 -5
- data/{lib/tunnel/config → config}/clients.yml +2 -2
- data/config/micro/paths.yml +22 -0
- data/config/micro/refresh_ip.rb +20 -0
- data/lib/cli/commands/admin.rb +58 -0
- data/lib/cli/commands/apps.rb +1129 -0
- data/lib/cli/commands/base.rb +228 -0
- data/lib/cli/commands/manifest.rb +56 -0
- data/lib/cli/commands/micro.rb +115 -0
- data/lib/cli/commands/misc.rb +126 -0
- data/lib/cli/commands/services.rb +178 -0
- data/lib/cli/commands/user.rb +14 -0
- data/lib/cli/config.rb +173 -0
- data/lib/cli/console_helper.rb +170 -0
- data/lib/cli/core_ext.rb +122 -0
- data/lib/cli/errors.rb +19 -0
- data/lib/cli/frameworks.rb +265 -0
- data/lib/cli/manifest_helper.rb +300 -0
- data/lib/cli/runner.rb +505 -0
- data/lib/cli/services_helper.rb +84 -0
- data/lib/cli/tunnel_helper.rb +332 -0
- data/lib/cli/usage.rb +86 -0
- data/lib/cli/version.rb +7 -0
- data/lib/cli/zip_util.rb +77 -0
- data/lib/cli.rb +53 -0
- data/lib/jdc/client.rb +457 -0
- data/lib/jdc/const.rb +25 -0
- data/lib/jdc/micro/switcher/base.rb +97 -0
- data/lib/{micro → jdc/micro}/switcher/darwin.rb +3 -5
- data/lib/{micro → jdc/micro}/switcher/dummy.rb +1 -1
- data/lib/jdc/micro/switcher/linux.rb +16 -0
- data/lib/{micro → jdc/micro}/switcher/windows.rb +5 -5
- data/lib/{micro → jdc/micro}/vmrun.rb +19 -26
- data/lib/{micro → jdc}/micro.rb +15 -15
- data/lib/jdc/signature/version.rb +27 -0
- data/lib/jdc/signer.rb +13 -0
- data/lib/jdc/timer.rb +12 -0
- data/lib/jdc.rb +2 -15
- metadata +210 -360
- data/Rakefile +0 -13
- data/lib/admin/README.md +0 -15
- data/lib/admin/curl.rb +0 -60
- data/lib/admin/guid.rb +0 -89
- data/lib/admin/plugin.rb +0 -6
- data/lib/admin/service_auth_token.rb +0 -94
- data/lib/admin/service_broker/add.rb +0 -47
- data/lib/admin/service_broker/service_brokers.rb +0 -24
- data/lib/admin/set_quota.rb +0 -44
- data/lib/console/README.md +0 -8
- data/lib/console/console.rb +0 -187
- data/lib/console/plugin.rb +0 -33
- data/lib/jdc/cli/app/app.rb +0 -43
- data/lib/jdc/cli/app/apps.rb +0 -87
- data/lib/jdc/cli/app/base.rb +0 -72
- data/lib/jdc/cli/app/delete.rb +0 -95
- data/lib/jdc/cli/app/deprecated.rb +0 -11
- data/lib/jdc/cli/app/env.rb +0 -78
- data/lib/jdc/cli/app/events.rb +0 -45
- data/lib/jdc/cli/app/files.rb +0 -137
- data/lib/jdc/cli/app/health.rb +0 -26
- data/lib/jdc/cli/app/instances.rb +0 -53
- data/lib/jdc/cli/app/logs.rb +0 -76
- data/lib/jdc/cli/app/push/create.rb +0 -108
- data/lib/jdc/cli/app/push/interactions.rb +0 -86
- data/lib/jdc/cli/app/push/sync.rb +0 -57
- data/lib/jdc/cli/app/push.rb +0 -103
- data/lib/jdc/cli/app/rename.rb +0 -35
- data/lib/jdc/cli/app/restart.rb +0 -31
- data/lib/jdc/cli/app/scale.rb +0 -63
- data/lib/jdc/cli/app/start.rb +0 -161
- data/lib/jdc/cli/app/stats.rb +0 -67
- data/lib/jdc/cli/app/stop.rb +0 -27
- data/lib/jdc/cli/domain/base.rb +0 -9
- data/lib/jdc/cli/domain/domains.rb +0 -40
- data/lib/jdc/cli/domain/map.rb +0 -55
- data/lib/jdc/cli/domain/unmap.rb +0 -56
- data/lib/jdc/cli/help.rb +0 -15
- data/lib/jdc/cli/interactive.rb +0 -105
- data/lib/jdc/cli/login_requirements.rb +0 -15
- data/lib/jdc/cli/organization/base.rb +0 -14
- data/lib/jdc/cli/organization/create.rb +0 -37
- data/lib/jdc/cli/organization/delete.rb +0 -63
- data/lib/jdc/cli/organization/org.rb +0 -45
- data/lib/jdc/cli/organization/orgs.rb +0 -30
- data/lib/jdc/cli/organization/rename.rb +0 -37
- data/lib/jdc/cli/populators/base.rb +0 -16
- data/lib/jdc/cli/populators/organization.rb +0 -32
- data/lib/jdc/cli/populators/populator_methods.rb +0 -64
- data/lib/jdc/cli/populators/space.rb +0 -33
- data/lib/jdc/cli/populators/target.rb +0 -13
- data/lib/jdc/cli/route/base.rb +0 -9
- data/lib/jdc/cli/route/delete.rb +0 -28
- data/lib/jdc/cli/route/map.rb +0 -68
- data/lib/jdc/cli/route/routes.rb +0 -26
- data/lib/jdc/cli/route/unmap.rb +0 -56
- data/lib/jdc/cli/service/base.rb +0 -9
- data/lib/jdc/cli/service/bind.rb +0 -44
- data/lib/jdc/cli/service/create.rb +0 -159
- data/lib/jdc/cli/service/delete.rb +0 -83
- data/lib/jdc/cli/service/rename.rb +0 -36
- data/lib/jdc/cli/service/service.rb +0 -42
- data/lib/jdc/cli/service/service_instance_helper.rb +0 -99
- data/lib/jdc/cli/service/services.rb +0 -111
- data/lib/jdc/cli/service/unbind.rb +0 -37
- data/lib/jdc/cli/space/base.rb +0 -29
- data/lib/jdc/cli/space/create.rb +0 -67
- data/lib/jdc/cli/space/delete.rb +0 -56
- data/lib/jdc/cli/space/rename.rb +0 -38
- data/lib/jdc/cli/space/space.rb +0 -66
- data/lib/jdc/cli/space/spaces.rb +0 -57
- data/lib/jdc/cli/space/switch.rb +0 -19
- data/lib/jdc/cli/start/base.rb +0 -41
- data/lib/jdc/cli/start/colors.rb +0 -13
- data/lib/jdc/cli/start/target.rb +0 -50
- data/lib/jdc/cli/start/target_prettifier.rb +0 -17
- data/lib/jdc/cli/start/targets.rb +0 -16
- data/lib/jdc/cli/user/base.rb +0 -30
- data/lib/jdc/cli/user/create.rb +0 -52
- data/lib/jdc/cli/user/passwd.rb +0 -37
- data/lib/jdc/cli/user/register.rb +0 -43
- data/lib/jdc/cli/user/users.rb +0 -32
- data/lib/jdc/cli.rb +0 -556
- data/lib/jdc/constants.rb +0 -11
- data/lib/jdc/errors.rb +0 -19
- data/lib/jdc/object_extensions.rb +0 -15
- data/lib/jdc/plugin.rb +0 -56
- data/lib/jdc/spacing.rb +0 -89
- data/lib/jdc/spec_helper.rb +0 -1
- data/lib/jdc/test_support.rb +0 -6
- data/lib/jdc/version.rb +0 -3
- data/lib/manifests/errors.rb +0 -35
- data/lib/manifests/loader/builder.rb +0 -39
- data/lib/manifests/loader/normalizer.rb +0 -145
- data/lib/manifests/loader/resolver.rb +0 -79
- data/lib/manifests/loader.rb +0 -31
- data/lib/manifests/manifests.rb +0 -344
- data/lib/manifests/plugin.rb +0 -140
- data/lib/micro/README.md +0 -9
- data/lib/micro/errors.rb +0 -4
- data/lib/micro/plugin.rb +0 -197
- data/lib/micro/switcher/base.rb +0 -79
- data/lib/micro/switcher/linux.rb +0 -16
- data/lib/tasks/gem_release.rake +0 -42
- data/lib/tunnel/README.md +0 -29
- data/lib/tunnel/helper-app/Gemfile +0 -10
- data/lib/tunnel/helper-app/Gemfile.lock +0 -48
- data/lib/tunnel/plugin.rb +0 -183
- data/lib/tunnel/tunnel.rb +0 -295
data/lib/jdc/cli/app/stats.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require "jdc/cli/app/base"
|
2
|
-
|
3
|
-
module JDC::App
|
4
|
-
class Stats < Base
|
5
|
-
desc "Display application instance status"
|
6
|
-
group :apps, :info
|
7
|
-
input :app, :desc => "Application to get the stats for",
|
8
|
-
:argument => true, :from_given => by_name(:app)
|
9
|
-
def stats
|
10
|
-
app = input[:app]
|
11
|
-
|
12
|
-
stats =
|
13
|
-
with_progress("Getting stats for #{c(app.name, :name)}") do |s|
|
14
|
-
begin
|
15
|
-
app.stats
|
16
|
-
rescue JFoundry::StatsError
|
17
|
-
s.fail do
|
18
|
-
err "Application #{b(app.name)} is not running."
|
19
|
-
return
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
line unless quiet?
|
25
|
-
|
26
|
-
table(
|
27
|
-
%w{instance cpu memory disk},
|
28
|
-
stats.sort_by { |idx, _| idx.to_i }.collect { |idx, info|
|
29
|
-
idx = c("\##{idx}", :instance)
|
30
|
-
|
31
|
-
if info[:state] == "DOWN"
|
32
|
-
[idx, c("down", :bad)]
|
33
|
-
else
|
34
|
-
stats = info[:stats]
|
35
|
-
usage = stats[:usage]
|
36
|
-
|
37
|
-
if usage
|
38
|
-
[ idx,
|
39
|
-
"#{percentage(usage[:cpu])}",
|
40
|
-
"#{usage(usage[:mem], stats[:mem_quota])}",
|
41
|
-
"#{usage(usage[:disk], stats[:disk_quota])}"
|
42
|
-
]
|
43
|
-
else
|
44
|
-
[idx, c("n/a", :neutral)]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
})
|
48
|
-
end
|
49
|
-
|
50
|
-
def percentage(num, low = 50, mid = 70)
|
51
|
-
color =
|
52
|
-
if num <= low
|
53
|
-
:good
|
54
|
-
elsif num <= mid
|
55
|
-
:warning
|
56
|
-
else
|
57
|
-
:bad
|
58
|
-
end
|
59
|
-
|
60
|
-
c(format("%.1f\%", num), color)
|
61
|
-
end
|
62
|
-
|
63
|
-
def usage(used, limit)
|
64
|
-
"#{b(human_size(used))} of #{b(human_size(limit, 0))}"
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/lib/jdc/cli/app/stop.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require "jdc/cli/app/base"
|
2
|
-
|
3
|
-
module JDC::App
|
4
|
-
class Stop < Base
|
5
|
-
desc "Stop an application"
|
6
|
-
group :apps, :manage
|
7
|
-
input :apps, :desc => "Applications to start", :argument => :splat,
|
8
|
-
:singular => :app, :from_given => by_name(:app)
|
9
|
-
input :all, :desc => "Stop all applications", :default => false
|
10
|
-
def stop
|
11
|
-
apps = input[:all] ? client.apps : input[:apps]
|
12
|
-
fail "No applications given." if apps.empty?
|
13
|
-
|
14
|
-
apps.each do |app|
|
15
|
-
with_progress("Stopping #{c(app.name, :name)}") do |s|
|
16
|
-
if app.stopped?
|
17
|
-
s.skip do
|
18
|
-
err "Application is not running."
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
app.stop!
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/jdc/cli/domain/base.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require "jdc/cli/domain/base"
|
2
|
-
|
3
|
-
module JDC::Domain
|
4
|
-
class Domains < Base
|
5
|
-
desc "List domains in a space"
|
6
|
-
group :domains
|
7
|
-
input :space, :desc => "Space to list the domains from",
|
8
|
-
:argument => :optional, :default => proc { client.current_space },
|
9
|
-
:from_given => by_name(:space)
|
10
|
-
input :all, :desc => "List all domains", :default => false
|
11
|
-
def domains
|
12
|
-
space = input[:space]
|
13
|
-
|
14
|
-
domains =
|
15
|
-
if input[:all]
|
16
|
-
with_progress("Getting all domains") do
|
17
|
-
client.domains
|
18
|
-
end
|
19
|
-
else
|
20
|
-
with_progress("Getting domains in #{c(space.name, :name)}") do
|
21
|
-
space.domains
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
line unless quiet?
|
26
|
-
|
27
|
-
table(
|
28
|
-
%w{name owner},
|
29
|
-
domains.sort_by(&:name).collect { |r|
|
30
|
-
[c(r.name, :name),
|
31
|
-
if org = r.owning_organization
|
32
|
-
c(org.name, :name)
|
33
|
-
else
|
34
|
-
d("none")
|
35
|
-
end
|
36
|
-
]
|
37
|
-
})
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
data/lib/jdc/cli/domain/map.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require "jdc/cli/domain/base"
|
2
|
-
|
3
|
-
module JDC::Domain
|
4
|
-
class Map < Base
|
5
|
-
desc "Map a domain to an organization or space"
|
6
|
-
group :domains
|
7
|
-
input :name, :desc => "Domain to map", :argument => :required
|
8
|
-
input :organization, :desc => "Organization to map the domain to",
|
9
|
-
:aliases => %w{--org -o},
|
10
|
-
:default => proc { client.current_organization },
|
11
|
-
:from_given => by_name(:organization)
|
12
|
-
input :space, :desc => "Space to map the domain to",
|
13
|
-
:default => proc { client.current_space },
|
14
|
-
:from_given => by_name(:space)
|
15
|
-
input :shared, :desc => "Create a shared domain", :default => false
|
16
|
-
def map_domain
|
17
|
-
domain = client.domain_by_name(input[:name])
|
18
|
-
|
19
|
-
given_org = input.has?(:organization)
|
20
|
-
given_space = input.has?(:space)
|
21
|
-
|
22
|
-
org = input[:organization]
|
23
|
-
space = input[:space]
|
24
|
-
|
25
|
-
given_space = true unless given_org || given_space
|
26
|
-
|
27
|
-
unless domain
|
28
|
-
domain = client.domain
|
29
|
-
domain.name = input[:name]
|
30
|
-
domain.owning_organization = org unless input[:shared]
|
31
|
-
domain.wildcard = true
|
32
|
-
|
33
|
-
with_progress("Creating domain #{c(domain.name, :name)}") do
|
34
|
-
domain.create!
|
35
|
-
org.add_domain(domain) if org && !given_org && !given_space
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
if given_space
|
40
|
-
add_domain(domain, space.organization)
|
41
|
-
add_domain(domain, space)
|
42
|
-
elsif given_org
|
43
|
-
add_domain(domain, org)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def add_domain(domain, target)
|
50
|
-
with_progress("Mapping #{c(domain.name, :name)} to #{c(target.name, :name)}") do
|
51
|
-
target.add_domain(domain)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/jdc/cli/domain/unmap.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
require "jdc/cli/domain/base"
|
2
|
-
|
3
|
-
module JDC::Domain
|
4
|
-
class Unmap < Base
|
5
|
-
desc "Unmap a domain from an organization or space"
|
6
|
-
group :domains
|
7
|
-
input :domain, :desc => "Domain to unmap", :argument => :required,
|
8
|
-
:from_given => by_name("domain")
|
9
|
-
input :organization, :desc => "Organization to unmap the domain from",
|
10
|
-
:aliases => %w{--org -o},
|
11
|
-
:default => proc { client.current_organization },
|
12
|
-
:from_given => by_name(:organization)
|
13
|
-
input :space, :desc => "Space to unmap the domain from",
|
14
|
-
:default => proc { client.current_space },
|
15
|
-
:from_given => by_name(:space)
|
16
|
-
input :delete, :desc => "Delete domain", :type => :boolean
|
17
|
-
input :really, :type => :boolean, :forget => true, :hidden => true,
|
18
|
-
:default => proc { force? || interact }
|
19
|
-
def unmap_domain
|
20
|
-
domain = input[:domain]
|
21
|
-
|
22
|
-
given_org = input.has?(:organization)
|
23
|
-
given_space = input.has?(:space)
|
24
|
-
|
25
|
-
org = input[:organization]
|
26
|
-
space = input[:space]
|
27
|
-
|
28
|
-
if input[:delete]
|
29
|
-
return unless input[:really, domain.name, :name]
|
30
|
-
|
31
|
-
with_progress("Deleting domain #{c(domain.name, :name)}") do
|
32
|
-
domain.delete!
|
33
|
-
end
|
34
|
-
|
35
|
-
return
|
36
|
-
end
|
37
|
-
|
38
|
-
given_space = true unless given_org || given_space
|
39
|
-
|
40
|
-
remove_domain(domain, space) if given_space
|
41
|
-
remove_domain(domain, org) if given_org
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def remove_domain(domain, target)
|
47
|
-
with_progress("Unmapping #{c(domain.name, :name)} from #{c(target.name, :name)}") do
|
48
|
-
target.remove_domain(domain)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def ask_really(name, color)
|
53
|
-
ask("Really delete #{c(name, color)}?", :default => false)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
data/lib/jdc/cli/help.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require "mothership/help"
|
2
|
-
|
3
|
-
Mothership::Help.groups(
|
4
|
-
[:start, "Getting Started"],
|
5
|
-
[:apps, "Applications",
|
6
|
-
[:manage, "Management"],
|
7
|
-
[:info, "Information"]],
|
8
|
-
#[:services, "Services",
|
9
|
-
# [:manage, "Management"]],
|
10
|
-
[:organizations, "Organizations"],
|
11
|
-
[:spaces, "Spaces"],
|
12
|
-
[:routes, "Routes"],
|
13
|
-
[:domains, "Domains"],
|
14
|
-
[:admin, "Administration",
|
15
|
-
[:user, "User Management"]])
|
data/lib/jdc/cli/interactive.rb
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
require "interact"
|
2
|
-
require "interact/pretty"
|
3
|
-
require "interact/progress"
|
4
|
-
|
5
|
-
module JDC
|
6
|
-
module Interactive
|
7
|
-
include ::Interactive::Rewindable
|
8
|
-
include Interact::Pretty
|
9
|
-
include Interact::Progress
|
10
|
-
|
11
|
-
def ask(question, options = {})
|
12
|
-
if force? and options.key?(:default)
|
13
|
-
options[:default]
|
14
|
-
else
|
15
|
-
super
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def list_choices(choices, options = {})
|
20
|
-
choices.each_with_index do |o, i|
|
21
|
-
puts "#{c(i + 1, :number)}: #{show_choice(o, options)}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def input_state(options)
|
26
|
-
if options.key? :default
|
27
|
-
answer = show_default(options)
|
28
|
-
end
|
29
|
-
|
30
|
-
JDCState.new(options, answer)
|
31
|
-
end
|
32
|
-
|
33
|
-
def show_default(options)
|
34
|
-
case options[:default]
|
35
|
-
when true
|
36
|
-
"y"
|
37
|
-
when false
|
38
|
-
"n"
|
39
|
-
when nil
|
40
|
-
""
|
41
|
-
else
|
42
|
-
show_choice(options[:default], options)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def prompt(question, options)
|
47
|
-
value = show_default(options)
|
48
|
-
|
49
|
-
print "#{question}"
|
50
|
-
print c("> ", :prompt)
|
51
|
-
|
52
|
-
unless value.empty?
|
53
|
-
print "#{d(value) + "\b" * value.size}"
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def handler(event, state)
|
58
|
-
ans = state.answer
|
59
|
-
pos = state.position
|
60
|
-
|
61
|
-
exit if event == :eof
|
62
|
-
|
63
|
-
if state.default?
|
64
|
-
if event.is_a?(Array) and event[0] == :key
|
65
|
-
# initial non-movement keypress clears default answer
|
66
|
-
clear_input(state)
|
67
|
-
else
|
68
|
-
# wipe away any coloring
|
69
|
-
redraw_input(state)
|
70
|
-
end
|
71
|
-
|
72
|
-
state.clear_default! if(event != :up)
|
73
|
-
|
74
|
-
# tab with a default accepts it and moves to the end
|
75
|
-
if event == :tab
|
76
|
-
state.goto(ans.size)
|
77
|
-
else
|
78
|
-
super
|
79
|
-
end
|
80
|
-
else
|
81
|
-
super
|
82
|
-
end
|
83
|
-
|
84
|
-
print "\n" if event == :enter
|
85
|
-
end
|
86
|
-
|
87
|
-
class JDCState < ::Interactive::InputState
|
88
|
-
def initialize(options = {}, answer = nil, position = 0)
|
89
|
-
@options = options
|
90
|
-
@answer = answer || ""
|
91
|
-
@default = options.key? :default
|
92
|
-
@position = position
|
93
|
-
@done = false
|
94
|
-
end
|
95
|
-
|
96
|
-
def clear_default!
|
97
|
-
@default = false
|
98
|
-
end
|
99
|
-
|
100
|
-
def default?
|
101
|
-
@default
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module LoginRequirements
|
2
|
-
def precondition
|
3
|
-
check_key
|
4
|
-
check_organization_and_space
|
5
|
-
#check_logged_in
|
6
|
-
|
7
|
-
unless client.current_organization
|
8
|
-
fail "Please select an organization with 'jdc target --organization ORGANIZATION_NAME'. (Get organization names from 'jdc orgs'.)"
|
9
|
-
end
|
10
|
-
|
11
|
-
unless client.current_space
|
12
|
-
fail "Please select a space with 'jdc target --space SPACE_NAME'. (Get space names from 'jdc spaces'.)"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "jdc/cli/organization/base"
|
2
|
-
=begin
|
3
|
-
module JDC::Organization
|
4
|
-
class Create < Base
|
5
|
-
desc "Create an organization"
|
6
|
-
group :organizations
|
7
|
-
input :name, :desc => "Organization name", :argument => :optional
|
8
|
-
input :target, :desc => "Switch to the organization after creation",
|
9
|
-
:alias => "-t", :default => true
|
10
|
-
input :add_self, :desc => "Add yourself to the organization",
|
11
|
-
:default => true
|
12
|
-
input :find_if_exists, :desc => "Use an existing organization if one already exists with the given name", :default => false
|
13
|
-
def create_org
|
14
|
-
org = client.organization
|
15
|
-
org.name = input[:name]
|
16
|
-
org.users = [client.current_user] if input[:add_self]
|
17
|
-
|
18
|
-
begin
|
19
|
-
with_progress("Creating organization #{c(org.name, :name)}") { org.create! }
|
20
|
-
rescue JFoundry::OrganizationNameTaken
|
21
|
-
raise unless input[:find_if_exists]
|
22
|
-
org = client.organization_by_name(input[:name])
|
23
|
-
end
|
24
|
-
|
25
|
-
if input[:target]
|
26
|
-
invoke :target, :organization => org
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def ask_name
|
33
|
-
ask("Name")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
=end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require "jdc/cli/organization/base"
|
2
|
-
=begin
|
3
|
-
module JDC::Organization
|
4
|
-
class Delete < Base
|
5
|
-
desc "Delete an organization"
|
6
|
-
group :organizations
|
7
|
-
input :organization, :desc => "Organization to delete",
|
8
|
-
:aliases => %w{--org -o}, :argument => :optional,
|
9
|
-
:from_given => by_name(:organization)
|
10
|
-
input :recursive, :desc => "Delete recursively", :alias => "-r",
|
11
|
-
:default => false, :forget => true
|
12
|
-
input :warn, :desc => "Show warning if it was the last org",
|
13
|
-
:default => true
|
14
|
-
input :really, :type => :boolean, :forget => true, :hidden => true,
|
15
|
-
:default => proc { force? || interact }
|
16
|
-
def delete_org
|
17
|
-
org = input[:organization]
|
18
|
-
return unless input[:really, org]
|
19
|
-
|
20
|
-
is_current = org == client.current_organization
|
21
|
-
@orgs ||= client.organizations(:depth => 0)
|
22
|
-
with_progress("Deleting organization #{c(org.name, :name)}") do
|
23
|
-
deleted = org.delete!(:recursive => !!input[:recursive])
|
24
|
-
@orgs.delete(org) if deleted
|
25
|
-
end
|
26
|
-
|
27
|
-
if @orgs.empty?
|
28
|
-
return unless input[:warn]
|
29
|
-
|
30
|
-
line
|
31
|
-
line c("There are no longer any organizations.", :warning)
|
32
|
-
line "You may want to create one with #{c("create-org", :good)}."
|
33
|
-
elsif is_current
|
34
|
-
invalidate_client
|
35
|
-
invoke :target
|
36
|
-
end
|
37
|
-
rescue JFoundry::AssociationNotEmpty => boom
|
38
|
-
line
|
39
|
-
line c(boom.description, :bad)
|
40
|
-
line c("If you want to delete the organization along with all dependent objects, rerun the command with the #{b("'--recursive'")} flag.", :bad)
|
41
|
-
exit_status(1)
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def ask_organization
|
47
|
-
@orgs = client.organizations(:depth => 0)
|
48
|
-
fail "No organizations." if @orgs.empty?
|
49
|
-
|
50
|
-
ask("Which organization", :choices => @orgs.sort_by(&:name),
|
51
|
-
:display => proc(&:name))
|
52
|
-
end
|
53
|
-
|
54
|
-
def ask_really(org)
|
55
|
-
ask("Really delete #{c(org.name, :name)}?", :default => false)
|
56
|
-
end
|
57
|
-
|
58
|
-
def ask_recursive
|
59
|
-
ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
=end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require "jdc/cli/organization/base"
|
2
|
-
|
3
|
-
module JDC::Organization
|
4
|
-
class Org < Base
|
5
|
-
desc "Show organization information"
|
6
|
-
group :organizations
|
7
|
-
input :organization, :desc => "Organization to show",
|
8
|
-
:aliases => %w{--org -o}, :argument => :optional,
|
9
|
-
:from_given => by_name(:organization),
|
10
|
-
:default => proc { client.current_organization }
|
11
|
-
input :full, :desc => "Show full information for spaces, domains, etc.",
|
12
|
-
:default => false
|
13
|
-
def org
|
14
|
-
org = input[:organization]
|
15
|
-
|
16
|
-
unless org
|
17
|
-
return if quiet?
|
18
|
-
fail "No current organization."
|
19
|
-
end
|
20
|
-
|
21
|
-
if quiet?
|
22
|
-
puts org.name
|
23
|
-
return
|
24
|
-
end
|
25
|
-
|
26
|
-
line "#{c(org.name, :name)}:"
|
27
|
-
|
28
|
-
indented do
|
29
|
-
line "domains: #{name_list(org.domains)}"
|
30
|
-
|
31
|
-
if input[:full]
|
32
|
-
line "spaces:"
|
33
|
-
|
34
|
-
spaced(org.spaces(:depth => 2)) do |s|
|
35
|
-
indented do
|
36
|
-
invoke :space, :space => s
|
37
|
-
end
|
38
|
-
end
|
39
|
-
else
|
40
|
-
line "spaces: #{name_list(org.spaces)}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,30 +0,0 @@
|
|
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
|
@@ -1,37 +0,0 @@
|
|
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
|
@@ -1,32 +0,0 @@
|
|
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
|