Move reason struct to avoid cycles
This commit is contained in:
parent
ffcc4e1bb8
commit
72269441ea
@ -17,55 +17,6 @@ import (
|
|||||||
"github.com/alcionai/corso/src/pkg/store"
|
"github.com/alcionai/corso/src/pkg/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewReason(
|
|
||||||
tenant, resource string,
|
|
||||||
service path.ServiceType,
|
|
||||||
category path.CategoryType,
|
|
||||||
) identity.Reasoner {
|
|
||||||
return reason{
|
|
||||||
tenant: tenant,
|
|
||||||
resource: resource,
|
|
||||||
service: service,
|
|
||||||
category: category,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type reason struct {
|
|
||||||
// tenant appears here so that when this is moved to an inject package nothing
|
|
||||||
// needs changed. However, kopia itself is blind to the fields in the reason
|
|
||||||
// struct and relies on helper functions to get the information it needs.
|
|
||||||
tenant string
|
|
||||||
resource string
|
|
||||||
service path.ServiceType
|
|
||||||
category path.CategoryType
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r reason) Tenant() string {
|
|
||||||
return r.tenant
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r reason) ProtectedResource() string {
|
|
||||||
return r.resource
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r reason) Service() path.ServiceType {
|
|
||||||
return r.service
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r reason) Category() path.CategoryType {
|
|
||||||
return r.category
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r reason) SubtreePath() (path.Path, error) {
|
|
||||||
p, err := path.BuildPrefix(
|
|
||||||
r.Tenant(),
|
|
||||||
r.ProtectedResource(),
|
|
||||||
r.Service(),
|
|
||||||
r.Category())
|
|
||||||
|
|
||||||
return p, clues.Wrap(err, "building path").OrNil()
|
|
||||||
}
|
|
||||||
|
|
||||||
func tagKeys(r identity.Reasoner) []string {
|
func tagKeys(r identity.Reasoner) []string {
|
||||||
return []string{
|
return []string{
|
||||||
r.ProtectedResource(),
|
r.ProtectedResource(),
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
package identity
|
package identity
|
||||||
|
|
||||||
import "github.com/alcionai/corso/src/pkg/path"
|
import (
|
||||||
|
"github.com/alcionai/clues"
|
||||||
|
|
||||||
|
"github.com/alcionai/corso/src/pkg/path"
|
||||||
|
)
|
||||||
|
|
||||||
// Reasoner describes the parts of the backup that make up its
|
// Reasoner describes the parts of the backup that make up its
|
||||||
// data identity: the tenant, protected resources, services, and
|
// data identity: the tenant, protected resources, services, and
|
||||||
@ -14,3 +18,52 @@ type Reasoner interface {
|
|||||||
// parameters (tenant, protected resourced, etc) that match this Reasoner.
|
// parameters (tenant, protected resourced, etc) that match this Reasoner.
|
||||||
SubtreePath() (path.Path, error)
|
SubtreePath() (path.Path, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewReason(
|
||||||
|
tenant, resource string,
|
||||||
|
service path.ServiceType,
|
||||||
|
category path.CategoryType,
|
||||||
|
) Reasoner {
|
||||||
|
return reason{
|
||||||
|
tenant: tenant,
|
||||||
|
resource: resource,
|
||||||
|
service: service,
|
||||||
|
category: category,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type reason struct {
|
||||||
|
// tenant appears here so that when this is moved to an inject package nothing
|
||||||
|
// needs changed. However, kopia itself is blind to the fields in the reason
|
||||||
|
// struct and relies on helper functions to get the information it needs.
|
||||||
|
tenant string
|
||||||
|
resource string
|
||||||
|
service path.ServiceType
|
||||||
|
category path.CategoryType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r reason) Tenant() string {
|
||||||
|
return r.tenant
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r reason) ProtectedResource() string {
|
||||||
|
return r.resource
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r reason) Service() path.ServiceType {
|
||||||
|
return r.service
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r reason) Category() path.CategoryType {
|
||||||
|
return r.category
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r reason) SubtreePath() (path.Path, error) {
|
||||||
|
p, err := path.BuildPrefix(
|
||||||
|
r.Tenant(),
|
||||||
|
r.ProtectedResource(),
|
||||||
|
r.Service(),
|
||||||
|
r.Category())
|
||||||
|
|
||||||
|
return p, clues.Wrap(err, "building path").OrNil()
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user