Skip to content

Commit 20df57d

Browse files
committed
Revert "New command "cleanup-outdated-service-bindings" (cloudfoundry#3712)"
This reverts commit fad4bcb.
1 parent 3f547b2 commit 20df57d

16 files changed

Lines changed: 8 additions & 1613 deletions

actor/v7action/cloud_controller_client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ type CloudControllerClient interface {
116116
GetServiceBrokers(query ...ccv3.Query) ([]resources.ServiceBroker, ccv3.Warnings, error)
117117
GetServiceCredentialBindings(query ...ccv3.Query) ([]resources.ServiceCredentialBinding, ccv3.Warnings, error)
118118
GetServiceCredentialBindingDetails(guid string) (resources.ServiceCredentialBindingDetails, ccv3.Warnings, error)
119-
GetServiceInstanceByGUID(serviceInstanceGUID string) (resources.ServiceInstance, ccv3.Warnings, error)
120119
GetServiceInstanceByNameAndSpace(name, spaceGUID string, query ...ccv3.Query) (resources.ServiceInstance, ccv3.IncludedResources, ccv3.Warnings, error)
121120
GetServiceInstanceParameters(serviceInstanceGUID string) (types.JSONObject, ccv3.Warnings, error)
122121
GetServiceInstanceSharedSpaces(serviceInstanceGUID string) ([]ccv3.SpaceWithOrganization, ccv3.Warnings, error)

actor/v7action/service_app_binding.go

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ type CreateServiceAppBindingParams struct {
1818
Strategy resources.BindingStrategyType
1919
}
2020

21-
type ListAppBindingParams struct {
22-
SpaceGUID string
23-
AppName string
24-
}
25-
2621
type ListServiceAppBindingParams struct {
2722
SpaceGUID string
2823
ServiceInstanceName string
@@ -70,33 +65,6 @@ func (actor Actor) CreateServiceAppBinding(params CreateServiceAppBindingParams)
7065
}
7166
}
7267

73-
func (actor Actor) ListAppBindings(params ListAppBindingParams) ([]resources.ServiceCredentialBinding, Warnings, error) {
74-
var (
75-
app resources.Application
76-
bindings []resources.ServiceCredentialBinding
77-
)
78-
79-
warnings, err := railway.Sequentially(
80-
func() (warnings ccv3.Warnings, err error) {
81-
app, warnings, err = actor.CloudControllerClient.GetApplicationByNameAndSpace(params.AppName, params.SpaceGUID)
82-
return
83-
},
84-
func() (warnings ccv3.Warnings, err error) {
85-
bindings, warnings, err = actor.getServiceAppBindings("", app.GUID)
86-
return
87-
},
88-
)
89-
90-
switch err.(type) {
91-
case nil:
92-
return bindings, Warnings(warnings), nil
93-
case ccerror.ApplicationNotFoundError:
94-
return nil, Warnings(warnings), actionerror.ApplicationNotFoundError{Name: params.AppName}
95-
default:
96-
return nil, Warnings(warnings), err
97-
}
98-
}
99-
10068
func (actor Actor) ListServiceAppBindings(params ListServiceAppBindingParams) ([]resources.ServiceCredentialBinding, Warnings, error) {
10169
var (
10270
serviceInstance resources.ServiceInstance
@@ -176,24 +144,16 @@ func (actor Actor) createServiceAppBinding(serviceInstanceGUID, appGUID, binding
176144
}
177145

178146
func (actor Actor) getServiceAppBindings(serviceInstanceGUID, appGUID string) ([]resources.ServiceCredentialBinding, ccv3.Warnings, error) {
179-
queries := []ccv3.Query{
180-
{Key: ccv3.TypeFilter, Values: []string{"app"}},
181-
{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}},
182-
}
183-
if serviceInstanceGUID != "" {
184-
queries = append(queries, ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}})
185-
}
186-
187-
bindings, warnings, err := actor.CloudControllerClient.GetServiceCredentialBindings(queries...)
147+
bindings, warnings, err := actor.CloudControllerClient.GetServiceCredentialBindings(
148+
ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"app"}},
149+
ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstanceGUID}},
150+
ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}},
151+
)
188152

189153
switch {
190154
case err != nil:
191155
return []resources.ServiceCredentialBinding{}, warnings, err
192156
case len(bindings) == 0:
193-
// If no specific service instance is requested, return empty set without error.
194-
if serviceInstanceGUID == "" {
195-
return []resources.ServiceCredentialBinding{}, warnings, nil
196-
}
197157
return []resources.ServiceCredentialBinding{}, warnings, actionerror.ServiceBindingNotFoundError{
198158
AppGUID: appGUID,
199159
ServiceInstanceGUID: serviceInstanceGUID,

actor/v7action/service_app_binding_test.go

Lines changed: 0 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -251,140 +251,6 @@ var _ = Describe("Service App Binding Action", func() {
251251
})
252252
})
253253

