cf 1.1.3.rc1 → 1.1.4
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.
- data/lib/cf/cli.rb +2 -7
- data/lib/cf/cli/organization/delete.rb +4 -6
- data/lib/cf/cli/service/create.rb +23 -17
- data/lib/cf/cli/space/create.rb +43 -41
- data/lib/cf/cli/space/space.rb +49 -46
- data/lib/cf/version.rb +1 -1
- data/lib/console/console.rb +1 -1
- data/spec/cf/cli/app/delete_spec.rb +16 -28
- data/spec/cf/cli/app/instances_spec.rb +4 -5
- data/spec/cf/cli/app/push/create_spec.rb +362 -373
- data/spec/cf/cli/app/push_spec.rb +216 -215
- data/spec/cf/cli/app/rename_spec.rb +28 -31
- data/spec/cf/cli/app/scale_spec.rb +44 -41
- data/spec/cf/cli/app/start_spec.rb +194 -193
- data/spec/cf/cli/app/stats_spec.rb +55 -56
- data/spec/cf/cli/domain/map_spec.rb +105 -102
- data/spec/cf/cli/domain/unmap_spec.rb +60 -56
- data/spec/cf/cli/organization/delete_spec.rb +85 -84
- data/spec/cf/cli/organization/orgs_spec.rb +80 -83
- data/spec/cf/cli/organization/rename_spec.rb +90 -89
- data/spec/cf/cli/populators/organization_spec.rb +117 -119
- data/spec/cf/cli/populators/space_spec.rb +107 -108
- data/spec/cf/cli/populators/target_spec.rb +17 -12
- data/spec/cf/cli/route/delete_spec.rb +4 -4
- data/spec/cf/cli/route/map_spec.rb +106 -102
- data/spec/cf/cli/route/unmap_spec.rb +5 -5
- data/spec/cf/cli/service/create_spec.rb +74 -46
- data/spec/cf/cli/service/rename_spec.rb +29 -33
- data/spec/cf/cli/service/services_spec.rb +48 -48
- data/spec/cf/cli/space/base_spec.rb +39 -32
- data/spec/cf/cli/space/create_spec.rb +52 -53
- data/spec/cf/cli/space/delete_spec.rb +84 -85
- data/spec/cf/cli/space/rename_spec.rb +93 -94
- data/spec/cf/cli/space/space_spec.rb +60 -60
- data/spec/cf/cli/space/spaces_spec.rb +75 -80
- data/spec/cf/cli/space/switch_space_spec.rb +45 -48
- data/spec/cf/cli/start/info_spec.rb +4 -6
- data/spec/cf/cli/start/login_spec.rb +18 -20
- data/spec/cf/cli/start/logout_spec.rb +36 -37
- data/spec/cf/cli/start/target_spec.rb +86 -89
- data/spec/cf/cli/user/create_spec.rb +83 -84
- data/spec/cf/cli/user/passwd_spec.rb +87 -86
- data/spec/cf/cli/user/register_spec.rb +109 -108
- data/spec/cf/cli_spec.rb +305 -310
- data/spec/console/console_spec.rb +58 -58
- data/spec/factories/cfoundry/v2/domain_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/route_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/user_factory.rb +7 -0
- data/spec/features/org_spec.rb +11 -11
- data/spec/manifests/manifests_spec.rb +21 -21
- data/spec/manifests/plugin_spec.rb +34 -34
- data/spec/spec_helper.rb +1 -2
- data/spec/support/cli_helper.rb +5 -14
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/interact_helper.rb +5 -15
- data/spec/support/shared_examples/errors.rb +1 -1
- data/spec/tunnel/plugin_spec.rb +2 -2
- data/spec/tunnel/tunnel_spec.rb +5 -5
- metadata +36 -28
data/lib/cf/cli.rb
CHANGED
@@ -398,13 +398,8 @@ module CF
|
|
398
398
|
save_target_info(info, target)
|
399
399
|
end
|
400
400
|
|
401
|
-
|
402
|
-
|
403
|
-
end
|
404
|
-
|
405
|
-
if (space = info[:space])
|
406
|
-
@@client.current_space = @@client.space(space)
|
407
|
-
end
|
401
|
+
@@client.current_organization = @@client.organization(info[:organization]) if info[:organization]
|
402
|
+
@@client.current_space = @@client.space(info[:space]) if info[:space]
|
408
403
|
|
409
404
|
@@client
|
410
405
|
rescue CFoundry::InvalidTarget
|
@@ -18,16 +18,14 @@ module CF::Organization
|
|
18
18
|
return unless input[:really, org]
|
19
19
|
|
20
20
|
is_current = org == client.current_organization
|
21
|
+
remote_organizations = client.organizations(:depth => 0)
|
21
22
|
|
22
23
|
with_progress("Deleting organization #{c(org.name, :name)}") do
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
org.delete!
|
27
|
-
end
|
24
|
+
deleted = org.delete!(:recursive => !!input[:recursive])
|
25
|
+
remote_organizations.delete(org) if deleted
|
28
26
|
end
|
29
27
|
|
30
|
-
if
|
28
|
+
if remote_organizations.empty?
|
31
29
|
return unless input[:warn]
|
32
30
|
|
33
31
|
line
|
@@ -9,17 +9,18 @@ module CF::Service
|
|
9
9
|
desc "Create a service"
|
10
10
|
group :services, :manage
|
11
11
|
input :offering, :desc => "What kind of service (e.g. redis, mysql)",
|
12
|
-
|
12
|
+
:argument => :optional, :from_given => offerings_from_label
|
13
13
|
input :name, :desc => "Name for your service", :argument => :optional
|
14
14
|
input :plan, :desc => "Service plan",
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
:from_given => find_by_name_insensitive("plan"),
|
16
|
+
:default => proc {
|
17
|
+
interact
|
18
|
+
}
|
19
19
|
input :provider, :desc => "Service provider"
|
20
20
|
input :version, :desc => "Service version"
|
21
21
|
input :app, :desc => "Application to immediately bind to",
|
22
|
-
|
22
|
+
:alias => "--bind", :from_given => by_name(:app)
|
23
|
+
|
23
24
|
def create_service
|
24
25
|
offerings = client.services
|
25
26
|
|
@@ -37,9 +38,9 @@ module CF::Service
|
|
37
38
|
if plan = input.direct(:plan)
|
38
39
|
offerings.reject! do |s|
|
39
40
|
if plan.is_a?(String)
|
40
|
-
s.service_plans.none? { |p| p.name ==
|
41
|
+
s.service_plans.none? { |p| p.name.casecmp(plan) == 0 }
|
41
42
|
else
|
42
|
-
s.service_plans.include? plan
|
43
|
+
!s.service_plans.include? plan
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
@@ -55,7 +56,12 @@ module CF::Service
|
|
55
56
|
service = client.service_instance
|
56
57
|
service.name = input[:name, offering]
|
57
58
|
|
58
|
-
|
59
|
+
plan = input[:plan, offering.service_plans]
|
60
|
+
service.service_plan = if plan.is_a?(String)
|
61
|
+
offering.service_plans.find { |p| p.name.casecmp(plan) == 0 }
|
62
|
+
else
|
63
|
+
plan
|
64
|
+
end
|
59
65
|
service.space = client.current_space
|
60
66
|
|
61
67
|
with_progress("Creating service #{c(service.name, :name)}") do
|
@@ -73,14 +79,14 @@ module CF::Service
|
|
73
79
|
|
74
80
|
def ask_offering(offerings)
|
75
81
|
[ask("What kind?", :choices => offerings.sort_by(&:label),
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
:display => proc { |s|
|
83
|
+
str = "#{c(s.label, :name)} #{s.version}"
|
84
|
+
if s.provider != "core"
|
85
|
+
str << ", via #{s.provider}"
|
86
|
+
end
|
87
|
+
str
|
88
|
+
},
|
89
|
+
:complete => proc { |s| "#{s.label} #{s.version}" })]
|
84
90
|
end
|
85
91
|
|
86
92
|
def ask_name(offering)
|
data/lib/cf/cli/space/create.rb
CHANGED
@@ -1,50 +1,52 @@
|
|
1
1
|
require "cf/cli/space/base"
|
2
2
|
|
3
|
-
module CF
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
3
|
+
module CF
|
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
|
+
|
19
|
+
def create_space
|
20
|
+
space = client.space
|
21
|
+
space.organization = org
|
22
|
+
space.name = input[:name]
|
23
|
+
|
24
|
+
with_progress("Creating space #{c(space.name, :name)}") { space.create! }
|
25
|
+
|
26
|
+
if input[:manager]
|
27
|
+
with_progress("Adding you as a manager") { space.add_manager client.current_user }
|
28
|
+
end
|
29
|
+
|
30
|
+
if input[:developer]
|
31
|
+
with_progress("Adding you as a developer") { space.add_developer client.current_user }
|
32
|
+
end
|
33
|
+
|
34
|
+
if input[:auditor]
|
35
|
+
with_progress("Adding you as an auditor") { space.add_auditor client.current_user }
|
36
|
+
end
|
37
|
+
|
38
|
+
if input[:target]
|
39
|
+
invoke :target, :organization => space.organization, :space => space
|
40
|
+
else
|
41
|
+
line c("Space created! Use #{b("`cf switch-space #{space.name}`")} to target it.", :good)
|
42
|
+
end
|
27
43
|
end
|
28
44
|
|
29
|
-
|
30
|
-
with_progress("Adding you as a developer") { space.add_developer client.current_user }
|
31
|
-
end
|
32
|
-
|
33
|
-
if input[:auditor]
|
34
|
-
with_progress("Adding you as an auditor") { space.add_auditor client.current_user }
|
35
|
-
end
|
45
|
+
private
|
36
46
|
|
37
|
-
|
38
|
-
|
39
|
-
else
|
40
|
-
line c("Space created! Use #{b("`cf switch-space #{space.name}`")} to target it.", :good)
|
47
|
+
def ask_name
|
48
|
+
ask("Name")
|
41
49
|
end
|
42
50
|
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def ask_name
|
47
|
-
ask("Name")
|
48
|
-
end
|
49
51
|
end
|
50
52
|
end
|
data/lib/cf/cli/space/space.rb
CHANGED
@@ -1,62 +1,65 @@
|
|
1
1
|
require "cf/cli/space/base"
|
2
2
|
|
3
|
-
module CF
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
space = CF::Populators::Space.new(input, org).populate_and_save!
|
18
|
-
|
19
|
-
unless space
|
20
|
-
return if quiet?
|
21
|
-
fail "No current space."
|
22
|
-
end
|
3
|
+
module CF
|
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
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
return
|
27
|
-
end
|
18
|
+
def space
|
19
|
+
space = CF::Populators::Space.new(input, org).populate_and_save!
|
28
20
|
|
29
|
-
|
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
30
|
|
31
|
-
|
32
|
-
line "organization: #{c(space.organization.name, :name)}"
|
31
|
+
line "#{c(space.name, :name)}:"
|
33
32
|
|
34
|
-
|
35
|
-
line
|
36
|
-
line "apps:"
|
33
|
+
indented do
|
34
|
+
line "organization: #{c(space.organization.name, :name)}"
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
41
44
|
end
|
45
|
+
else
|
46
|
+
line "apps: #{name_list(space.apps)}"
|
42
47
|
end
|
43
|
-
else
|
44
|
-
line "apps: #{name_list(space.apps)}"
|
45
|
-
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
53
56
|
end
|
57
|
+
else
|
58
|
+
line "services: #{name_list(space.service_instances)}"
|
54
59
|
end
|
55
|
-
else
|
56
|
-
line "services: #{name_list(space.service_instances)}"
|
57
|
-
end
|
58
60
|
|
59
|
-
|
61
|
+
line "domains: #{name_list(space.domains)}"
|
62
|
+
end
|
60
63
|
end
|
61
64
|
end
|
62
65
|
end
|
data/lib/cf/version.rb
CHANGED
data/lib/console/console.rb
CHANGED
@@ -122,7 +122,7 @@ class CFConsole < CFTunnel
|
|
122
122
|
|
123
123
|
return if line == nil || line == 'quit' || line == 'exit'
|
124
124
|
|
125
|
-
if line !~ /^\s*$/ && Readline::HISTORY.to_a
|
125
|
+
if line !~ /^\s*$/ && Readline::HISTORY.to_a.last != line
|
126
126
|
Readline::HISTORY.push(line)
|
127
127
|
end
|
128
128
|
|
@@ -10,10 +10,8 @@ describe CF::App::Delete do
|
|
10
10
|
let(:new_name) { "some-new-name" }
|
11
11
|
|
12
12
|
before do
|
13
|
-
|
14
|
-
|
15
|
-
stub(cli).precondition { nil }
|
16
|
-
end
|
13
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
14
|
+
CF::CLI.any_instance.stub(:precondition).and_return(nil)
|
17
15
|
end
|
18
16
|
|
19
17
|
subject { Mothership.new.invoke(:delete, inputs, given, global) }
|
@@ -74,7 +72,7 @@ describe CF::App::Delete do
|
|
74
72
|
it 'asks for the app' do
|
75
73
|
mock_ask("Delete which application?", anything) { basic_app }
|
76
74
|
stub_ask { true }
|
77
|
-
stub(
|
75
|
+
basic_app.stub(:delete!)
|
78
76
|
subject
|
79
77
|
end
|
80
78
|
end
|
@@ -87,7 +85,7 @@ describe CF::App::Delete do
|
|
87
85
|
context 'and the user answers no' do
|
88
86
|
it 'does not delete the application' do
|
89
87
|
mock_ask("Really delete #{deleted_app.name}?", anything) { false }
|
90
|
-
|
88
|
+
deleted_app.should_not_receive(:delete!)
|
91
89
|
subject
|
92
90
|
end
|
93
91
|
end
|
@@ -95,7 +93,7 @@ describe CF::App::Delete do
|
|
95
93
|
context 'and the user answers yes' do
|
96
94
|
it 'deletes the application' do
|
97
95
|
mock_ask("Really delete #{deleted_app.name}?", anything) { true }
|
98
|
-
|
96
|
+
deleted_app.should_receive(:delete!)
|
99
97
|
subject
|
100
98
|
end
|
101
99
|
end
|
@@ -106,7 +104,7 @@ describe CF::App::Delete do
|
|
106
104
|
|
107
105
|
it 'deletes the application without asking to confirm' do
|
108
106
|
dont_allow_ask
|
109
|
-
|
107
|
+
deleted_app.should_receive(:delete!)
|
110
108
|
subject
|
111
109
|
end
|
112
110
|
end
|
@@ -120,16 +118,13 @@ describe CF::App::Delete do
|
|
120
118
|
context 'and the user answers yes' do
|
121
119
|
it 'asks to delete orphaned services' do
|
122
120
|
stub_ask("Really delete #{deleted_app.name}?", anything) { true }
|
123
|
-
stub(
|
121
|
+
deleted_app.stub(:delete!)
|
124
122
|
|
125
|
-
stub(
|
123
|
+
service_2.stub(:invalidate!)
|
126
124
|
|
127
125
|
mock_ask("Delete orphaned service #{service_2.name}?", anything) { true }
|
128
126
|
|
129
|
-
|
130
|
-
mock(del).invoke :delete_service, :service => service_2,
|
131
|
-
:really => true
|
132
|
-
end
|
127
|
+
CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
|
133
128
|
|
134
129
|
subject
|
135
130
|
end
|
@@ -138,15 +133,13 @@ describe CF::App::Delete do
|
|
138
133
|
context 'and the user answers no' do
|
139
134
|
it 'does not ask to delete orphaned serivces, or delete them' do
|
140
135
|
stub_ask("Really delete #{deleted_app.name}?", anything) { false }
|
141
|
-
|
136
|
+
deleted_app.should_not_receive(:delete!)
|
142
137
|
|
143
|
-
stub(
|
138
|
+
service_2.stub(:invalidate!)
|
144
139
|
|
145
140
|
dont_allow_ask("Delete orphaned service #{service_2.name}?")
|
146
141
|
|
147
|
-
|
148
|
-
dont_allow(del).invoke(:delete_service, anything)
|
149
|
-
end
|
142
|
+
CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
|
150
143
|
|
151
144
|
subject
|
152
145
|
end
|
@@ -158,11 +151,9 @@ describe CF::App::Delete do
|
|
158
151
|
|
159
152
|
it 'does not delete orphaned services' do
|
160
153
|
dont_allow_ask
|
161
|
-
stub(
|
154
|
+
deleted_app.stub(:delete!)
|
162
155
|
|
163
|
-
|
164
|
-
dont_allow(del).invoke(:delete_service, anything)
|
165
|
-
end
|
156
|
+
CF::App::Delete.any_instance.should_not_receive(:invoke).with(:delete_service, anything)
|
166
157
|
|
167
158
|
subject
|
168
159
|
end
|
@@ -173,12 +164,9 @@ describe CF::App::Delete do
|
|
173
164
|
|
174
165
|
it 'deletes the orphaned services' do
|
175
166
|
stub_ask("Really delete #{deleted_app.name}?", anything) { true }
|
176
|
-
stub(
|
167
|
+
deleted_app.stub(:delete!)
|
177
168
|
|
178
|
-
|
179
|
-
mock(del).invoke :delete_service, :service => service_2,
|
180
|
-
:really => true
|
181
|
-
end
|
169
|
+
CF::App::Delete.any_instance.should_receive(:invoke).with(:delete_service, :service => service_2, :really => true)
|
182
170
|
|
183
171
|
subject
|
184
172
|
end
|
@@ -10,11 +10,10 @@ describe CF::App::Stats do
|
|
10
10
|
let(:time) { Time.local(2012, 11, 1, 2, 30) }
|
11
11
|
|
12
12
|
before do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
stub(client.base).instances(anything) do
|
13
|
+
CF::CLI.any_instance.stub(:client).and_return(client)
|
14
|
+
CF::CLI.any_instance.stub(:precondition).and_return(nil)
|
15
|
+
|
16
|
+
client.base.stub(:instances).with(anything) do
|
18
17
|
{
|
19
18
|
"12" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
|
20
19
|
"1" => {:state => "STOPPED", :since => time.to_i, :debug_ip => "foo", :debug_port => "bar", :console_ip => "baz", :console_port => "qux"},
|