Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit a05a44e

Browse files
committed
v3(service): Tags can be requested for the service offering of the instance
[#155025477](https://www.pivotaltracker.com/story/show/155025477)
1 parent b616751 commit a05a44e

4 files changed

Lines changed: 29 additions & 6 deletions

File tree

app/decorators/field_service_instance_offering_decorator.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module VCAP::CloudController
22
class FieldServiceInstanceOfferingDecorator
33
def self.allowed
4-
Set.new(%w(name guid description documentation_url relationships.service_broker))
4+
Set.new(%w(name guid description documentation_url tags relationships.service_broker))
55
end
66

77
def self.match?(fields)
@@ -25,6 +25,7 @@ def decorate(hash, service_instances)
2525
offering_view[:name] = offering.name if @fields.include?('name')
2626
offering_view[:guid] = offering.guid if @fields.include?('guid')
2727
offering_view[:description] = offering.description if @fields.include?('description')
28+
offering_view[:tags] = offering.tags if @fields.include?('tags')
2829
offering_view[:documentation_url] = extract_documentation_url(offering.extra) if @fields.include?('documentation_url')
2930
if @fields.include?('relationships.service_broker')
3031
offering_view[:relationships] = {

docs/v3/source/includes/experimental_resources/service_instances/_get.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Resource | Allowed Keys
5252
space | `guid`, `name`
5353
space.organization | `name`, `guid`
5454
service_plan| `name`, `guid`
55-
service_plan.service_offering| `name`, `guid`, `description`, `documentation_url`
55+
service_plan.service_offering| `name`, `guid`, `description`, `documentation_url`, `tags`
5656
service_plan.service_offering.service_broker| `name`, `guid`
5757

5858
#### Permitted roles

docs/v3/source/includes/resources/service_instances/_list.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Resource | Allowed Keys
5050
space | `guid`, `name`, `relationships.organization`
5151
space.organization| `guid`, `name`
5252
service_plan| `guid`, `name`, `relationships.service_offering`
53-
service_plan.service_offering| `guid`, `name`, `description`, `documentation_url`, `relationships.service_broker`
53+
service_plan.service_offering| `guid`, `name`, `description`, `documentation_url`, `tags`, `relationships.service_broker`
5454
service_plan.service_offering.service_broker| `guid`, `name`
5555

5656
#### Permitted roles

spec/unit/decorators/field_service_instance_offering_decorator_spec.rb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
module VCAP::CloudController
55
RSpec.describe FieldServiceInstanceOfferingDecorator do
66
describe '.decorate' do
7-
let(:offering1) { Service.make(extra: '{"documentationUrl": "https://offering1.com"}') }
8-
let(:offering2) { Service.make(extra: '{"documentationUrl": "https://offering2.com"}') }
7+
let(:offering1) { Service.make(extra: '{"documentationUrl": "https://offering1.com"}', tags: %w(foo bar)) }
8+
let(:offering2) { Service.make(extra: '{"documentationUrl": "https://offering2.com"}', tags: %w(baz)) }
99

1010
let(:plan1) { ServicePlan.make(service: offering1) }
1111
let(:plan2) { ServicePlan.make(service: offering2) }
@@ -101,6 +101,28 @@ module VCAP::CloudController
101101
})
102102
end
103103

104+
it 'can decorate with the service offering tags' do
105+
undecorated_hash = { foo: 'bar', included: { monkeys: %w(zach greg) } }
106+
decorator = described_class.new({ 'service_plan.service_offering': ['tags', 'foo'] })
107+
108+
hash = decorator.decorate(undecorated_hash, [service_instance_1, service_instance_2])
109+
110+
expect(hash).to match({
111+
foo: 'bar',
112+
included: {
113+
monkeys: %w(zach greg),
114+
service_offerings: [
115+
{
116+
tags: offering1.tags,
117+
},
118+
{
119+
tags: offering2.tags,
120+
}
121+
]
122+
}
123+
})
124+
end
125+
104126
it 'decorated the given hash with offering relationship to broker from service instances' do
105127
undecorated_hash = { foo: 'bar', included: { monkeys: %w(zach greg) } }
106128
decorator = described_class.new({ 'service_plan.service_offering': ['relationships.service_broker', 'foo'] })
@@ -160,7 +182,7 @@ module VCAP::CloudController
160182
end
161183

162184
describe '.match?' do
163-
fields = %w(name guid description documentation_url relationships.service_broker)
185+
fields = %w(name guid description documentation_url tags relationships.service_broker)
164186

165187
fields.each do |field|
166188
it "matches value `#{field}` for key symbol `service_plan.service_offering`" do

0 commit comments

Comments
 (0)