254-
Describe("ListAppBindings", func() {
255-
const (
256-
appName = "fake-app-name"
257-
appGUID = "fake-app-guid"
258-
spaceGUID = "fake-space-guid"
259-
bindingGUID = "fake-binding-guid"
260-
)
261-
262-
var (
263-
params ListAppBindingParams
264-
warnings Warnings
265-
executionError error
266-
serviceCredentialBindings []resources.ServiceCredentialBinding
267-
)
268-
269-
BeforeEach(func() {
270-
fakeCloudControllerClient.GetApplicationByNameAndSpaceReturns(
271-
resources.Application{
272-
GUID: appGUID,
273-
Name: appName,
274-
},
275-
ccv3.Warnings{"get app warning"},
276-
nil,
277-
)
278-
279-
fakeCloudControllerClient.GetServiceCredentialBindingsReturns(
280-
[]resources.ServiceCredentialBinding{
281-
{GUID: bindingGUID},
282-
},
283-
ccv3.Warnings{"get bindings warning"},
284-
nil,
285-
)
286-
287-
params = ListAppBindingParams{
288-
SpaceGUID: "fake-space-guid",
289-
AppName: "fake-app-name",
290-
}
291-
})
292-
293-
JustBeforeEach(func() {
294-
serviceCredentialBindings, warnings, executionError = actor.ListAppBindings(params)
295-
})
296-
297-
It("returns an event stream, warning, and no errors", func() {
298-
Expect(executionError).NotTo(HaveOccurred())
299-
300-
Expect(warnings).To(ConsistOf(Warnings{
301-
"get app warning",
302-
"get bindings warning",
303-
}))
304-
305-
Expect(serviceCredentialBindings).To(Equal([]resources.ServiceCredentialBinding{{GUID: bindingGUID}}))
306-
})
307-
308-
Describe("app lookup", func() {
309-
It("makes the correct call", func() {
310-
Expect(fakeCloudControllerClient.GetApplicationByNameAndSpaceCallCount()).To(Equal(1))
311-
actualAppName, actualSpaceGUID := fakeCloudControllerClient.GetApplicationByNameAndSpaceArgsForCall(0)
312-
Expect(actualAppName).To(Equal(appName))
313-
Expect(actualSpaceGUID).To(Equal(spaceGUID))
314-
})
315-
316-
When("not found", func() {
317-
BeforeEach(func() {
318-
fakeCloudControllerClient.GetApplicationByNameAndSpaceReturns(
319-
resources.Application{},
320-
ccv3.Warnings{"get app warning"},
321-
ccerror.ApplicationNotFoundError{Name: appName},
322-
)
323-
})
324-
325-
It("returns the error and warning", func() {
326-
Expect(warnings).To(ContainElement("get app warning"))
327-
Expect(executionError).To(MatchError(actionerror.ApplicationNotFoundError{Name: appName}))
328-
})
329-
})
330-
331-
When("fails", func() {
332-
BeforeEach(func() {
333-
fakeCloudControllerClient.GetApplicationByNameAndSpaceReturns(
334-
resources.Application{},
335-
ccv3.Warnings{"get app warning"},
336-
errors.New("boom"),
337-
)
338-
})
339-
340-
It("returns the error and warning", func() {
341-
Expect(warnings).To(ContainElement("get app warning"))
342-
Expect(executionError).To(MatchError("boom"))
343-
})
344-
})
345-
})
346-
347-
Describe("binding lookup", func() {
348-
It("makes the correct call", func() {
349-
Expect(fakeCloudControllerClient.GetServiceCredentialBindingsCallCount()).To(Equal(1))
350-
Expect(fakeCloudControllerClient.GetServiceCredentialBindingsArgsForCall(0)).To(ConsistOf(
351-
ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"app"}},
352-
ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{appGUID}},
353-
))
354-
})
355-
356-
When("there are no bindings", func() {
357-
BeforeEach(func() {
358-
fakeCloudControllerClient.GetServiceCredentialBindingsReturns(
359-
[]resources.ServiceCredentialBinding{},
360-
ccv3.Warnings{"get bindings warning"},
361-
nil,
362-
)
363-
})
364-
365-
It("returns an empty list", func() {
366-
Expect(warnings).To(ContainElement("get bindings warning"))
367-
Expect(serviceCredentialBindings).To(Equal([]resources.ServiceCredentialBinding{}))
368-
})
369-
})
370-
371-
When("fails", func() {
372-
BeforeEach(func() {
373-
fakeCloudControllerClient.GetServiceCredentialBindingsReturns(
374-
[]resources.ServiceCredentialBinding{},
375-
ccv3.Warnings{"get binding warning"},
376-
errors.New("boom"),
377-
)
378-
})
379-
380-
It("returns the error and warning", func() {
381-
Expect(warnings).To(ContainElement("get binding warning"))
382-
Expect(executionError).To(MatchError("boom"))
383-
})
384-
})
385-
})
386-
})
387-
388254
Describe("ListServiceAppBindings", func() {
389255
const (
390256
serviceInstanceName = "fake-service-instance-name"

actor/v7action/service_instance.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ func (actor Actor) GetServiceInstanceByNameAndSpace(serviceInstanceName string,
3333
return serviceInstance, Warnings(warnings), err
3434
}
3535

36-
func (actor Actor) GetServiceInstanceByGUID(serviceInstanceGUID string) (resources.ServiceInstance, Warnings, error) {
37-
serviceInstance, warnings, err := actor.CloudControllerClient.GetServiceInstanceByGUID(serviceInstanceGUID)
38-
return serviceInstance, Warnings(warnings), err
39-
}
40-
4136
func (actor Actor) CreateUserProvidedServiceInstance(serviceInstance resources.ServiceInstance) (Warnings, error) {
4237
serviceInstance.Type = resources.UserProvidedServiceInstance
4338
_, warnings, err := actor.CloudControllerClient.CreateServiceInstance(serviceInstance)

actor/v7action/v7actionfakes/fake_cloud_controller_client.go

Lines changed: 0 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/cloudcontroller/ccv3/internal/api_routes.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ const (
8686
GetServiceCredentialBindingsRequest = "GetServiceCredentialBindings"
8787
GetServiceCredentialBindingDetailsRequest = "GetServiceCredentialBindingDetails"
8888
GetServiceInstanceParametersRequest = "GetServiceInstanceParameters"
89-
GetServiceInstanceRequest = "GetServiceInstance"
9089
GetServiceInstancesRequest = "GetServiceInstances"
9190
GetServiceInstanceRelationshipsSharedSpacesRequest = "GetServiceInstanceRelationshipSharedSpacesRequest"
9291
GetServiceInstanceSharedSpacesUsageSummaryRequest = "GetServiceInstanceSharedSpacesUsageSummaryRequest"
@@ -307,7 +306,6 @@ var APIRoutes = map[string]Route{
307306
GetServiceCredentialBindingsRequest: {Path: "/v3/service_credential_bindings", Method: http.MethodGet},
308307
DeleteServiceCredentialBindingRequest: {Path: "/v3/service_credential_bindings/:service_credential_binding_guid", Method: http.MethodDelete},
309308
GetServiceCredentialBindingDetailsRequest: {Path: "/v3/service_credential_bindings/:service_credential_binding_guid/details", Method: http.MethodGet},
310-
GetServiceInstanceRequest: {Path: "/v3/service_instances/:service_instance_guid", Method: http.MethodGet},
311309
GetServiceInstancesRequest: {Path: "/v3/service_instances", Method: http.MethodGet},
312310
PostServiceInstanceRequest: {Path: "/v3/service_instances", Method: http.MethodPost},
313311
GetServiceInstanceParametersRequest: {Path: "/v3/service_instances/:service_instance_guid/parameters", Method: http.MethodGet},

api/cloudcontroller/ccv3/service_instance.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ func (client *Client) GetServiceInstances(query ...Query) ([]resources.ServiceIn
3232
return result, included, warnings, err
3333
}
3434

35-
func (client *Client) GetServiceInstanceByGUID(serviceInstanceGUID string) (resources.ServiceInstance, Warnings, error) {
36-
var result resources.ServiceInstance
37-
38-
_, warnings, err := client.MakeRequest(RequestParams{
39-
RequestName: internal.GetServiceInstanceRequest,
40-
URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID},
41-
ResponseBody: &result,
42-
})
43-
44-
return result, warnings, err
45-
}
46-
4735
func (client *Client) GetServiceInstanceByNameAndSpace(name, spaceGUID string, query ...Query) (resources.ServiceInstance, IncludedResources, Warnings, error) {
4836
query = append(query,
4937
Query{Key: NameFilter, Values: []string{name}},

0 commit comments

Comments
 (0)