WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion actor/v7action/service_instance_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,20 @@ func buildPlanDetailsLookup(included ccv3.IncludedResources) map[string]planDeta
}

func buildBoundAppsLookup(bindings []resources.ServiceCredentialBinding, spaceGUID string) map[string][]string {
type bindingKey struct {
appGUID string
serviceInstanceGUID string
}
seenBindingKeys := make(map[bindingKey]struct{})
appsBoundLookup := make(map[string][]string)
for _, binding := range bindings {
if binding.Type == resources.AppBinding && binding.AppSpaceGUID == spaceGUID {
appsBoundLookup[binding.ServiceInstanceGUID] = append(appsBoundLookup[binding.ServiceInstanceGUID], binding.AppName)
bk := bindingKey{appGUID: binding.AppGUID, serviceInstanceGUID: binding.ServiceInstanceGUID}
// Prevent duplicate app names for the same service instance in case of duplicate bindings
if _, exists := seenBindingKeys[bk]; !exists {
appsBoundLookup[binding.ServiceInstanceGUID] = append(appsBoundLookup[binding.ServiceInstanceGUID], binding.AppName)
seenBindingKeys[bk] = struct{}{}
}
}
}
return appsBoundLookup
Expand Down
2 changes: 2 additions & 0 deletions actor/v7action/service_instance_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ var _ = Describe("Service Instance List Action", func() {
)
fakeCloudControllerClient.GetServiceCredentialBindingsReturns(
[]resources.ServiceCredentialBinding{
{Type: "app", ServiceInstanceGUID: "fake-guid-1", AppGUID: "app-1", AppName: "great-app-1", AppSpaceGUID: spaceGUID},
// Duplicate binding for (app-1, fake-guid-1) pair to ensure app names are not duplicated
{Type: "app", ServiceInstanceGUID: "fake-guid-1", AppGUID: "app-1", AppName: "great-app-1", AppSpaceGUID: spaceGUID},
{Type: "app", ServiceInstanceGUID: "fake-guid-1", AppGUID: "app-2", AppName: "great-app-2", AppSpaceGUID: spaceGUID},
{Type: "app", ServiceInstanceGUID: "fake-guid-2", AppGUID: "app-3", AppName: "great-app-3", AppSpaceGUID: spaceGUID},
Expand Down
Loading