Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
use first plan listed, instead of assuming 100
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Suraci and Mark Rushakoff committed Apr 5, 2013
1 parent 889b750 commit 8d879d0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/harness/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8d879d0

Please sign in to comment.