Remove other implementation of Reasoner in the selector package since it's a duplicate of the one that's in the identity package --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [x] 🤖 Supportability/Tests - [ ] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Test Plan - [ ] 💪 Manual - [x] ⚡ Unit test - [x] 💚 E2E
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package selectors
|
|
|
|
import (
|
|
"golang.org/x/exp/maps"
|
|
|
|
"github.com/alcionai/corso/src/internal/common/idname"
|
|
"github.com/alcionai/corso/src/pkg/backup/identity"
|
|
"github.com/alcionai/corso/src/pkg/path"
|
|
)
|
|
|
|
func key(br identity.Reasoner) string {
|
|
return br.Category().String() +
|
|
br.ProtectedResource() +
|
|
br.Service().String() +
|
|
br.Tenant()
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// common transformer
|
|
// ---------------------------------------------------------------------------
|
|
|
|
type servicerCategorizerProvider interface {
|
|
pathServicer
|
|
pathCategorier
|
|
idname.Provider
|
|
}
|
|
|
|
func reasonsFor(
|
|
sel servicerCategorizerProvider,
|
|
tenantID string,
|
|
useOwnerNameForID bool,
|
|
) []identity.Reasoner {
|
|
service := sel.PathService()
|
|
reasons := map[string]identity.Reasoner{}
|
|
|
|
resource := sel.ID()
|
|
if useOwnerNameForID {
|
|
resource = sel.Name()
|
|
}
|
|
|
|
pc := sel.PathCategories()
|
|
|
|
for _, sl := range [][]path.CategoryType{pc.Includes, pc.Filters} {
|
|
for _, cat := range sl {
|
|
br := identity.NewReason(tenantID, resource, service, cat)
|
|
reasons[key(br)] = br
|
|
}
|
|
}
|
|
|
|
return maps.Values(reasons)
|
|
}
|