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