move kopia.Reasoner to new package
Moves the kopia.Reasoner interface out of the kopia package and into pkg/backup/identity. No logical changes here, just renaming and movement.
This commit is contained in:
parent
3b73b61c90
commit
e3e90e397c
@ -8,6 +8,7 @@ import (
|
||||
"golang.org/x/exp/slices"
|
||||
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
)
|
||||
|
||||
@ -25,7 +26,7 @@ type BackupBases interface {
|
||||
MergeBackupBases(
|
||||
ctx context.Context,
|
||||
other BackupBases,
|
||||
reasonToKey func(Reasoner) string,
|
||||
reasonToKey func(identity.Reasoner) string,
|
||||
) BackupBases
|
||||
}
|
||||
|
||||
@ -131,7 +132,7 @@ func (bb *backupBases) ClearAssistBases() {
|
||||
func (bb *backupBases) MergeBackupBases(
|
||||
ctx context.Context,
|
||||
other BackupBases,
|
||||
reasonToKey func(reason Reasoner) string,
|
||||
reasonToKey func(reason identity.Reasoner) string,
|
||||
) BackupBases {
|
||||
if other == nil || (len(other.MergeBases()) == 0 && len(other.AssistBases()) == 0) {
|
||||
return bb
|
||||
@ -165,7 +166,7 @@ func (bb *backupBases) MergeBackupBases(
|
||||
|
||||
// Calculate the set of mergeBases to pull from other into this one.
|
||||
for _, m := range other.MergeBases() {
|
||||
useReasons := []Reasoner{}
|
||||
useReasons := []identity.Reasoner{}
|
||||
|
||||
for _, r := range m.Reasons {
|
||||
k := reasonToKey(r)
|
||||
@ -216,7 +217,7 @@ func (bb *backupBases) MergeBackupBases(
|
||||
|
||||
// Add assistBases from other to this one as needed.
|
||||
for _, m := range other.AssistBases() {
|
||||
useReasons := []Reasoner{}
|
||||
useReasons := []identity.Reasoner{}
|
||||
|
||||
// Assume that all complete manifests in assist overlap with MergeBases.
|
||||
if len(m.IncompleteReason) == 0 {
|
||||
|
||||
@ -13,10 +13,11 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/internal/version"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
|
||||
func makeManifest(id, incmpl, bID string, reasons ...Reasoner) ManifestEntry {
|
||||
func makeManifest(id, incmpl, bID string, reasons ...identity.Reasoner) ManifestEntry {
|
||||
bIDKey, _ := makeTagKV(TagBackupID)
|
||||
|
||||
return ManifestEntry{
|
||||
@ -223,7 +224,7 @@ func (suite *BackupBasesUnitSuite) TestMergeBackupBases() {
|
||||
ir = "checkpoint"
|
||||
}
|
||||
|
||||
reasons := make([]Reasoner, 0, len(i.cat))
|
||||
reasons := make([]identity.Reasoner, 0, len(i.cat))
|
||||
|
||||
for _, c := range i.cat {
|
||||
reasons = append(reasons, NewReason("", ro, path.ExchangeService, c))
|
||||
@ -453,7 +454,7 @@ func (suite *BackupBasesUnitSuite) TestMergeBackupBases() {
|
||||
got := bb.MergeBackupBases(
|
||||
ctx,
|
||||
other,
|
||||
func(r Reasoner) string {
|
||||
func(r identity.Reasoner) string {
|
||||
return r.Service().String() + r.Category().String()
|
||||
})
|
||||
AssertBackupBasesEqual(t, expect, got)
|
||||
|
||||
@ -12,6 +12,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/model"
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
@ -29,23 +30,11 @@ const (
|
||||
userTagPrefix = "tag:"
|
||||
)
|
||||
|
||||
// TODO(ashmrtn): Move this into some inject package. Here to avoid import
|
||||
// cycles.
|
||||
type Reasoner interface {
|
||||
Tenant() string
|
||||
ProtectedResource() string
|
||||
Service() path.ServiceType
|
||||
Category() path.CategoryType
|
||||
// SubtreePath returns the path prefix for data in existing backups that have
|
||||
// parameters (tenant, protected resourced, etc) that match this Reasoner.
|
||||
SubtreePath() (path.Path, error)
|
||||
}
|
||||
|
||||
func NewReason(
|
||||
tenant, resource string,
|
||||
service path.ServiceType,
|
||||
category path.CategoryType,
|
||||
) Reasoner {
|
||||
) identity.Reasoner {
|
||||
return reason{
|
||||
tenant: tenant,
|
||||
resource: resource,
|
||||
@ -90,7 +79,7 @@ func (r reason) SubtreePath() (path.Path, error) {
|
||||
return p, clues.Wrap(err, "building path").OrNil()
|
||||
}
|
||||
|
||||
func tagKeys(r Reasoner) []string {
|
||||
func tagKeys(r identity.Reasoner) []string {
|
||||
return []string{
|
||||
r.ProtectedResource(),
|
||||
serviceCatString(r.Service(), r.Category()),
|
||||
@ -98,13 +87,13 @@ func tagKeys(r Reasoner) []string {
|
||||
}
|
||||
|
||||
// reasonKey returns the concatenation of the ProtectedResource, Service, and Category.
|
||||
func reasonKey(r Reasoner) string {
|
||||
func reasonKey(r identity.Reasoner) string {
|
||||
return r.ProtectedResource() + r.Service().String() + r.Category().String()
|
||||
}
|
||||
|
||||
type BackupEntry struct {
|
||||
*backup.Backup
|
||||
Reasons []Reasoner
|
||||
Reasons []identity.Reasoner
|
||||
}
|
||||
|
||||
type ManifestEntry struct {
|
||||
@ -116,7 +105,7 @@ type ManifestEntry struct {
|
||||
// 1. backup user1 email,contacts -> B1
|
||||
// 2. backup user1 contacts -> B2 (uses B1 as base)
|
||||
// 3. backup user1 email,contacts,events (uses B1 for email, B2 for contacts)
|
||||
Reasons []Reasoner
|
||||
Reasons []identity.Reasoner
|
||||
}
|
||||
|
||||
func (me ManifestEntry) GetTag(key string) (string, bool) {
|
||||
@ -212,7 +201,7 @@ func (b *baseFinder) getBackupModel(
|
||||
// most recent complete backup as the base.
|
||||
func (b *baseFinder) findBasesInSet(
|
||||
ctx context.Context,
|
||||
reason Reasoner,
|
||||
reason identity.Reasoner,
|
||||
metas []*manifest.EntryMetadata,
|
||||
) (*BackupEntry, *ManifestEntry, []ManifestEntry, error) {
|
||||
// Sort manifests by time so we can go through them sequentially. The code in
|
||||
@ -245,7 +234,7 @@ func (b *baseFinder) findBasesInSet(
|
||||
|
||||
kopiaAssistSnaps = append(kopiaAssistSnaps, ManifestEntry{
|
||||
Manifest: man,
|
||||
Reasons: []Reasoner{reason},
|
||||
Reasons: []identity.Reasoner{reason},
|
||||
})
|
||||
|
||||
logger.Ctx(ictx).Info("found incomplete backup")
|
||||
@ -266,7 +255,7 @@ func (b *baseFinder) findBasesInSet(
|
||||
|
||||
kopiaAssistSnaps = append(kopiaAssistSnaps, ManifestEntry{
|
||||
Manifest: man,
|
||||
Reasons: []Reasoner{reason},
|
||||
Reasons: []identity.Reasoner{reason},
|
||||
})
|
||||
|
||||
logger.Ctx(ictx).Info("found incomplete backup")
|
||||
@ -290,7 +279,7 @@ func (b *baseFinder) findBasesInSet(
|
||||
|
||||
kopiaAssistSnaps = append(kopiaAssistSnaps, ManifestEntry{
|
||||
Manifest: man,
|
||||
Reasons: []Reasoner{reason},
|
||||
Reasons: []identity.Reasoner{reason},
|
||||
})
|
||||
|
||||
logger.Ctx(ictx).Infow(
|
||||
@ -308,13 +297,13 @@ func (b *baseFinder) findBasesInSet(
|
||||
|
||||
me := ManifestEntry{
|
||||
Manifest: man,
|
||||
Reasons: []Reasoner{reason},
|
||||
Reasons: []identity.Reasoner{reason},
|
||||
}
|
||||
kopiaAssistSnaps = append(kopiaAssistSnaps, me)
|
||||
|
||||
return &BackupEntry{
|
||||
Backup: bup,
|
||||
Reasons: []Reasoner{reason},
|
||||
Reasons: []identity.Reasoner{reason},
|
||||
}, &me, kopiaAssistSnaps, nil
|
||||
}
|
||||
|
||||
@ -325,7 +314,7 @@ func (b *baseFinder) findBasesInSet(
|
||||
|
||||
func (b *baseFinder) getBase(
|
||||
ctx context.Context,
|
||||
r Reasoner,
|
||||
r identity.Reasoner,
|
||||
tags map[string]string,
|
||||
) (*BackupEntry, *ManifestEntry, []ManifestEntry, error) {
|
||||
allTags := map[string]string{}
|
||||
@ -352,7 +341,7 @@ func (b *baseFinder) getBase(
|
||||
|
||||
func (b *baseFinder) FindBases(
|
||||
ctx context.Context,
|
||||
reasons []Reasoner,
|
||||
reasons []identity.Reasoner,
|
||||
tags map[string]string,
|
||||
) BackupBases {
|
||||
var (
|
||||
|
||||
@ -14,6 +14,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/model"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
|
||||
@ -39,7 +40,7 @@ var (
|
||||
testUser2 = "user2"
|
||||
testUser3 = "user3"
|
||||
|
||||
testAllUsersAllCats = []Reasoner{
|
||||
testAllUsersAllCats = []identity.Reasoner{
|
||||
// User1 email and events.
|
||||
NewReason("", testUser1, path.ExchangeService, path.EmailCategory),
|
||||
NewReason("", testUser1, path.ExchangeService, path.EventsCategory),
|
||||
@ -50,12 +51,12 @@ var (
|
||||
NewReason("", testUser3, path.ExchangeService, path.EmailCategory),
|
||||
NewReason("", testUser3, path.ExchangeService, path.EventsCategory),
|
||||
}
|
||||
testAllUsersMail = []Reasoner{
|
||||
testAllUsersMail = []identity.Reasoner{
|
||||
NewReason("", testUser1, path.ExchangeService, path.EmailCategory),
|
||||
NewReason("", testUser2, path.ExchangeService, path.EmailCategory),
|
||||
NewReason("", testUser3, path.ExchangeService, path.EmailCategory),
|
||||
}
|
||||
testUser1Mail = []Reasoner{
|
||||
testUser1Mail = []identity.Reasoner{
|
||||
NewReason("", testUser1, path.ExchangeService, path.EmailCategory),
|
||||
}
|
||||
)
|
||||
@ -285,7 +286,7 @@ func (suite *BaseFinderUnitSuite) TestNoResult_NoBackupsOrSnapshots() {
|
||||
sm: mockEmptySnapshotManager{},
|
||||
bg: mockEmptyModelGetter{},
|
||||
}
|
||||
reasons := []Reasoner{
|
||||
reasons := []identity.Reasoner{
|
||||
NewReason("", "a-user", path.ExchangeService, path.EmailCategory),
|
||||
}
|
||||
|
||||
@ -304,7 +305,7 @@ func (suite *BaseFinderUnitSuite) TestNoResult_ErrorListingSnapshots() {
|
||||
sm: &mockSnapshotManager{findErr: assert.AnError},
|
||||
bg: mockEmptyModelGetter{},
|
||||
}
|
||||
reasons := []Reasoner{
|
||||
reasons := []identity.Reasoner{
|
||||
NewReason("", "a-user", path.ExchangeService, path.EmailCategory),
|
||||
}
|
||||
|
||||
@ -316,14 +317,14 @@ func (suite *BaseFinderUnitSuite) TestNoResult_ErrorListingSnapshots() {
|
||||
func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
table := []struct {
|
||||
name string
|
||||
input []Reasoner
|
||||
input []identity.Reasoner
|
||||
manifestData []manifestInfo
|
||||
// Use this to denote the Reasons a base backup or base manifest is
|
||||
// selected. The int maps to the index of the backup or manifest in data.
|
||||
expectedBaseReasons map[int][]Reasoner
|
||||
expectedBaseReasons map[int][]identity.Reasoner
|
||||
// Use this to denote the Reasons a kopia assised incrementals manifest is
|
||||
// selected. The int maps to the index of the manifest in data.
|
||||
expectedAssistManifestReasons map[int][]Reasoner
|
||||
expectedAssistManifestReasons map[int][]identity.Reasoner
|
||||
backupData []backupInfo
|
||||
}{
|
||||
{
|
||||
@ -349,10 +350,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
1: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
1: testUser1Mail,
|
||||
},
|
||||
backupData: []backupInfo{
|
||||
@ -383,10 +384,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
1: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
1: testUser1Mail,
|
||||
},
|
||||
@ -418,10 +419,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
1: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
1: testUser1Mail,
|
||||
},
|
||||
@ -447,10 +448,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser3,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
backupData: []backupInfo{
|
||||
@ -474,10 +475,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser3,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
0: testAllUsersAllCats,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: testAllUsersAllCats,
|
||||
},
|
||||
backupData: []backupInfo{
|
||||
@ -512,7 +513,7 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser3,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
0: {
|
||||
NewReason("", testUser1, path.ExchangeService, path.EmailCategory),
|
||||
NewReason("", testUser2, path.ExchangeService, path.EmailCategory),
|
||||
@ -524,7 +525,7 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
NewReason("", testUser3, path.ExchangeService, path.EventsCategory),
|
||||
},
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: {
|
||||
NewReason("", testUser1, path.ExchangeService, path.EmailCategory),
|
||||
NewReason("", testUser2, path.ExchangeService, path.EmailCategory),
|
||||
@ -564,10 +565,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
1: testUser1Mail,
|
||||
},
|
||||
@ -600,10 +601,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
1: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
1: testUser1Mail,
|
||||
},
|
||||
backupData: []backupInfo{
|
||||
@ -635,8 +636,8 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{},
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
1: testUser1Mail,
|
||||
},
|
||||
backupData: []backupInfo{
|
||||
@ -659,10 +660,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
backupData: []backupInfo{
|
||||
@ -694,10 +695,10 @@ func (suite *BaseFinderUnitSuite) TestGetBases() {
|
||||
testUser1,
|
||||
),
|
||||
},
|
||||
expectedBaseReasons: map[int][]Reasoner{
|
||||
expectedBaseReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
expectedAssistManifestReasons: map[int][]Reasoner{
|
||||
expectedAssistManifestReasons: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
backupData: []backupInfo{
|
||||
@ -764,17 +765,17 @@ func (suite *BaseFinderUnitSuite) TestFindBases_CustomTags() {
|
||||
|
||||
table := []struct {
|
||||
name string
|
||||
input []Reasoner
|
||||
input []identity.Reasoner
|
||||
tags map[string]string
|
||||
// Use this to denote which manifests in data should be expected. Allows
|
||||
// defining data in a table while not repeating things between data and
|
||||
// expected.
|
||||
expectedIdxs map[int][]Reasoner
|
||||
expectedIdxs map[int][]identity.Reasoner
|
||||
}{
|
||||
{
|
||||
name: "no tags specified",
|
||||
tags: nil,
|
||||
expectedIdxs: map[int][]Reasoner{
|
||||
expectedIdxs: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
},
|
||||
@ -784,14 +785,14 @@ func (suite *BaseFinderUnitSuite) TestFindBases_CustomTags() {
|
||||
"fnords": "",
|
||||
"smarf": "",
|
||||
},
|
||||
expectedIdxs: map[int][]Reasoner{
|
||||
expectedIdxs: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "subset of custom tags",
|
||||
tags: map[string]string{"fnords": ""},
|
||||
expectedIdxs: map[int][]Reasoner{
|
||||
expectedIdxs: map[int][]identity.Reasoner{
|
||||
0: testUser1Mail,
|
||||
},
|
||||
},
|
||||
@ -832,7 +833,7 @@ func checkManifestEntriesMatch(
|
||||
t *testing.T,
|
||||
retSnaps []ManifestEntry,
|
||||
allExpected []manifestInfo,
|
||||
expectedIdxsAndReasons map[int][]Reasoner,
|
||||
expectedIdxsAndReasons map[int][]identity.Reasoner,
|
||||
) {
|
||||
// Check the proper snapshot manifests were returned.
|
||||
expected := make([]*snapshot.Manifest, 0, len(expectedIdxsAndReasons))
|
||||
@ -848,7 +849,7 @@ func checkManifestEntriesMatch(
|
||||
assert.ElementsMatch(t, expected, got)
|
||||
|
||||
// Check the reasons for selecting each manifest are correct.
|
||||
expectedReasons := make(map[manifest.ID][]Reasoner, len(expectedIdxsAndReasons))
|
||||
expectedReasons := make(map[manifest.ID][]identity.Reasoner, len(expectedIdxsAndReasons))
|
||||
for idx, reasons := range expectedIdxsAndReasons {
|
||||
expectedReasons[allExpected[idx].man.ID] = reasons
|
||||
}
|
||||
@ -874,7 +875,7 @@ func checkBackupEntriesMatch(
|
||||
t *testing.T,
|
||||
retBups []BackupEntry,
|
||||
allExpected []backupInfo,
|
||||
expectedIdxsAndReasons map[int][]Reasoner,
|
||||
expectedIdxsAndReasons map[int][]identity.Reasoner,
|
||||
) {
|
||||
// Check the proper snapshot manifests were returned.
|
||||
expected := make([]*backup.Backup, 0, len(expectedIdxsAndReasons))
|
||||
@ -890,7 +891,7 @@ func checkBackupEntriesMatch(
|
||||
assert.ElementsMatch(t, expected, got)
|
||||
|
||||
// Check the reasons for selecting each manifest are correct.
|
||||
expectedReasons := make(map[model.StableID][]Reasoner, len(expectedIdxsAndReasons))
|
||||
expectedReasons := make(map[model.StableID][]identity.Reasoner, len(expectedIdxsAndReasons))
|
||||
for idx, reasons := range expectedIdxsAndReasons {
|
||||
expectedReasons[allExpected[idx].b.ID] = reasons
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/data"
|
||||
"github.com/alcionai/corso/src/internal/kopia"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
@ -15,7 +16,7 @@ type (
|
||||
BackupConsumer interface {
|
||||
ConsumeBackupCollections(
|
||||
ctx context.Context,
|
||||
backupReasons []kopia.Reasoner,
|
||||
backupReasons []identity.Reasoner,
|
||||
bases kopia.BackupBases,
|
||||
cs []data.BackupCollection,
|
||||
pmr prefixmatcher.StringSetReader,
|
||||
@ -38,7 +39,7 @@ type (
|
||||
BaseFinder interface {
|
||||
FindBases(
|
||||
ctx context.Context,
|
||||
reasons []kopia.Reasoner,
|
||||
reasons []identity.Reasoner,
|
||||
tags map[string]string,
|
||||
) kopia.BackupBases
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ import (
|
||||
exchMock "github.com/alcionai/corso/src/internal/m365/exchange/mock"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
@ -951,7 +952,7 @@ func makeManifestEntry(
|
||||
service path.ServiceType,
|
||||
categories ...path.CategoryType,
|
||||
) ManifestEntry {
|
||||
var reasons []Reasoner
|
||||
var reasons []identity.Reasoner
|
||||
|
||||
for _, c := range categories {
|
||||
reasons = append(reasons, NewReason(tenant, resourceOwner, service, c))
|
||||
|
||||
@ -23,6 +23,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/operations/inject"
|
||||
"github.com/alcionai/corso/src/internal/stats"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/control/repository"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
@ -137,7 +138,7 @@ func (w *Wrapper) Close(ctx context.Context) error {
|
||||
// complete backup of all data.
|
||||
func (w Wrapper) ConsumeBackupCollections(
|
||||
ctx context.Context,
|
||||
backupReasons []Reasoner,
|
||||
backupReasons []identity.Reasoner,
|
||||
bases BackupBases,
|
||||
collections []data.BackupCollection,
|
||||
globalExcludeSet prefixmatcher.StringSetReader,
|
||||
|
||||
@ -29,6 +29,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/m365/onedrive/metadata"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/control/repository"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
@ -800,7 +801,7 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections() {
|
||||
"brunhilda": "",
|
||||
}
|
||||
|
||||
reasons := []Reasoner{
|
||||
reasons := []identity.Reasoner{
|
||||
NewReason(
|
||||
testTenant,
|
||||
suite.storePath1.ResourceOwner(),
|
||||
@ -1072,7 +1073,7 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections_NoDetailsForMeta() {
|
||||
"brunhilda": "",
|
||||
}
|
||||
|
||||
reasons := []Reasoner{
|
||||
reasons := []identity.Reasoner{
|
||||
NewReason(
|
||||
testTenant,
|
||||
storePath.ResourceOwner(),
|
||||
@ -1267,7 +1268,7 @@ func (suite *KopiaIntegrationSuite) TestRestoreAfterCompressionChange() {
|
||||
|
||||
stats, _, _, err := w.ConsumeBackupCollections(
|
||||
ctx,
|
||||
[]Reasoner{r},
|
||||
[]identity.Reasoner{r},
|
||||
nil,
|
||||
[]data.BackupCollection{dc1, dc2},
|
||||
nil,
|
||||
@ -1385,7 +1386,7 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections_ReaderError() {
|
||||
|
||||
stats, deets, _, err := suite.w.ConsumeBackupCollections(
|
||||
suite.ctx,
|
||||
[]Reasoner{r},
|
||||
[]identity.Reasoner{r},
|
||||
nil,
|
||||
collections,
|
||||
nil,
|
||||
@ -1618,7 +1619,7 @@ func (suite *KopiaSimpleRepoIntegrationSuite) SetupTest() {
|
||||
|
||||
stats, deets, _, err := suite.w.ConsumeBackupCollections(
|
||||
suite.ctx,
|
||||
[]Reasoner{r},
|
||||
[]identity.Reasoner{r},
|
||||
nil,
|
||||
collections,
|
||||
nil,
|
||||
@ -1745,11 +1746,11 @@ func (suite *KopiaSimpleRepoIntegrationSuite) TestBackupExcludeItem() {
|
||||
|
||||
stats, _, _, err := suite.w.ConsumeBackupCollections(
|
||||
suite.ctx,
|
||||
[]Reasoner{r},
|
||||
[]identity.Reasoner{r},
|
||||
NewMockBackupBases().WithMergeBases(
|
||||
ManifestEntry{
|
||||
Manifest: man,
|
||||
Reasons: []Reasoner{r},
|
||||
Reasons: []identity.Reasoner{r},
|
||||
},
|
||||
),
|
||||
test.cols(),
|
||||
|
||||
@ -26,6 +26,7 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
@ -367,7 +368,7 @@ func (op *BackupOperation) do(
|
||||
return deets, nil
|
||||
}
|
||||
|
||||
func makeFallbackReasons(tenant string, sel selectors.Selector) []kopia.Reasoner {
|
||||
func makeFallbackReasons(tenant string, sel selectors.Selector) []identity.Reasoner {
|
||||
if sel.PathService() != path.SharePointService &&
|
||||
sel.DiscreteOwner != sel.DiscreteOwnerName {
|
||||
return selectorToReasons(tenant, sel, true)
|
||||
@ -419,9 +420,9 @@ func selectorToReasons(
|
||||
tenant string,
|
||||
sel selectors.Selector,
|
||||
useOwnerNameForID bool,
|
||||
) []kopia.Reasoner {
|
||||
) []identity.Reasoner {
|
||||
service := sel.PathService()
|
||||
reasons := []kopia.Reasoner{}
|
||||
reasons := []identity.Reasoner{}
|
||||
|
||||
pcs, err := sel.PathCategories()
|
||||
if err != nil {
|
||||
@ -449,7 +450,7 @@ func consumeBackupCollections(
|
||||
ctx context.Context,
|
||||
bc kinject.BackupConsumer,
|
||||
tenantID string,
|
||||
reasons []kopia.Reasoner,
|
||||
reasons []identity.Reasoner,
|
||||
bbs kopia.BackupBases,
|
||||
cs []data.BackupCollection,
|
||||
pmr prefixmatcher.StringSetReader,
|
||||
@ -501,7 +502,7 @@ func consumeBackupCollections(
|
||||
return kopiaStats, deets, itemsSourcedFromBase, err
|
||||
}
|
||||
|
||||
func matchesReason(reasons []kopia.Reasoner, p path.Path) bool {
|
||||
func matchesReason(reasons []identity.Reasoner, p path.Path) bool {
|
||||
for _, reason := range reasons {
|
||||
if p.ResourceOwner() == reason.ProtectedResource() &&
|
||||
p.Service() == reason.Service() &&
|
||||
|
||||
@ -27,6 +27,7 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -107,7 +108,7 @@ func checkPaths(t *testing.T, expected, got []path.Path) {
|
||||
|
||||
type mockBackupConsumer struct {
|
||||
checkFunc func(
|
||||
backupReasons []kopia.Reasoner,
|
||||
backupReasons []identity.Reasoner,
|
||||
bases kopia.BackupBases,
|
||||
cs []data.BackupCollection,
|
||||
tags map[string]string,
|
||||
@ -116,7 +117,7 @@ type mockBackupConsumer struct {
|
||||
|
||||
func (mbu mockBackupConsumer) ConsumeBackupCollections(
|
||||
ctx context.Context,
|
||||
backupReasons []kopia.Reasoner,
|
||||
backupReasons []identity.Reasoner,
|
||||
bases kopia.BackupBases,
|
||||
cs []data.BackupCollection,
|
||||
excluded prefixmatcher.StringSetReader,
|
||||
@ -406,7 +407,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_ConsumeBackupDataCollections
|
||||
path.ExchangeService,
|
||||
path.ContactsCategory)
|
||||
|
||||
reasons = []kopia.Reasoner{
|
||||
reasons = []identity.Reasoner{
|
||||
emailReason,
|
||||
contactsReason,
|
||||
}
|
||||
@ -421,13 +422,13 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_ConsumeBackupDataCollections
|
||||
bases = kopia.NewMockBackupBases().WithMergeBases(
|
||||
kopia.ManifestEntry{
|
||||
Manifest: manifest1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
emailReason,
|
||||
},
|
||||
}).WithAssistBases(
|
||||
kopia.ManifestEntry{
|
||||
Manifest: manifest2,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
contactsReason,
|
||||
},
|
||||
})
|
||||
@ -441,7 +442,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_ConsumeBackupDataCollections
|
||||
|
||||
mbu := &mockBackupConsumer{
|
||||
checkFunc: func(
|
||||
backupReasons []kopia.Reasoner,
|
||||
backupReasons []identity.Reasoner,
|
||||
gotBases kopia.BackupBases,
|
||||
cs []data.BackupCollection,
|
||||
gotTags map[string]string,
|
||||
@ -590,7 +591,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
},
|
||||
DetailsID: "foo",
|
||||
},
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -609,7 +610,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -636,13 +637,13 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -669,7 +670,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -728,7 +729,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -755,7 +756,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -785,7 +786,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -815,7 +816,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -846,7 +847,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
@ -877,13 +878,13 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsItems
|
||||
inputBackups: []kopia.BackupEntry{
|
||||
{
|
||||
Backup: &backup1,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
},
|
||||
{
|
||||
Backup: &backup2,
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason3,
|
||||
},
|
||||
},
|
||||
@ -983,7 +984,7 @@ func (suite *BackupOpUnitSuite) TestBackupOperation_MergeBackupDetails_AddsFolde
|
||||
},
|
||||
DetailsID: "did1",
|
||||
},
|
||||
Reasons: []kopia.Reasoner{
|
||||
Reasons: []identity.Reasoner{
|
||||
pathReason1,
|
||||
},
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/kopia"
|
||||
"github.com/alcionai/corso/src/internal/kopia/inject"
|
||||
"github.com/alcionai/corso/src/internal/m365/graph"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/logger"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -23,7 +24,7 @@ func produceManifestsAndMetadata(
|
||||
ctx context.Context,
|
||||
bf inject.BaseFinder,
|
||||
rp inject.RestoreProducer,
|
||||
reasons, fallbackReasons []kopia.Reasoner,
|
||||
reasons, fallbackReasons []identity.Reasoner,
|
||||
tenantID string,
|
||||
getMetadata bool,
|
||||
) (kopia.BackupBases, []data.RestoreCollection, bool, error) {
|
||||
@ -47,7 +48,7 @@ func produceManifestsAndMetadata(
|
||||
bb = bb.MergeBackupBases(
|
||||
ctx,
|
||||
fbb,
|
||||
func(r kopia.Reasoner) string {
|
||||
func(r identity.Reasoner) string {
|
||||
return r.Service().String() + r.Category().String()
|
||||
})
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ import (
|
||||
"github.com/alcionai/corso/src/internal/model"
|
||||
"github.com/alcionai/corso/src/internal/tester"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/fault"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
)
|
||||
@ -47,7 +48,7 @@ type mockBackupFinder struct {
|
||||
|
||||
func (bf *mockBackupFinder) FindBases(
|
||||
_ context.Context,
|
||||
reasons []kopia.Reasoner,
|
||||
reasons []identity.Reasoner,
|
||||
_ map[string]string,
|
||||
) kopia.BackupBases {
|
||||
if len(reasons) == 0 {
|
||||
@ -102,7 +103,7 @@ func (suite *OperationsManifestsUnitSuite) TestCollectMetadata() {
|
||||
table := []struct {
|
||||
name string
|
||||
manID string
|
||||
reasons []kopia.Reasoner
|
||||
reasons []identity.Reasoner
|
||||
fileNames []string
|
||||
expectPaths func(*testing.T, []string) []path.Path
|
||||
expectErr error
|
||||
@ -110,7 +111,7 @@ func (suite *OperationsManifestsUnitSuite) TestCollectMetadata() {
|
||||
{
|
||||
name: "single reason, single file",
|
||||
manID: "single single",
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason(tid, ro, path.ExchangeService, path.EmailCategory),
|
||||
},
|
||||
expectPaths: func(t *testing.T, files []string) []path.Path {
|
||||
@ -129,7 +130,7 @@ func (suite *OperationsManifestsUnitSuite) TestCollectMetadata() {
|
||||
{
|
||||
name: "single reason, multiple files",
|
||||
manID: "single multi",
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason(tid, ro, path.ExchangeService, path.EmailCategory),
|
||||
},
|
||||
expectPaths: func(t *testing.T, files []string) []path.Path {
|
||||
@ -148,7 +149,7 @@ func (suite *OperationsManifestsUnitSuite) TestCollectMetadata() {
|
||||
{
|
||||
name: "multiple reasons, single file",
|
||||
manID: "multi single",
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason(tid, ro, path.ExchangeService, path.EmailCategory),
|
||||
kopia.NewReason(tid, ro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
@ -171,7 +172,7 @@ func (suite *OperationsManifestsUnitSuite) TestCollectMetadata() {
|
||||
{
|
||||
name: "multiple reasons, multiple file",
|
||||
manID: "multi multi",
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason(tid, ro, path.ExchangeService, path.EmailCategory),
|
||||
kopia.NewReason(tid, ro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
@ -219,8 +220,8 @@ func buildReasons(
|
||||
ro string,
|
||||
service path.ServiceType,
|
||||
cats ...path.CategoryType,
|
||||
) []kopia.Reasoner {
|
||||
var reasons []kopia.Reasoner
|
||||
) []identity.Reasoner {
|
||||
var reasons []identity.Reasoner
|
||||
|
||||
for _, cat := range cats {
|
||||
reasons = append(
|
||||
@ -252,7 +253,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
name string
|
||||
bf *mockBackupFinder
|
||||
rp mockRestoreProducer
|
||||
reasons []kopia.Reasoner
|
||||
reasons []identity.Reasoner
|
||||
getMeta bool
|
||||
assertErr assert.ErrorAssertionFunc
|
||||
assertB assert.BoolAssertionFunc
|
||||
@ -263,7 +264,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
{
|
||||
name: "don't get metadata, no mans",
|
||||
rp: mockRestoreProducer{},
|
||||
reasons: []kopia.Reasoner{},
|
||||
reasons: []identity.Reasoner{},
|
||||
getMeta: false,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.False,
|
||||
@ -280,7 +281,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
},
|
||||
},
|
||||
rp: mockRestoreProducer{},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.EmailCategory),
|
||||
},
|
||||
getMeta: false,
|
||||
@ -301,7 +302,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
},
|
||||
},
|
||||
rp: mockRestoreProducer{},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.EmailCategory),
|
||||
},
|
||||
getMeta: true,
|
||||
@ -329,7 +330,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
"id1": {data.NoFetchRestoreCollection{Collection: mockColl{id: "id1"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.EmailCategory),
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
@ -377,7 +378,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
"id2": {data.NoFetchRestoreCollection{Collection: mockColl{id: "id2"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.EmailCategory),
|
||||
},
|
||||
getMeta: true,
|
||||
@ -406,7 +407,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
"id2": {data.NoFetchRestoreCollection{Collection: mockColl{id: "id2"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.EmailCategory),
|
||||
},
|
||||
getMeta: true,
|
||||
@ -428,7 +429,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata() {
|
||||
},
|
||||
},
|
||||
rp: mockRestoreProducer{err: assert.AnError},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.EmailCategory),
|
||||
},
|
||||
getMeta: true,
|
||||
@ -548,8 +549,8 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
name string
|
||||
bf *mockBackupFinder
|
||||
rp mockRestoreProducer
|
||||
reasons []kopia.Reasoner
|
||||
fallbackReasons []kopia.Reasoner
|
||||
reasons []identity.Reasoner
|
||||
fallbackReasons []identity.Reasoner
|
||||
getMeta bool
|
||||
assertErr assert.ErrorAssertionFunc
|
||||
assertB assert.BoolAssertionFunc
|
||||
@ -568,7 +569,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
},
|
||||
},
|
||||
rp: mockRestoreProducer{},
|
||||
fallbackReasons: []kopia.Reasoner{fbEmailReason},
|
||||
fallbackReasons: []identity.Reasoner{fbEmailReason},
|
||||
getMeta: false,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.False,
|
||||
@ -593,7 +594,7 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id1": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id1"}}},
|
||||
},
|
||||
},
|
||||
fallbackReasons: []kopia.Reasoner{fbEmailReason},
|
||||
fallbackReasons: []identity.Reasoner{fbEmailReason},
|
||||
getMeta: true,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.True,
|
||||
@ -624,8 +625,8 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id1": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id1"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{emailReason},
|
||||
fallbackReasons: []kopia.Reasoner{fbEmailReason},
|
||||
reasons: []identity.Reasoner{emailReason},
|
||||
fallbackReasons: []identity.Reasoner{fbEmailReason},
|
||||
getMeta: true,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.True,
|
||||
@ -652,8 +653,8 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id2": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id2"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{emailReason},
|
||||
fallbackReasons: []kopia.Reasoner{fbEmailReason},
|
||||
reasons: []identity.Reasoner{emailReason},
|
||||
fallbackReasons: []identity.Reasoner{fbEmailReason},
|
||||
getMeta: true,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.True,
|
||||
@ -688,8 +689,8 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id2": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id2"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{emailReason},
|
||||
fallbackReasons: []kopia.Reasoner{fbEmailReason},
|
||||
reasons: []identity.Reasoner{emailReason},
|
||||
fallbackReasons: []identity.Reasoner{fbEmailReason},
|
||||
getMeta: true,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.True,
|
||||
@ -720,8 +721,8 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id1": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id1"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{emailReason},
|
||||
fallbackReasons: []kopia.Reasoner{fbEmailReason},
|
||||
reasons: []identity.Reasoner{emailReason},
|
||||
fallbackReasons: []identity.Reasoner{fbEmailReason},
|
||||
getMeta: true,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.True,
|
||||
@ -752,8 +753,8 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id2": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id2"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{emailReason},
|
||||
fallbackReasons: []kopia.Reasoner{fbEmailReason},
|
||||
reasons: []identity.Reasoner{emailReason},
|
||||
fallbackReasons: []identity.Reasoner{fbEmailReason},
|
||||
getMeta: true,
|
||||
assertErr: assert.NoError,
|
||||
assertB: assert.True,
|
||||
@ -782,11 +783,11 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id1": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id1"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
emailReason,
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
fallbackReasons: []kopia.Reasoner{
|
||||
fallbackReasons: []identity.Reasoner{
|
||||
fbEmailReason,
|
||||
kopia.NewReason("", fbro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
@ -818,8 +819,8 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id1": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id1"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{emailReason},
|
||||
fallbackReasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{emailReason},
|
||||
fallbackReasons: []identity.Reasoner{
|
||||
kopia.NewReason("", fbro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
getMeta: true,
|
||||
@ -853,11 +854,11 @@ func (suite *OperationsManifestsUnitSuite) TestProduceManifestsAndMetadata_Fallb
|
||||
"fb_id1": {data.NoFetchRestoreCollection{Collection: mockColl{id: "fb_id1"}}},
|
||||
},
|
||||
},
|
||||
reasons: []kopia.Reasoner{
|
||||
reasons: []identity.Reasoner{
|
||||
emailReason,
|
||||
kopia.NewReason("", ro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
fallbackReasons: []kopia.Reasoner{
|
||||
fallbackReasons: []identity.Reasoner{
|
||||
fbEmailReason,
|
||||
kopia.NewReason("", fbro, path.ExchangeService, path.ContactsCategory),
|
||||
},
|
||||
|
||||
@ -32,6 +32,7 @@ import (
|
||||
"github.com/alcionai/corso/src/pkg/account"
|
||||
"github.com/alcionai/corso/src/pkg/backup"
|
||||
"github.com/alcionai/corso/src/pkg/backup/details"
|
||||
"github.com/alcionai/corso/src/pkg/backup/identity"
|
||||
"github.com/alcionai/corso/src/pkg/control"
|
||||
"github.com/alcionai/corso/src/pkg/control/repository"
|
||||
"github.com/alcionai/corso/src/pkg/count"
|
||||
@ -251,7 +252,7 @@ func checkBackupIsInManifests(
|
||||
bf, err := kw.NewBaseFinder(sw)
|
||||
require.NoError(t, err, clues.ToCore(err))
|
||||
|
||||
mans := bf.FindBases(ctx, []kopia.Reasoner{r}, tags)
|
||||
mans := bf.FindBases(ctx, []identity.Reasoner{r}, tags)
|
||||
for _, man := range mans.MergeBases() {
|
||||
bID, ok := man.GetTag(kopia.TagBackupID)
|
||||
if !assert.Truef(t, ok, "snapshot manifest %s missing backup ID tag", man.ID) {
|
||||
|
||||
16
src/pkg/backup/identity/identity.go
Normal file
16
src/pkg/backup/identity/identity.go
Normal file
@ -0,0 +1,16 @@
|
||||
package identity
|
||||
|
||||
import "github.com/alcionai/corso/src/pkg/path"
|
||||
|
||||
// Reasoner describes the parts of the backup that make up its
|
||||
// data identity: the tenant, protected resources, services, and
|
||||
// categories which are held within the backup.
|
||||
type Reasoner interface {
|
||||
Tenant() string
|
||||
ProtectedResource() string
|
||||
Service() path.ServiceType
|
||||
Category() path.CategoryType
|
||||
// SubtreePath returns the path prefix for data in existing backups that have
|
||||
// parameters (tenant, protected resourced, etc) that match this Reasoner.
|
||||
SubtreePath() (path.Path, error)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user