Permalink
Browse files

Merge changes I95567126,I79538afb into services-r12

* changes:
  Bump vcap_common to include mongolab gateway fix
  Add cf_plan_id in service api & ccdb
  • Loading branch information...
2 parents 5538a5d + 5be108e commit c3dce2b65bc9be1b68a738eae8c23294b510d520 @kushmerick kushmerick committed with Gerrit Code Review May 29, 2012
View
@@ -6,7 +6,7 @@ gem 'rails', '~> 3.0.5'
gem 'nats', :require => 'nats/client'
# VCAP common components
-gem 'vcap_common', :require => ['vcap/common', 'vcap/component']
+gem 'vcap_common', :require => ['vcap/common', 'vcap/component'], :git => 'git://github.com/cloudfoundry/vcap-common.git', :ref => '2715dbdaec'
gem 'vcap_logging', :require => ['vcap/logging']
gem 'vcap_staging', '~> 0.1.59'
gem 'cf-uaa-client', '~> 0.0.10', :git => 'git://github.com/cloudfoundry/uaa.git', :ref => '0000f736'
@@ -33,7 +33,7 @@ group :production do
end
# EventMachine and async support
-gem 'eventmachine'
+gem 'eventmachine', :git => 'git://github.com/cloudfoundry/eventmachine.git', :branch => 'release-0.12.11-cf'
gem 'thin'
gem 'em-http-request', '~> 1.0.0.beta.3', :require => 'em-http'
gem 'em-redis', '~> 0.3.0', :require => nil
@@ -1,3 +1,10 @@
+GIT
+ remote: git://github.com/cloudfoundry/eventmachine.git
+ revision: 2806c630d8631d5dcf9fb2555f665b829052aabe
+ branch: release-0.12.11-cf
+ specs:
+ eventmachine (0.12.11.cloudfoundry.3)
+
GIT
remote: git://github.com/cloudfoundry/uaa.git
revision: 0000f73653ae3a09279063e4f73f87066a91b14a
@@ -11,6 +18,18 @@ GIT
rest-client
thor
+GIT
+ remote: git://github.com/cloudfoundry/vcap-common.git
+ revision: 2715dbdaeca8366640730495b50af2680e8177bc
+ ref: 2715dbdaec
+ specs:
+ vcap_common (1.0.13)
+ eventmachine (~> 0.12.11.cloudfoundry.3)
+ nats (~> 0.4.22.beta.8)
+ posix-spawn (~> 0.3.6)
+ thin (~> 1.3.1)
+ yajl-ruby (~> 0.8.3)
+
GEM
remote: http://rubygems.org/
specs:
@@ -66,12 +85,11 @@ GEM
eventmachine
erubis (2.6.6)
abstract (>= 1.0.0)
- eventmachine (0.12.11.cloudfoundry.3)
hiredis (0.3.2)
http_parser.rb (0.5.1)
i18n (0.5.0)
interact (0.4.2)
- json_pure (1.6.6)
+ json_pure (1.7.3)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
@@ -144,12 +162,6 @@ GEM
polyglot (>= 0.3.1)
tzinfo (0.3.26)
uuidtools (2.1.2)
- vcap_common (1.0.12)
- eventmachine (~> 0.12.11.cloudfoundry.3)
- nats (~> 0.4.22.beta.8)
- posix-spawn (~> 0.3.6)
- thin (~> 1.3.1)
- yajl-ruby (~> 0.8.3)
vcap_logging (1.0.1)
vcap_staging (0.1.59)
nokogiri (>= 1.4.4)
@@ -172,7 +184,7 @@ DEPENDENCIES
em-hiredis
em-http-request (~> 1.0.0.beta.3)
em-redis (~> 0.3.0)
- eventmachine
+ eventmachine!
mocha
mysql2 (>= 0.2.6)
nats
@@ -190,7 +202,7 @@ DEPENDENCIES
stager-client (~> 0.0.2)
thin
uuidtools (~> 2.1.2)
- vcap_common
+ vcap_common!
vcap_logging
vcap_staging (~> 0.1.59)
yajl-ruby (~> 0.8.3)
@@ -10,14 +10,16 @@ class Service < ActiveRecord::Base
validates_format_of :url, :with => URI::regexp(%w(http https))
validates_format_of :info_url, :with => URI::regexp(%w(http https)), :allow_nil => true
validates_format_of :label, :with => LABEL_REGEX
+ validate :cf_plan_id_matches_plans
serialize :tags
serialize :plans
+ serialize :cf_plan_id
serialize :plan_options
serialize :binding_options
serialize :acls
- attr_accessible :label, :token, :url, :description, :info_url, :tags, :plans, :plan_options, :binding_options, :active, :acls, :timeout
+ attr_accessible :label, :token, :url, :description, :info_url, :tags, :plans, :cf_plan_id, :plan_options, :binding_options, :active, :acls, :timeout
def self.active_services
where("active = ?", true)
@@ -170,11 +172,20 @@ def hash_to_service_offering
svc_offering[:info_url] = self.info_url if self.info_url
svc_offering[:tags] = self.tags if self.tags
svc_offering[:plans] = self.plans if self.plans
+ svc_offering[:cf_plan_id] = self.cf_plan_id if self.cf_plan_id
svc_offering[:plan_options] = self.plan_options if self.plan_options
svc_offering[:binding_options] = self.binding_options if self.binding_options
svc_offering[:acls] = self.acls if self.acls
svc_offering[:active] = self.active if self.active
svc_offering[:timeout] = self.timeout if self.timeout
return svc_offering
end
+
+ def cf_plan_id_matches_plans
+ # cf_plan_id either be nil,
+ # or its keys must be a subset of plans
+ if cf_plan_id && !(cf_plan_id.is_a?(Hash) && plans.is_a?(Array) && (cf_plan_id.keys - plans).empty?)
+ errors.add(:base, "cf_plan_id does not match plans")
+ end
+ end
end
@@ -0,0 +1,9 @@
+class AddCfPlanIdToService < ActiveRecord::Migration
+ def self.up
+ add_column :services, :cf_plan_id, :string
+ end
+
+ def self.down
+ remove_column :services, :cf_plan_id
+ end
+end
@@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110818080550) do
+ActiveRecord::Schema.define(:version => 20120511124233) do
create_table "app_collaborations", :force => true do |t|
t.integer "app_id"
@@ -127,6 +127,7 @@
t.datetime "created_at"
t.datetime "updated_at"
t.integer "timeout"
+ t.string "cf_plan_id"
end
add_index "services", ["name", "version"], :name => "index_services_on_name_and_version", :unique => true
@@ -53,9 +53,29 @@
svc.should_not be_valid
end
+ it "requires a valid cf_plan_id" do
+ svc = make_service(:label => "foo-bar", :url => "http://www.google.com", :token => "foo")
+ svc.plans = ['foo']
+ svc.should be_valid
+
+ svc.cf_plan_id = "foobar"
+ svc.should_not be_valid
+
+ svc.cf_plan_id = {'123' => '456'}
+ svc.should_not be_valid
+
+ svc.cf_plan_id = {'foo' => 'bar'}
+ svc.should be_valid
+ end
+
it "should serialize complex fields" do
plans = ["foo", "bar"]
- svc = make_service(:label => "foo-bar", :url => "http://www.google.com", :token => "foo", :plans => plans)
+ svc = make_service(
+ :label => "foo-bar",
+ :url => "http://www.google.com",
+ :token => "foo",
+ :plans => plans,
+ )
svc.should be_valid
svc.save
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit c3dce2b

Please sign in to comment.