vmc 0.4.0.beta.85 → 0.4.0.beta.86

Sign up to get free protection for your applications and to get access to all the features.
@@ -90,6 +90,7 @@ module VMC
90
90
  :from_given => by_name("organization"),
91
91
  :default => proc { client.current_organization },
92
92
  :desc => "Organization to list spaces from"
93
+ input :name, :desc => "Filter by name"
93
94
  input :one_line, :alias => "-l", :type => :boolean, :default => false,
94
95
  :desc => "Single-line tabular format"
95
96
  input :full, :type => :boolean, :default => false,
@@ -103,6 +104,10 @@ module VMC
103
104
 
104
105
  line unless quiet?
105
106
 
107
+ spaces.reject! do |s|
108
+ !space_matches(s, input)
109
+ end
110
+
106
111
  if input[:one_line]
107
112
  table(
108
113
  %w{name apps services},
@@ -185,13 +190,14 @@ module VMC
185
190
 
186
191
  desc "Delete a space and its contents"
187
192
  group :spaces
188
- input(:space, :argument => :optional, :from_given => space_by_name,
193
+ input(:spaces, :argument => :splat,
194
+ :from_given => space_by_name,
189
195
  :desc => "Space to delete") { |org|
190
196
  spaces = org.spaces
191
197
  fail "No spaces." if spaces.empty?
192
198
 
193
- ask "Which space in #{c(org.name, :name)}?", :choices => spaces,
194
- :display => proc(&:name)
199
+ [ask "Which space in #{c(org.name, :name)}?", :choices => spaces,
200
+ :display => proc(&:name)]
195
201
  }
196
202
  input :organization, :aliases => ["--org", "-o"],
197
203
  :from_given => by_name("organization"),
@@ -208,38 +214,22 @@ module VMC
208
214
  :desc => "Show warning if it was the last space"
209
215
  def delete_space
210
216
  org = input[:organization]
211
- space = input[:space, org]
212
- return unless input[:really, space]
217
+ spaces = input[:spaces, org]
213
218
 
214
- apps = space.apps
215
- instances = space.service_instances
219
+ deleted_current = false
216
220
 
217
- unless apps.empty? && instances.empty?
218
- unless force?
219
- line "This space is not empty!"
220
- line
221
- line "apps: #{name_list(apps)}"
222
- line "service instances: #{name_list(instances)}"
223
- line
221
+ spaces.each do |space|
222
+ next unless input[:really, space]
224
223
 
225
- return unless input[:recursive]
226
- end
224
+ next unless clear_space(space)
227
225
 
228
- apps.each do |a|
229
- invoke :delete, :app => a, :really => true
230
- end
226
+ deleted_current ||= space == client.current_space
231
227
 
232
- instances.each do |i|
233
- invoke :delete_service, :instance => i, :really => true
228
+ with_progress("Deleting space #{c(space.name, :name)}") do
229
+ space.delete!
234
230
  end
235
231
  end
236
232
 
237
- is_current = space == client.current_space
238
-
239
- with_progress("Deleting space #{c(space.name, :name)}") do
240
- space.delete!
241
- end
242
-
243
233
  org.invalidate!
244
234
 
245
235
  if org.spaces.empty?
@@ -248,10 +238,47 @@ module VMC
248
238
  line
249
239
  line c("There are no longer any spaces in #{b(org.name)}.", :warning)
250
240
  line "You may want to create one with #{c("create-space", :good)}."
251
- elsif is_current
241
+ elsif deleted_current
252
242
  invalidate_client
253
243
  invoke :target, :organization => client.current_organization
254
244
  end
255
245
  end
246
+
247
+ private
248
+
249
+ def space_matches(s, options)
250
+ if name = options[:name]
251
+ return false if s.name !~ /#{name}/
252
+ end
253
+
254
+ true
255
+ end
256
+
257
+ def clear_space(space)
258
+ apps = space.apps
259
+ instances = space.service_instances
260
+
261
+ return true if apps.empty? && instances.empty?
262
+
263
+ unless force?
264
+ line "This space is not empty!"
265
+ line
266
+ line "apps: #{name_list(apps)}"
267
+ line "service instances: #{name_list(instances)}"
268
+ line
269
+
270
+ return unless input[:recursive]
271
+ end
272
+
273
+ apps.each do |a|
274
+ invoke :delete, :app => a, :really => true
275
+ end
276
+
277
+ instances.each do |i|
278
+ invoke :delete_service, :instance => i, :really => true
279
+ end
280
+
281
+ true
282
+ end
256
283
  end
257
284
  end
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.4.0.beta.85"
2
+ VERSION = "0.4.0.beta.86"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 2616878885
4
+ hash: 2721457587
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
9
  - 0
10
10
  - beta
11
- - 85
12
- version: 0.4.0.beta.85
11
+ - 86
12
+ version: 0.4.0.beta.86
13
13
  platform: ruby
14
14
  authors:
15
15
  - VMware
@@ -266,12 +266,12 @@ dependencies:
266
266
  requirements:
267
267
  - - ~>
268
268
  - !ruby/object:Gem::Version
269
- hash: 125
269
+ hash: 99
270
270
  segments:
271
271
  - 0
272
272
  - 3
273
- - 55
274
- version: 0.3.55
273
+ - 56
274
+ version: 0.3.56
275
275
  type: :runtime
276
276
  version_requirements: *id015
277
277
  - !ruby/object:Gem::Dependency