Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Consolidate Reasoner implementations (#4469)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ashmrtn authored Oct 11, 2023
1 parent 84b9de9 commit c07b14c
Showing 1 changed file with 7 additions and 47 deletions.
54 changes: 7 additions & 47 deletions src/pkg/selectors/reasons.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,11 @@ import (
"github.com/alcionai/corso/src/pkg/path"
)

// ---------------------------------------------------------------------------
// reasoner interface compliance
// ---------------------------------------------------------------------------

var _ identity.Reasoner = &backupReason{}

type backupReason struct {
category path.CategoryType
resource string
service path.ServiceType
tenant string
}

func (br backupReason) Tenant() string {
return br.tenant
}

func (br backupReason) ProtectedResource() string {
return br.resource
}

func (br backupReason) Service() path.ServiceType {
return br.service
}

func (br backupReason) Category() path.CategoryType {
return br.category
}

func (br backupReason) SubtreePath() (path.Path, error) {
return path.BuildPrefix(
br.tenant,
br.resource,
br.service,
br.category)
}

func (br backupReason) key() string {
return br.category.String() + br.resource + br.service.String() + br.tenant
func key(br identity.Reasoner) string {
return br.Category().String() +
br.ProtectedResource() +
br.Service().String() +
br.Tenant()
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -76,14 +42,8 @@ func reasonsFor(

for _, sl := range [][]path.CategoryType{pc.Includes, pc.Filters} {
for _, cat := range sl {
br := backupReason{
category: cat,
resource: resource,
service: service,
tenant: tenantID,
}

reasons[br.key()] = br
br := identity.NewReason(tenantID, resource, service, cat)
reasons[key(br)] = br
}
}

Expand Down

0 comments on commit c07b14c

Please sign in to comment.