cf 0.6.1.rc17 → 0.6.1.rc18

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,20 +19,12 @@ module CF::Organization
19
19
 
20
20
  is_current = org == client.current_organization
21
21
 
22
- begin
23
- with_progress("Deleting organization #{c(org.name, :name)}") do
24
- if input[:recursive]
25
- org.delete!(:recursive => true)
26
- else
27
- org.delete!
28
- end
22
+ with_progress("Deleting organization #{c(org.name, :name)}") do
23
+ if input[:recursive]
24
+ org.delete!(:recursive => true)
25
+ else
26
+ org.delete!
29
27
  end
30
- rescue CFoundry::AssociationNotEmpty => boom
31
- line
32
- line c(boom.description, :bad)
33
- line c("If you want to delete the organization along with all dependent objects, rerun the command with the #{b("'--recursive'")} flag.", :bad)
34
- exit_status(1)
35
- return
36
28
  end
37
29
 
38
30
  if client.organizations.size == 1
@@ -45,6 +37,11 @@ module CF::Organization
45
37
  invalidate_client
46
38
  invoke :target
47
39
  end
40
+ rescue CFoundry::AssociationNotEmpty => boom
41
+ line
42
+ line c(boom.description, :bad)
43
+ line c("If you want to delete the organization along with all dependent objects, rerun the command with the #{b("'--recursive'")} flag.", :bad)
44
+ exit_status(1)
48
45
  end
49
46
 
50
47
  private
@@ -0,0 +1,28 @@
1
+ require "cf/cli/route/base"
2
+
3
+ module CF::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
@@ -8,23 +8,21 @@ module CF::Route
8
8
  :from_given => find_by_name("route") { client.routes }
9
9
  input :app, :desc => "Application to remove the URL from",
10
10
  :argument => :optional, :from_given => by_name(:app)
11
- input :delete, :desc => "Delete route", :type => :boolean
12
11
  input :all, :desc => "Act on all routes", :type => :boolean
13
12
  input :really, :type => :boolean, :forget => true, :hidden => true,
14
13
  :default => proc { force? || interact }
14
+
15
15
  def unmap
16
16
  if input[:all]
17
17
  if input.has?(:app)
18
18
  app = target = input[:app]
19
- return unless !input[:delete] || input[:really, "ALL URLS bound to #{target.name}", :bad]
20
19
  else
21
20
  target = client
22
- return unless !input[:delete] || input[:really, "ALL URLS", :bad]
23
21
  end
24
22
 
25
23
  target.routes.each do |r|
26
24
  begin
27
- invoke :unmap, :delete => input[:delete], :url => r, :really => true, :app => app
25
+ invoke :unmap, :url => r, :really => true, :app => app
28
26
  rescue CFoundry::APIError => e
29
27
  err "#{e.class}: #{e.message}"
30
28
  end
@@ -36,16 +34,12 @@ module CF::Route
36
34
  app = input[:app]
37
35
  url = input[:url, app ? app.routes : client.routes]
38
36
 
39
- if input[:delete]
40
- with_progress("Deleting route #{c(url.name, :name)}") do
41
- url.delete!
42
- end
43
- elsif app
37
+ if app
44
38
  with_progress("Unbinding #{c(url.name, :name)} from #{c(app.name, :name)}") do
45
39
  app.remove_route(url)
46
40
  end
47
41
  else
48
- fail "Missing either --delete or --app."
42
+ fail "Missing --app."
49
43
  end
50
44
  end
51
45
 
@@ -7,8 +7,8 @@ module CF::Space
7
7
  input :organization, :desc => "Space's organization",
8
8
  :aliases => ["--org", "-o"], :from_given => by_name(:organization),
9
9
  :default => proc { client.current_organization }
10
- input :spaces, :desc => "Spaces to delete", :argument => :splat,
11
- :singular => :space, :from_given => space_by_name
10
+ input :space, :desc => "Space to delete", :argument => true,
11
+ :from_given => space_by_name
12
12
  input :recursive, :desc => "Delete recursively", :alias => "-r",
13
13
  :default => false, :forget => true
14
14
  input :warn, :desc => "Show warning if it was the last space",
@@ -17,35 +17,29 @@ module CF::Space
17
17
  :default => proc { force? || interact }
