diff --git a/api.go b/api.go index e44b8bfb..e77f5e43 100644 --- a/api.go +++ b/api.go @@ -290,7 +290,10 @@ func (h serviceBrokerHandler) update(w http.ResponseWriter, req *http.Request) { if updateServiceSpec.IsAsync { statusCode = http.StatusAccepted } - h.respond(w, statusCode, UpdateResponse{OperationData: updateServiceSpec.OperationData}) + h.respond(w, statusCode, UpdateResponse{ + OperationData: updateServiceSpec.OperationData, + DashboardURL: updateServiceSpec.DashboardURL, + }) } func (h serviceBrokerHandler) deprovision(w http.ResponseWriter, req *http.Request) { diff --git a/api_test.go b/api_test.go index d38e233d..5fec0917 100644 --- a/api_test.go +++ b/api_test.go @@ -436,7 +436,7 @@ var _ = Describe("Service Broker API", func() { fakeServiceBroker.DashboardURL = "some-dashboard-url" }) - It("returns json with dasboard URL", func() { + It("returns json with dashboard URL", func() { response := makeInstanceProvisioningRequest(instanceID, provisionDetails, "") Expect(response.Body).To(MatchJSON(fixture("provisioning_with_dashboard.json"))) }) @@ -915,6 +915,18 @@ var _ = Describe("Service Broker API", func() { }) }) }) + + Context("when the broker returns a dashboard URL", func() { + BeforeEach(func() { + fakeServiceBroker.DashboardURL = "some-dashboard-url" + }) + + It("returns json with dashboard URL", func() { + response := makeInstanceUpdateRequest(instanceID, details, "", "2.14") + Expect(response.Body).To(MatchJSON(fixture("updating_with_dashboard.json"))) + }) + }) + }) Context("when the broker indicates that it needs async support", func() { diff --git a/fakes/fake_service_broker.go b/fakes/fake_service_broker.go index a6649936..aac7d15e 100644 --- a/fakes/fake_service_broker.go +++ b/fakes/fake_service_broker.go @@ -229,7 +229,7 @@ func (fakeBroker *FakeServiceBroker) Update(context context.Context, instanceID fakeBroker.UpdateDetails = details fakeBroker.UpdatedInstanceIDs = append(fakeBroker.UpdatedInstanceIDs, instanceID) fakeBroker.AsyncAllowed = asyncAllowed - return brokerapi.UpdateServiceSpec{IsAsync: fakeBroker.ShouldReturnAsync, OperationData: fakeBroker.OperationDataToReturn}, nil + return brokerapi.UpdateServiceSpec{IsAsync: fakeBroker.ShouldReturnAsync, OperationData: fakeBroker.OperationDataToReturn, DashboardURL: fakeBroker.DashboardURL}, nil } func (fakeBroker *FakeServiceBroker) Deprovision(context context.Context, instanceID string, details brokerapi.DeprovisionDetails, asyncAllowed bool) (brokerapi.DeprovisionServiceSpec, error) { diff --git a/fixtures/updating_with_dashboard.json b/fixtures/updating_with_dashboard.json new file mode 100644 index 00000000..0a31f48b --- /dev/null +++ b/fixtures/updating_with_dashboard.json @@ -0,0 +1,3 @@ +{ + "dashboard_url": "some-dashboard-url" +} diff --git a/response.go b/response.go index 1481298e..46b9e428 100644 --- a/response.go +++ b/response.go @@ -32,6 +32,7 @@ type ProvisioningResponse struct { } type UpdateResponse struct { + DashboardURL string `json:"dashboard_url,omitempty"` OperationData string `json:"operation,omitempty"` } diff --git a/response_test.go b/response_test.go index c7b3efef..df9e8b05 100644 --- a/response_test.go +++ b/response_test.go @@ -60,6 +60,30 @@ var _ = Describe("Provisioning Response", func() { }) }) +var _ = Describe("Update Response", func() { + Describe("JSON encoding", func() { + Context("when the dashboard URL is not present", func() { + It("does not return it in the JSON", func() { + updateResponse := brokerapi.UpdateResponse{} + jsonString := `{}` + + Expect(json.Marshal(updateResponse)).To(MatchJSON(jsonString)) + }) + }) + + Context("when the dashboard URL is present", func() { + It("returns it in the JSON", func() { + updateResponse := brokerapi.UpdateResponse{ + DashboardURL: "http://example.com/broker_updated", + } + jsonString := `{"dashboard_url":"http://example.com/broker_updated"}` + + Expect(json.Marshal(updateResponse)).To(MatchJSON(jsonString)) + }) + }) + }) +}) + var _ = Describe("Binding Response", func() { Describe("JSON encoding", func() { It("has a credentials object", func() { diff --git a/service_broker.go b/service_broker.go index 6e4cc018..8efa0c0d 100644 --- a/service_broker.go +++ b/service_broker.go @@ -109,6 +109,7 @@ type UnbindDetails struct { type UpdateServiceSpec struct { IsAsync bool + DashboardURL string OperationData string }