Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only return instances of core services

  This patch makes the cc respond to legacy api
    GET /services
with only instances of services whose provider is "core".

Test plan: unit tests passed

Change-Id: I3fb11950187eab7b006edc61c1154b33b1f7d4c8
  • Loading branch information...
commit ba343e6f0f91b4174002a1c041a414c6b85a6eac 1 parent 2670127
@d d authored
View
2  lib/cloud_controller/api/service_instance.rb
@@ -15,7 +15,7 @@ module VCAP::CloudController
to_one :service_plan
to_many :service_bindings
attribute :credentials, Hash
- attribute :gateway_data, Hash, :default => "" # FIXME: notation for access override here
+ attribute :gateway_data, Hash, :default => {} # FIXME: notation for access override here
end
query_parameters :name, :space_guid, :service_plan_guid, :service_binding_guid
View
7 lib/cloud_controller/legacy_api/legacy_services.rb
@@ -18,7 +18,12 @@ def initialize(config, logger, request, service_auth_token = nil)
end
def enumerate
- resp = default_space.service_instances.map do |svc_instance|
+ resp = default_space.service_instances_dataset.
+ # I want LINQ-style auto join on FK for this:
+ # filter { service.provider == "core" }.
+ join(:services, :id => :service_id).filter(:provider => DEFAULT_PROVIDER).
+ select_all(:service_instances).
+ map do |svc_instance|
legacy_service_encoding(svc_instance)
end
View
24 spec/api/legacy_services_spec.rb
@@ -74,7 +74,6 @@
:provider => "core",
:url => "http://localhost:56789",
)
- svc1.save
svc1.should be_valid
svc2 = Models::Service.make(
@@ -82,7 +81,6 @@
:provider => "test",
:url => "http://localhost:56789",
)
- svc2.save
svc2.should be_valid
cfg1 = Models::ServiceInstance.make(
@@ -90,7 +88,6 @@
:name => "bar1",
:service => svc1
)
- cfg1.save
cfg1.should be_valid
cfg2 = Models::ServiceInstance.make(
@@ -98,27 +95,22 @@
:name => "bar2",
:service => svc2
)
- cfg2.save
cfg2.should be_valid
bdg1 = Models::ServiceBinding.make(
:gateway_name => "bind1",
:service_instance => cfg1,
:configuration => {},
- :credentials => {},
:binding_options => []
)
- bdg1.save
bdg1.should be_valid
bdg2 = Models::ServiceBinding.make(
:gateway_name => "bind2",
:service_instance => cfg2,
:configuration => {},
- :credentials => {},
:binding_options => []
)
- bdg2.save
bdg2.should be_valid
get "/services/v1/offerings/foo-bar/handles"
@@ -142,9 +134,15 @@
describe "GET /services" do
before do
- @services = []
- 7.times do
- @services << Models::ServiceInstance.make(:space => user.default_space)
+ core_service = Models::Service.make(:provider => "core")
+ @core = 3.times.map do
+ Models::ServiceInstance.make(
+ :space => user.default_space,
+ :service => core_service,
+ )
+ end
+ 2.times do
+ Models::ServiceInstance.make(:space => user.default_space)
end
3.times do
@@ -164,12 +162,12 @@
end
it "should only return services for the default app space" do
- decoded_response.length.should == 7
+ decoded_response.length.should == 3
end
it "should return service names" do
names = decoded_response.map { |a| a["name"] }.sort!
- expected_names = @services.map { |a| a.name }.sort!
+ expected_names = @core.map { |a| a.name }.sort!
names.should == expected_names
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.