18
18
 
19
19
  def delete_space
20
- spaces = input[:spaces, org]
21
-
22
- deleted_current = false
23
-
24
- spaces.each do |space|
25
- next unless input[:really, space]
26
-
27
- deleted_current ||= (space == client.current_space)
28
-
29
- begin
30
- with_progress("Deleting space #{c(space.name, :name)}") do
31
- if input[:recursive]
32
- space.delete!(:recursive => true)
33
- else
34
- space.delete!
35
- end
36
- end
37
- rescue CFoundry::AssociationNotEmpty => boom
38
- line
39
- line c(boom.description, :bad)
40
- line c("If you want to delete the space along with all dependent objects, rerun the command with the #{b("'--recursive'")} flag.", :bad)
41
- exit_status(1)
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!
42
31
  end
43
32
  end
44
33
 
45
- if deleted_current
34
+ if deleting_current_space
46
35
  line
47
36
  line c("The space that you were targeting has now been deleted. Please use #{b("`cf target -s SPACE_NAME`")} to target a different one.", :warning)
48
37
  end
38
+ rescue CFoundry::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)
49
43
  end
50
44
 
51
45
  private
@@ -1,3 +1,3 @@
1
1
  module CF
2
- VERSION = "0.6.1.rc17".freeze
2
+ VERSION = "0.6.1.rc18".freeze
3
3
  end
@@ -0,0 +1,17 @@
1
+ redis:
2
+ redis-cli: -h ${host} -p ${port} -a ${password}
3
+
4
+ mysql:
5
+ mysql: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name}
6
+ mysqldump: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name} > ${ask Output file}
7
+
8
+ mongodb:
9
+ mongo: --host ${host} --port ${port} -u ${user} -p ${password} ${name}
10
+ mongodump: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name}
11
+ mongorestore: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name} ${ask Directory or filename to restore from}
12
+
13
+ postgresql:
14
+ psql:
15
+ command: -h ${host} -p ${port} -d ${name} -U ${user} -w
16
+ environment:
17
+ - PGPASSWORD='${password}'
@@ -4,7 +4,7 @@ require "tunnel/tunnel"
4
4
  module CFTunnelPlugin
5
5
  class Tunnel < CF::CLI
6
6
  CLIENTS_FILE = "tunnel-clients.yml"
7
- STOCK_CLIENTS = File.expand_path("../../../config/clients.yml", __FILE__)
7
+ STOCK_CLIENTS = File.expand_path("../config/clients.yml", __FILE__)
8
8
 
9
9
  desc "Create a local tunnel to a service."
10
10
  group :services, :manage
