From 5f82edb78319672eb5e03bc37e18a0fb4a6ed661 Mon Sep 17 00:00:00 2001 From: Keepers Date: Tue, 22 Nov 2022 09:37:48 -0700 Subject: [PATCH] fix resource owner display on backup list (#1580) ## Type of change - [x] :bug: Bugfix ## Issue(s) * #1506 ## Test Plan - [x] :zap: Unit test --- src/pkg/selectors/selectors.go | 8 +++++--- src/pkg/selectors/selectors_test.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/pkg/selectors/selectors.go b/src/pkg/selectors/selectors.go index 8482d1dd0..836a2ae7f 100644 --- a/src/pkg/selectors/selectors.go +++ b/src/pkg/selectors/selectors.go @@ -296,8 +296,8 @@ func resourcesShortFormat(m map[string][]string) string { } // Transforms the slice to a single map. -// Keys are each map's scopeKeyResource value. -// Values are the set of all scopeKeyDataTypes for a given resource. +// Keys are each service's rootCat value. +// Values are the set of all scopeKeyDataTypes for the resource. func toResourceTypeMap[T scopeT](s []scope) map[string][]string { if len(s) == 0 { return nil @@ -314,7 +314,9 @@ func toResourceTypeMap[T scopeT](s []scope) map[string][]string { k = All } - r[k] = addToSet(r[k], split(sc[scopeKeyDataType].Target)) + for _, sk := range split(k) { + r[sk] = addToSet(r[sk], split(sc[scopeKeyDataType].Target)) + } } return r diff --git a/src/pkg/selectors/selectors_test.go b/src/pkg/selectors/selectors_test.go index fe977ed29..5311f14f8 100644 --- a/src/pkg/selectors/selectors_test.go +++ b/src/pkg/selectors/selectors_test.go @@ -106,6 +106,21 @@ func (suite *SelectorSuite) TestToResourceTypeMap() { "smarf": {unknownCatStub.String()}, }, }, + { + name: "multiple resources", + input: []scope{ + scope(stubScope("")), + { + rootCatStub.String(): filterize(scopeConfig{}, join("smarf", "fnords")), + scopeKeyDataType: filterize(scopeConfig{}, unknownCatStub.String()), + }, + }, + expect: map[string][]string{ + "All": {rootCatStub.String()}, + "smarf": {unknownCatStub.String()}, + "fnords": {unknownCatStub.String()}, + }, + }, { name: "disjoint types", input: []scope{