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

Commit 8afe080

Browse files
Add documentation url in the offering top level properties
[#171878575]
1 parent 80176ff commit 8afe080

5 files changed

Lines changed: 34 additions & 16 deletions

File tree

app/presenters/v3/service_offering_presenter.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def to_hash
2222
created_at: service_offering.created_at,
2323
updated_at: service_offering.updated_at,
2424
shareable: shareable(metadata),
25+
documentation_url: documentation_url(metadata),
2526
broker_catalog: {
2627
id: service_offering.unique_id,
2728
metadata: metadata,
@@ -52,6 +53,10 @@ def shareable(metadata)
5253
metadata['shareable'] == true
5354
end
5455

56+
def documentation_url(metadata)
57+
metadata['documentation_url'] || ''
58+
end
59+
5560
def broker_metadata
5661
JSON.parse(service_offering.extra)
5762
rescue JSON::ParserError

docs/v3/source/includes/experimental_resources/service_offerings/_object.md.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Name | Type | Description
1818
**created_at** | _datetime_ | The time with zone when the object was created.
1919
**updated_at** | _datetime_ | The time with zone when the object was last updated.
2020
**shareable** | _boolean_ | Whether or not Service Instances of this Service Offering can be shared across Organizations and Spaces.
21+
**documentation_url** | _string_ | Url that points to a documentation page for the Service Offering, if provided by the Service Broker as part of the metadata field as specified by [OSBAPI](https://github.com/openservicebrokerapi/servicebroker/blob/master/profile.md#service-metadata)
2122
**broker_catalog** | _object_ | This object contains information obtained from the Service Broker Catalog.
2223
**broker_catalog.id** | _string_ | The identifier that the Service Broker provided for this Service Offering.
2324
**broker_catalog.metadata** | _object_ | Additional information provided by the Service Broker.

spec/request/service_offerings_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ def create_offering_json(service_offering, labels: {}, annotations: {})
10041004
'created_at' => iso8601,
10051005
'updated_at' => iso8601,
10061006
'shareable' => true,
1007+
'documentation_url' => 'https://some.url.for.docs/',
10071008
'broker_catalog' => {
10081009
'id' => service_offering.unique_id,
10091010
'metadata' => JSON.parse(service_offering.extra),

spec/support/fakes/blueprints.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ module VCAP::CloudController
305305
active { true }
306306
service_broker { ServiceBroker.make }
307307
description { Sham.description } # remove hack
308-
extra { '{"shareable": true}' }
308+
extra { '{"shareable": true, "documentation_url": "https://some.url.for.docs/"}' }
309309
instances_retrievable { false }
310310
bindings_retrievable { false }
311311
end

spec/unit/presenters/v3/service_offering_presenter_spec.rb

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
let(:guid) { 'some-offering-guid' }
77
let(:name) { 'some-offering-name' }
88
let(:description) { 'some offering description' }
9+
let(:documentation_url) { 'https://some.documentation.url/' }
910
let(:available) { false }
1011
let(:bindable) { false }
1112
let(:extra) { '{"foo": "bar", "baz": {"answer": 42}' }
@@ -70,6 +71,7 @@
7071
'created_at': created_at,
7172
'updated_at': service_offering.updated_at,
7273
'shareable': false,
74+
'documentation_url': '',
7375
'broker_catalog': {
7476
'id': id,
7577
'metadata': {
@@ -164,30 +166,39 @@
164166
end
165167
end
166168

167-
context 'when `shareable` is true' do
168-
let(:extra) { '{"shareable": true}' }
169+
context 'extra' do
170+
context 'when `shareable` is true' do
171+
let(:extra) { '{"shareable": true}' }
169172

170-
it 'displays `true``' do
171-
expect(result[:shareable]).to be true
173+
it 'displays `true``' do
174+
expect(result[:shareable]).to be true
175+
end
172176
end
173-
end
174177

175-
context 'when `shareable` is non-boolean' do
176-
let(:extra) { '{"shareable": "invalid value"}' }
178+
context 'when `shareable` is non-boolean' do
179+
let(:extra) { '{"shareable": "invalid value"}' }
177180

178-
it 'displays `false``' do
179-
expect(result[:shareable]).to be false
181+
it 'displays `false``' do
182+
expect(result[:shareable]).to be false
183+
end
180184
end
181-
end
182185

183-
context 'when `shareable` is explicitly false' do
184-
let(:extra) { '{"shareable": false}' }
186+
context 'when `shareable` is explicitly false' do
187+
let(:extra) { '{"shareable": false}' }
185188

186-
it 'displays `false``' do
187-
expect(result[:shareable]).to be false
189+
it 'displays `false``' do
190+
expect(result[:shareable]).to be false
191+
end
188192
end
189-
end
190193

194+
context 'when `documentation_url` is set' do
195+
let(:extra) { '{"documentation_url": "https://some.documentation.url/"}' }
196+
197+
it 'displays the value` as a top level field' do
198+
expect(result[:documentation_url]).to eq 'https://some.documentation.url/'
199+
end
200+
end
201+
end
191202
context 'when `metadata` is not set' do
192203
let(:extra) { nil }
193204

0 commit comments

Comments
 (0)