@@ -0,0 +1,90 @@
1
+ require 'spec_helper'
2
+
3
+ describe CF::Route::Delete do
4
+ before do
5
+ stub_client_and_precondition
6
+ stub(route).delete!
7
+ end
8
+
9
+ let(:route) { fake(:route, :host => host_name, :domain => domain) }
10
+ let(:client) { fake_client :routes => [route] }
11
+ let(:domain) { fake(:domain, :name => domain_name) }
12
+ let(:domain_name) { "some-domain.com" }
13
+ let(:host_name) { "some-host" }
14
+ let(:url) { "#{host_name}.#{domain_name}" }
15
+
16
+ describe 'metadata' do
17
+ let(:command) { Mothership.commands[:delete_route] }
18
+
19
+ describe 'command' do
20
+ subject { command }
21
+ its(:description) { should eq "Delete a route" }
22
+ it { expect(Mothership::Help.group(:routes)).to include(subject) }
23
+ end
24
+
25
+ include_examples 'inputs must have descriptions'
26
+
27
+ describe 'arguments' do
28
+ subject { command.arguments }
29
+ it 'has the correct argument order' do
30
+ should eq([{:type => :normal, :value => nil, :name => :route}])
31
+ end
32
+ end
33
+ end
34
+
35
+ context "without the force parameter" do
36
+ let(:command) { cf %W[delete-route #{url}] }
37
+
38
+ it "prompts the user are they sure?" do
39
+ mock_ask("Really delete #{url}?", {:default => false}) { true }
40
+
41
+ command
42
+ end
43
+
44
+ context "when the user responds 'y'" do
45
+ before do
46
+ stub_ask("Really delete #{url}?", {:default => false}) { true }
47
+ end
48
+
49
+ it "deletes the route" do
50
+ mock(route).delete!
51
+ command
52
+ end
53
+
54
+ it "exits cleanly" do
55
+ command
56
+ @status.should == 0
57
+ end
58
+ end
59
+
60
+ context "when the user responds 'n'" do
61
+ before do
62
+ stub_ask("Really delete #{url}?", {:default => false}) { false }
63
+ end
64
+
65
+ it "does not delete the route" do
66
+ dont_allow(route).delete!
67
+ command
68
+ end
69
+
70
+ it "exits cleanly" do
71
+ command
72
+ @status.should == 0
73
+ end
74
+ end
75
+ end
76
+
77
+ context "with the force parameter" do
78
+ let(:command) { cf %W[delete-route #{url} --force] }
79
+
80
+ it "deletes the route" do
81
+ mock(route).delete!
82
+ command
83
+ end
84
+
85
+ it "exits cleanly" do
86
+ command
87
+ @status.should == 0
88
+ end
89
+ end
90
+ end
@@ -94,57 +94,6 @@ describe CF::Route::Unmap do
94
94
  end
95
95
  end
96
96
 
97
- context "when a url is specified and the --delete option is given" do
98
- let(:route) { fake(:route, :host => host_name, :domain => domain) }
99
- let(:client) { fake_client :routes => [route] }
100
-
101
- subject { cf %W[unmap #{url} --delete] }
102
-
103
- it "deletes the route" do
104
- mock(route).delete!
105
- subject
106
- end
107
- end
108
-
109
- context "when the --delete and --all options are both passed" do
110
- let(:other_route) { fake(:route, :host => "abcd", :domain => domain) }
111
- let(:route) { fake(:route, :host => "efgh", :domain => domain) }
112
- let(:client) { fake_client :routes => [route, other_route] }
113
-
114
- subject { cf %W[unmap --delete --all] }
115
-
116
- before do
117
- any_instance_of(route.class) do |route|
118
- stub(route).delete!
119
- end
120
- end
121
-
122
- it "asks if the user really wants to unmap all urls" do
123
- mock_ask("Really delete ALL URLS?", :default => false) { false }
124
- subject
125
- end
126
-
127
- context "when the user responds with a yes" do
128
- before { stub_ask("Really delete ALL URLS?", anything) { true } }
129
-
130
- it "deletes all the user's routes" do
131
- client.routes.each { |r| mock(r).delete! }
132
- subject
133
- end
134
- end
135
-
136
- context "when the user responds with a no" do
137
- before { stub_ask("Really delete ALL URLS?", anything) { false } }
138
-
139
- it "does not delete any routes" do
140
- any_instance_of(route.class) do |route|
141
- dont_allow(route).delete!
142
- end
143
- subject
144
- end
145
- end
146
- end
147
-
148
97
  context "when only a url is passed" do
149
98
  let(:route) { fake(:route, :host => host_name, :domain => domain) }
150
99
  let(:client) { fake_client :routes => [route] }
@@ -153,7 +102,7 @@ describe CF::Route::Unmap do
153
102
 
154
103
  it "displays an error message" do
155
104
  subject
156
- expect(error_output).to say("Missing either --delete or --app.")
105
+ expect(error_output).to say("Missing --app.")
157
106
  end
158
107
  end
159
108
  end
@@ -12,26 +12,14 @@ describe CF::Space::Delete do
12
12
  end
13
13
 
14
14
  include_examples 'inputs must have descriptions'
15
-
16
- describe 'arguments' do
17
- subject { command.arguments }
18
- it 'has the correct argument order' do
19
- should eq([
20
- {:type => :splat, :value => nil, :name => :spaces}
21
- ])
22
- end
23
- end
24
15
  end
25
16
 
26
17
  describe "running the command" do
27
18
  let(:space) { fake :space, :name => "some_space_name" }
28
- let(:space_2) { fake :space, :name => "some_other_space_name" }
29
- let(:spaces) { [space, space_2] }
30
- let(:organization) { fake(:organization, :spaces => spaces, :name => "MyOrg") }
31
-
32
- let(:client) { fake_client(:current_organization => organization, :spaces => spaces) }
19
+ let(:organization) { fake(:organization, :spaces => [space], :name => "MyOrg") }
20
+ let(:client) { fake_client(:current_organization => organization, :spaces => [space]) }
33
21
 
34
- subject { capture_output { cf %W[delete-space some_space_name some_other_space_name --quiet --force] } }
22
+ subject { capture_output { cf %W[delete-space some_space_name --quiet --force] } }
35
23
 
36
24
  before do
37
25
  any_instance_of described_class do |cli|
@@ -42,35 +30,52 @@ describe CF::Space::Delete do
42
30
  any_instance_of(CF::Populators::Organization, :populate_and_save! => organization)
43
31
  end
44
32
  stub(space).delete!
45
- stub(space_2).delete!
46
33
  end
47
34
 
48
- it "deletes all named spaces" do
49
- mock(space).delete!
50
- mock(space_2).delete!
51
35
 
52
- subject
53
- end
36
+ context "without the force parameter when prompting" do
37
+ subject { cf %W[delete-space some_space_name --quiet] }
38
+ context "when the user responds 'y'" do
39
+ it "deletes the space, exits cleanly" do
40
+ mock(space).delete!
41
+ mock_ask("Really delete #{space.name}?", {:default => false}) { true }
42
+
43
+ subject
44
+ @status.should == 0
45
+ end
46
+ end
54
47
 
55
- context "without the force parameter" do
56
- subject { cf %W[delete-space some_space_name some_other_space_name --quiet] }
57
- it "confirms deletion of each space and deletes them" do
58
- mock(space).delete!
59
- dont_allow(space_2).delete!
60
- mock_ask("Really delete #{space.name}?", {:default => false}) { true }
61
- mock_ask("Really delete #{space_2.name}?", {:default => false}) { false }
48
+ context "when the user responds 'n'" do
49
+ it "exits cleanly without deleting the space" do
50
+ dont_allow(space).delete!
51
+ mock_ask("Really delete #{space.name}?", {:default => false}) { false }
62
52
 
63
- subject
53
+ subject
54
+ @status.should == 0
55
+ end
64
56
  end
65
57
  end
66
58
 
67
59
  context "when deleting the current space" do
68
- it "warns the user what they've done" do
60
+ before do
69
61
  stub(client).current_space { space }
62
+ end
70
63
 
64
+ it "warns the user what they've done" do
71
65
  subject
72
66
  expect(output).to say("The space that you were targeting has now been deleted. Please use `cf target -s SPACE_NAME` to target a different one.")
73
67
  end
68
+
69
+ context "when the current space has dependent objects" do
70
+ before do
71
+ stub(space).delete! { raise CFoundry::AssociationNotEmpty.new("We don't delete children.", 10006) }
72
+ end
73
+
74
+ it "does not print a success message" do
75
+ subject
76
+ expect(output).to_not say("The space that you were targeting has now been deleted")
77
+ end
78
+ end
74
79
  end
75
80
 
76
81
  context "when a space fails to delete" do
@@ -12,7 +12,7 @@ if ENV['CF_V2_RUN_INTEGRATION']
12
12
 
13
13
  let(:run_id) { TRAVIS_BUILD_ID.to_s + Time.new.to_f.to_s.gsub(".", "_") }
14
14
  let(:app) { "hello-sinatra-#{run_id}" }
15
- let(:service_name) { "mysql-#{run_id}" }
15
+ let(:service_name) { "redistogo-dev-#{run_id}" }
16
16
 
17
17
  before do
18
18
  FileUtils.rm_rf File.expand_path(CF::CONFIG_DIR)
@@ -65,13 +65,13 @@ if ENV['CF_V2_RUN_INTEGRATION']
65
65
 
66
66
  # create a service here
67
67
  expect(runner).to say "What kind?>"
68
- runner.send_keys "mysql n/a"
68
+ runner.send_keys "redistogo-dev n/a"
69
69
 
70
70
  expect(runner).to say "Name?>"
71
71
  runner.send_keys service_name
72
72
 
73
73
  expect(runner).to say "Which plan?>"
74
- runner.send_keys "cfinternal"
74
+ runner.send_keys "1"
75
75
 
76
76
  expect(runner).to say /Creating service #{service_name}.*OK/
77
77
  expect(runner).to say /Binding .+ to .+ OK/
@@ -97,11 +97,11 @@ if ENV['CF_V2_RUN_INTEGRATION']
97
97
 
98
98
  BlueShell::Runner.run("#{cf_bin} services") do |runner|
99
99
  expect(runner).to say /name\s+service\s+provider\s+version\s+plan\s+bound apps/
100
- expect(runner).to say /mysql-.+?\s+ # name
101
- mysql\s+ # service
102
- aws\s+ # provider
100
+ expect(runner).to say /redistogo-dev-.+?\s+ # name
101
+ redistogo-dev\s+ # service
102
+ redistogo\s+ # provider
103
103
  n\/a\s+ # version
104
- cfinternal\s+ # plan
104
+ 100\s+ # plan
105
105
  #{app} # bound apps
106
106
  /x
107
107
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.rc17
4
+ version: 0.6.1.rc18
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-26 00:00:00.000000000 Z
13
+ date: 2013-05-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -51,7 +51,7 @@ dependencies:
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.7.0.rc9
54
+ version: 0.7.0.rc12
55
55
  - - <
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0.8'
@@ -62,7 +62,7 @@ dependencies:
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: 0.7.0.rc9
65
+ version: 0.7.0.rc12
66
66
  - - <
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.8'
@@ -205,7 +205,7 @@ dependencies:
205
205
  requirement: !ruby/object:Gem::Requirement
206
206
  none: false
207
207
  requirements:
208
- - - ~>
208
+ - - '='
209
209
  - !ruby/object:Gem::Version
210
210
  version: '1.15'
211
211
  type: :development
@@ -213,7 +213,7 @@ dependencies:
213
213
  version_requirements: !ruby/object:Gem::Requirement
214
214
  none: false
215
215
  requirements:
216
- - - ~>
216
+ - - '='
217
217
  - !ruby/object:Gem::Version
218
218
  version: '1.15'
219
219
  - !ruby/object:Gem::Dependency
@@ -345,6 +345,7 @@ files:
345
345
  - lib/cf/cli/populators/space.rb
346
346
  - lib/cf/cli/populators/target.rb
347
347
  - lib/cf/cli/route/base.rb
348
+ - lib/cf/cli/route/delete.rb
348
349
  - lib/cf/cli/route/map.rb
349
350
  - lib/cf/cli/route/routes.rb
350
351
  - lib/cf/cli/route/unmap.rb
@@ -395,6 +396,7 @@ files:
395
396
  - lib/manifests/manifests.rb
396
397
  - lib/manifests/plugin.rb
397
398
  - lib/manifests/README.md
399
+ - lib/tunnel/config/clients.yml
398
400
  - lib/tunnel/helper-app/Gemfile
399
401
  - lib/tunnel/helper-app/Gemfile.lock
400
402
  - lib/tunnel/helper-app/server.rb
@@ -471,6 +473,7 @@ files:
471
473
  - spec/cf/cli/populators/organization_spec.rb
472
474
  - spec/cf/cli/populators/space_spec.rb
473
475
  - spec/cf/cli/populators/target_spec.rb
476
+ - spec/cf/cli/route/delete_spec.rb
474
477
  - spec/cf/cli/route/map_spec.rb
475
478
  - spec/cf/cli/route/unmap_spec.rb
476
479
  - spec/cf/cli/service/bind_spec.rb
@@ -531,7 +534,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
531
534
  version: '0'
532
535
  segments:
533
536
  - 0
534
- hash: 1676711361169297204
537
+ hash: 3221305947383105149
535
538
  required_rubygems_version: !ruby/object:Gem::Requirement
536
539
  none: false
537
540
  requirements:
@@ -615,6 +618,7 @@ test_files:
615
618
  - spec/cf/cli/populators/organization_spec.rb
616
619
  - spec/cf/cli/populators/space_spec.rb
617
620
  - spec/cf/cli/populators/target_spec.rb
621
+ - spec/cf/cli/route/delete_spec.rb
618
622
  - spec/cf/cli/route/map_spec.rb
619
623
  - spec/cf/cli/route/unmap_spec.rb
620
624
  - spec/cf/cli/service/bind_spec.rb