mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-27 18:34:18 +00:00
@@ -268,12 +268,12 @@ func findPreviousSnapshotManifest(ctx context.Context, rep repo.Repository, sour
|
||||
for _, p := range man {
|
||||
log.Debugf("Found one snapshot %s, start time %v, incomplete %s, tags %v", p.ID, p.StartTime.ToTime(), p.IncompleteReason, p.Tags)
|
||||
|
||||
requestor, found := p.Tags[uploader.SnapshotRequestorTag]
|
||||
requester, found := p.Tags[uploader.SnapshotRequesterTag]
|
||||
if !found {
|
||||
continue
|
||||
}
|
||||
|
||||
if requestor != snapshotTags[uploader.SnapshotRequestorTag] {
|
||||
if requester != snapshotTags[uploader.SnapshotRequesterTag] {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
Path: "/path/to/dir1",
|
||||
}
|
||||
snapshotTags := map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
}
|
||||
noLaterThan := fs.UTCTimestampFromTime(time.Now())
|
||||
@@ -299,7 +299,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value",
|
||||
"anotherCustomTag": "123",
|
||||
@@ -312,7 +312,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
expectedSnapshots: []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value",
|
||||
"anotherCustomTag": "123",
|
||||
@@ -330,7 +330,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value1",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -339,7 +339,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value2",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -351,7 +351,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
expectedSnapshots: []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value1",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -361,14 +361,14 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
},
|
||||
expectedError: nil,
|
||||
},
|
||||
// Snapshot with different requestor
|
||||
// Snapshot with different requester
|
||||
{
|
||||
name: "Snapshot with different requestor",
|
||||
name: "Snapshot with different requester",
|
||||
listSnapshotsFunc: func(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) ([]*snapshot.Manifest, error) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user2",
|
||||
uploader.SnapshotRequesterTag: "user2",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value",
|
||||
"snapshotRequestor": "user2",
|
||||
@@ -387,7 +387,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader2",
|
||||
"otherTag": "value",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -406,7 +406,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -426,7 +426,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -446,7 +446,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value1",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -455,7 +455,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value2",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -466,7 +466,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value3",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -479,7 +479,7 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
expectedSnapshots: []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value3",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -490,14 +490,14 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
},
|
||||
expectedError: nil,
|
||||
},
|
||||
// Snapshot with manifest SnapshotRequestorTag not found
|
||||
// Snapshot with manifest SnapshotRequesterTag not found
|
||||
{
|
||||
name: "Snapshot with manifest SnapshotRequestorTag not found",
|
||||
name: "Snapshot with manifest SnapshotRequesterTag not found",
|
||||
listSnapshotsFunc: func(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) ([]*snapshot.Manifest, error) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
"requestor": "user1",
|
||||
"requester": "user1",
|
||||
uploader.SnapshotUploaderTag: "uploader1",
|
||||
"otherTag": "value",
|
||||
"snapshotRequestor": "user1",
|
||||
@@ -510,14 +510,14 @@ func TestFindPreviousSnapshotManifest(t *testing.T) {
|
||||
expectedSnapshots: []*snapshot.Manifest{},
|
||||
expectedError: nil,
|
||||
},
|
||||
// Snapshot with manifest SnapshotRequestorTag not found
|
||||
// Snapshot with manifest SnapshotRequesterTag not found
|
||||
{
|
||||
name: "Snapshot with manifest SnapshotUploaderTag not found",
|
||||
listSnapshotsFunc: func(ctx context.Context, rep repo.Repository, si snapshot.SourceInfo) ([]*snapshot.Manifest, error) {
|
||||
return []*snapshot.Manifest{
|
||||
{
|
||||
Tags: map[string]string{
|
||||
uploader.SnapshotRequestorTag: "user1",
|
||||
uploader.SnapshotRequesterTag: "user1",
|
||||
"uploader": "uploader1",
|
||||
"otherTag": "value",
|
||||
"snapshotRequestor": "user1",
|
||||
|
||||
@@ -150,7 +150,7 @@ func (kp *kopiaProvider) RunBackup(
|
||||
if tags == nil {
|
||||
tags = make(map[string]string)
|
||||
}
|
||||
tags[uploader.SnapshotRequestorTag] = kp.requestorType
|
||||
tags[uploader.SnapshotRequesterTag] = kp.requestorType
|
||||
tags[uploader.SnapshotUploaderTag] = uploader.KopiaType
|
||||
|
||||
snapshotInfo, isSnapshotEmpty, err := BackupFunc(ctx, kpUploader, repoWriter, path, realSource, forceFull, parentSnapshot, tags, log)
|
||||
|
||||
@@ -65,7 +65,7 @@ func NewUploaderProvider(
|
||||
ctx context.Context,
|
||||
client client.Client,
|
||||
uploaderType string,
|
||||
requestorType string,
|
||||
requesterType string,
|
||||
repoIdentifier string,
|
||||
bsl *velerov1api.BackupStorageLocation,
|
||||
backupRepo *velerov1api.BackupRepository,
|
||||
@@ -73,15 +73,15 @@ func NewUploaderProvider(
|
||||
repoKeySelector *v1.SecretKeySelector,
|
||||
log logrus.FieldLogger,
|
||||
) (Provider, error) {
|
||||
if requestorType == "" {
|
||||
return nil, errors.New("requestor type is empty")
|
||||
if requesterType == "" {
|
||||
return nil, errors.New("requester type is empty")
|
||||
}
|
||||
|
||||
if credGetter.FromFile == nil {
|
||||
return nil, errors.New("uninitialized FileStore credentail is not supported")
|
||||
return nil, errors.New("uninitialized FileStore credential is not supported")
|
||||
}
|
||||
if uploaderType == uploader.KopiaType {
|
||||
return NewKopiaUploaderProvider(requestorType, ctx, credGetter, backupRepo, log)
|
||||
return NewKopiaUploaderProvider(requesterType, ctx, credGetter, backupRepo, log)
|
||||
} else {
|
||||
return NewResticUploaderProvider(repoIdentifier, bsl, credGetter, repoKeySelector, log)
|
||||
}
|
||||
|
||||
@@ -55,25 +55,25 @@ func TestNewUploaderProvider(t *testing.T) {
|
||||
Description: "When requestorType is empty, it should return an error",
|
||||
UploaderType: "kopia",
|
||||
RequestorType: "",
|
||||
ExpectedError: "requestor type is empty",
|
||||
ExpectedError: "requester type is empty",
|
||||
},
|
||||
{
|
||||
Description: "When FileStore credential is uninitialized, it should return an error",
|
||||
UploaderType: "kopia",
|
||||
RequestorType: "requestor",
|
||||
ExpectedError: "uninitialized FileStore credentail",
|
||||
RequestorType: "requester",
|
||||
ExpectedError: "uninitialized FileStore credential",
|
||||
},
|
||||
{
|
||||
Description: "When uploaderType is kopia, it should return a KopiaUploaderProvider",
|
||||
UploaderType: "kopia",
|
||||
RequestorType: "requestor",
|
||||
RequestorType: "requester",
|
||||
needFromFile: true,
|
||||
ExpectedError: "invalid credentials interface",
|
||||
},
|
||||
{
|
||||
Description: "When uploaderType is not kopia, it should return a ResticUploaderProvider",
|
||||
UploaderType: "restic",
|
||||
RequestorType: "requestor",
|
||||
RequestorType: "requester",
|
||||
needFromFile: true,
|
||||
ExpectedError: "",
|
||||
},
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
const (
|
||||
ResticType = "restic"
|
||||
KopiaType = "kopia"
|
||||
SnapshotRequestorTag = "snapshot-requestor"
|
||||
SnapshotRequesterTag = "snapshot-requester"
|
||||
SnapshotUploaderTag = "snapshot-uploader"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user