Permalink
Browse files

use first plan listed, instead of assuming 100

  • Loading branch information...
1 parent 889b750 commit 8d879d0947d3ff9f255ba20342ef0c92e067e6e2 Alex Suraci and Mark Rushakoff committed Apr 5, 2013
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/harness/service.rb
View
@@ -42,20 +42,24 @@ def create(service_manifest, check_available = true)
end
@log.debug("Prepare to create service: #{@instance.name}")
begin
+ plans = service.service_plans
+
if service_manifest[:plan]
plan = service_manifest[:plan]
elsif ENV['VCAP_BVT_SERVICE_PLAN']
plan = ENV['VCAP_BVT_SERVICE_PLAN']
+ elsif @session.v2?
+ plan = plans.first.name
else
- plan = @session.v2? ? "100" : "free"
+ plan = "free"
end
+
if @session.v2?
- plans = service.service_plans.select { |p| p.name == plan}
+ plans = plans.select { |p| p.name == plan }
if plans.size == 0
- plan_list = []
- service.service_plans.each {|p| plan_list << p.name}
- @log.error("can't find service plan #{plan}, supported plans: #{plan_list}")
- raise RuntimeError, "can't find service plan #{plan}, supported plans: #{plan_list}"
+ plan_names = plans.map(&:name).join(", ")
+ @log.error("can't find service plan #{plan}, supported plans: #{plan_names}")
+ raise RuntimeError, "can't find service plan #{plan}, supported plans: #{plan_names}"
end
plan = plans.first
@instance.service_plan = plan

0 comments on commit 8d879d0

Please sign in to comment.