vmc 0.4.0.beta.18 → 0.4.0.beta.19

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.
@@ -40,7 +40,13 @@ module VMC
40
40
  :desc => "What kind of service (e.g. redis, mysql)",
41
41
  :from_given => services_from_label) { |services|
42
42
  [ask("What kind?", :choices => services.sort_by(&:label),
43
- :display => proc { |s| "#{c(s.label, :name)} v#{s.version}" },
43
+ :display => proc { |s|
44
+ str = "#{c(s.label, :name)} v#{s.version}"
45
+ if s.provider != "core"
46
+ str << ", via #{s.provider}"
47
+ end
48
+ str
49
+ },
44
50
  :complete => proc { |s| "#{s.label} v#{s.version}" })]
45
51
  }
46
52
  input(:name, :argument => true,
@@ -48,37 +54,42 @@ module VMC
48
54
  random = sprintf("%x", rand(1000000))
49
55
  ask "Name?", :default => "#{service.label}-#{random}"
50
56
  }
51
- input(:version, :desc => "Version of the service") { |services|
52
- ask "Which version?", :choices => services,
53
- :display => proc(&:version)
54
- }
55
57
  input(:plan, :desc => "Service plan",
56
58
  :from_given => plan_from_name) { |plans|
57
- ask "Which plan?", :choices => plans.sort_by(&:name),
58
- :display => proc { |p| "#{p.name}: #{p.description}" },
59
- :complete => proc(&:name)
59
+ if d100 = plans.find { |p| p.name == "D100" }
60
+ d100
61
+ else
62
+ ask "Which plan?", :choices => plans.sort_by(&:name),
63
+ :display => proc { |p| "#{p.name}: #{p.description}" },
64
+ :complete => proc(&:name)
65
+ end
60
66
  }
67
+ input :provider, :desc => "Service provider"
61
68
  input :bind, :alias => "--app",
62
69
  :desc => "Application to immediately bind to"
63
70
  def create_service(input)
64
71
  services = client.services
65
72
 
66
- services = input[:service, services]
73
+ if input[:provider]
74
+ services.reject! { |s| s.provider != input[:provider] }
75
+ end
67
76
 
68
- if services.size == 1
69
- service = services.first
70
- else
71
- service = input[:version, services]
77
+ until services.size < 2
78
+ services = input[:service, services]
79
+ input.forget(:service)
80
+ end
81
+
82
+ if services.empty?
83
+ fail "Cannot find services matching the given criteria."
72
84
  end
73
85
 
74
- plans = service.service_plans
75
- plan = plans.find { |p| p.name == "D100" } || input[:plan, plans]
86
+ service = services.first
76
87
 
77
88
  instance = client.service_instance
78
89
  instance.name = input[:name, service]
79
90
 
80
91
  if v2?
81
- instance.service_plan = plan
92
+ instance.service_plan = input[:plan, service.service_plans]
82
93
  instance.space = client.current_space
83
94
  instance.credentials = {} # TODO: ?
84
95
  else
@@ -2,6 +2,13 @@ require "vmc/cli"
2
2
 
3
3
  module VMC
4
4
  class Start < CLI
5
+ # Make sure we only show the target once
6
+ @@displayed_target = false
7
+
8
+ def displayed_target?
9
+ @@displayed_target
10
+ end
11
+
5
12
  desc "Display information on the current target, user, etc."
6
13
  group :start
7
14
  input :runtimes, :type => :boolean,
@@ -113,12 +120,6 @@ module VMC
113
120
  if !input.given?(:url) && !input.given?(:organization) &&
114
121
  !input.given?(:space)
115
122
  display_target
116
-
117
- if v2? && client.current_organization && client.current_space
118
- puts "Organization: #{c(client.current_organization.name, :name)}"
119
- puts "Space: #{c(client.current_space.name, :name)}"
120
- end
121
-
122
123
  return
123
124
  end
124
125
 
@@ -135,6 +136,7 @@ module VMC
135
136
  return unless v2?
136
137
 
137
138
  unless client.logged_in?
139
+ puts "" unless quiet?
138
140
  invoke :login
139
141
  @client = nil
140
142
  end
@@ -187,10 +189,7 @@ module VMC
187
189
  ask("Space", :choices => choices)
188
190
  }
189
191
  def login(input)
190
- unless quiet?
191
- display_target
192
- puts ""
193
- end
192
+ display_target unless quiet?
194
193
 
195
194
  credentials =
196
195
  { :username => input[:username],
@@ -260,10 +259,7 @@ module VMC
260
259
  input :login, :type => :boolean, :default => true,
261
260
  :desc => "Automatically log in?"
262
261
  def register(input)
263
- unless quiet?
264
- puts "Target: #{c(client_target, :name)}"
265
- puts ""
266
- end
262
+ display_target unless quiet?
267
263
 
268
264
  email = input[:email]
269
265
  password = input[:password]
@@ -277,9 +273,7 @@ module VMC
277
273
  end
278
274
 
279
275
  if input[:login]
280
- with_progress("Logging in") do
281
- save_token(client.login(email, password))
282
- end
276
+ invoke :login, :username => email, :password => password
283
277
  end
284
278
  end
285
279
 
@@ -295,11 +289,22 @@ module VMC
295
289
  private
296
290
 
297
291
  def display_target
292
+ return if @@displayed_target
293
+
298
294
  if quiet?
299
295
  puts client.target
300
296
  else
301
297
  puts "Target: #{c(client.target, :name)}"
298
+
299
+ if v2? && client.current_organization && client.current_space
300
+ puts "Organization: #{c(client.current_organization.name, :name)}"
301
+ puts "Space: #{c(client.current_space.name, :name)}"
302
+ end
302
303
  end
304
+
305
+ puts ""
306
+
307
+ @@displayed_target = true
303
308
  end
304
309
 
305
310
  def display_runtime(r)
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.4.0.beta.18"
2
+ VERSION = "0.4.0.beta.19"
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: 62196423
4
+ hash: 62196421
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
9
  - 0
10
10
  - beta
11
- - 18
12
- version: 0.4.0.beta.18
11
+ - 19
12
+ version: 0.4.0.beta.19
13
13
  platform: ruby
14
14
  authors:
15
15
  - VMware
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-07-15 00:00:00 Z
20
+ date: 2012-07-16 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: json_pure
@@ -249,12 +249,12 @@ dependencies:
249
249
  requirements:
250
250
  - - ~>
251
251
  - !ruby/object:Gem::Version
252
- hash: 27
252
+ hash: 25
253
253
  segments:
254
254
  - 0
255
255
  - 3
256
- - 4
257
- version: 0.3.4
256
+ - 5
257
+ version: 0.3.5
258
258
  type: :runtime
259
259
  version_requirements: *id014
260
260
  - !ruby/object:Gem::Dependency