diff options
author | James Fargher <jfargher@gitlab.com> | 2023-09-20 03:06:24 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2023-09-20 07:01:39 +0300 |
commit | 6a3734052c73ec7727450751edebb41e65a98c8c (patch) | |
tree | 585904ccc1ded16a93e534740d8bdcc9a7411979 | |
parent | 826816f50075a43c3ee5e98b57324b3827ef0f86 (diff) |
backup: Write backup manifest filesbackup_manifests
Changelog: changed
-rw-r--r-- | internal/backup/backup.go | 17 | ||||
-rw-r--r-- | internal/backup/backup_test.go | 7 |
2 files changed, 19 insertions, 5 deletions
diff --git a/internal/backup/backup.go b/internal/backup/backup.go index 05e0b14ee..a2b38fc58 100644 --- a/internal/backup/backup.go +++ b/internal/backup/backup.go @@ -107,18 +107,25 @@ type Repository interface { // ResolveLocator returns a locator implementation based on a locator identifier. func ResolveLocator(layout string, sink Sink) (Locator, error) { - legacy := LegacyLocator{} + var locator Locator = LegacyLocator{} + switch layout { case "legacy": - return legacy, nil case "pointer": - return PointerLocator{ + locator = PointerLocator{ Sink: sink, - Fallback: legacy, - }, nil + Fallback: locator, + } default: return nil, fmt.Errorf("unknown layout: %q", layout) } + + locator = ManifestLocator{ + Sink: sink, + Fallback: locator, + } + + return locator, nil } // Manager manages process of the creating/restoring backups. diff --git a/internal/backup/backup_test.go b/internal/backup/backup_test.go index ac7b155c0..9b84cec55 100644 --- a/internal/backup/backup_test.go +++ b/internal/backup/backup_test.go @@ -173,6 +173,7 @@ func TestManager_Create(t *testing.T) { StorageName: "some_storage", } + manifestPath := filepath.Join(backupRoot, "manifests", vanityRepo.StorageName, vanityRepo.RelativePath, backupID+".toml") refsPath := joinBackupPath(t, backupRoot, vanityRepo, backupID, "001.refs") bundlePath := joinBackupPath(t, backupRoot, vanityRepo, backupID, "001.bundle") customHooksPath := joinBackupPath(t, backupRoot, vanityRepo, backupID, "001.custom_hooks.tar") @@ -224,6 +225,12 @@ func TestManager_Create(t *testing.T) { require.NoFileExists(t, refsPath) } + if tc.createsBundle || tc.createsRefList { + require.FileExists(t, manifestPath) + } else { + require.NoFileExists(t, manifestPath) + } + if tc.createsCustomHooks { require.FileExists(t, customHooksPath) } else { |