diff options
author | James Fargher <jfargher@gitlab.com> | 2021-08-24 01:23:48 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2021-08-30 04:00:31 +0300 |
commit | acf891806c3aae663d4506cfab80b8f12c846de3 (patch) | |
tree | ae6cbc6d54925ab3764203c3680f8a9896f48b1c /cmd | |
parent | 69923a3ae4e9b03913c899c5d6fefed3d833047d (diff) |
Allow selecting locator strategy from commandline
This allows testing of new locator strategies without breaking any
existing backups.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly-backup/create.go | 9 | ||||
-rw-r--r-- | cmd/gitaly-backup/restore.go | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/cmd/gitaly-backup/create.go b/cmd/gitaly-backup/create.go index 9559099bb..12f087838 100644 --- a/cmd/gitaly-backup/create.go +++ b/cmd/gitaly-backup/create.go @@ -25,12 +25,14 @@ type createSubcommand struct { backupPath string parallel int parallelStorage int + locator string } func (cmd *createSubcommand) Flags(fs *flag.FlagSet) { fs.StringVar(&cmd.backupPath, "path", "", "repository backup path") fs.IntVar(&cmd.parallel, "parallel", runtime.NumCPU(), "maximum number of parallel backups") fs.IntVar(&cmd.parallelStorage, "parallel-storage", 2, "maximum number of parallel backups per storage. Note: actual parallelism when combined with `-parallel` depends on the order the repositories are received.") + fs.StringVar(&cmd.locator, "locator", "legacy", "determines how backup files are located. One of legacy, pointer. Note: The feature is not ready for production use.") } func (cmd *createSubcommand) Run(ctx context.Context, stdin io.Reader, stdout io.Writer) error { @@ -39,7 +41,12 @@ func (cmd *createSubcommand) Run(ctx context.Context, stdin io.Reader, stdout io return fmt.Errorf("create: resolve sink: %w", err) } - manager := backup.NewManager(sink) + locator, err := backup.ResolveLocator(cmd.locator, sink) + if err != nil { + return fmt.Errorf("create: resolve locator: %w", err) + } + + manager := backup.NewManager(sink, locator) var pipeline backup.CreatePipeline pipeline = backup.NewPipeline(log.StandardLogger(), manager) diff --git a/cmd/gitaly-backup/restore.go b/cmd/gitaly-backup/restore.go index 98fe58773..d5304cbd7 100644 --- a/cmd/gitaly-backup/restore.go +++ b/cmd/gitaly-backup/restore.go @@ -24,10 +24,12 @@ type restoreRequest struct { type restoreSubcommand struct { backupPath string + locator string } func (cmd *restoreSubcommand) Flags(fs *flag.FlagSet) { fs.StringVar(&cmd.backupPath, "path", "", "repository backup path") + fs.StringVar(&cmd.locator, "locator", "legacy", "determines how backup files are located. One of legacy, pointer. Note: The feature is not ready for production use.") } func (cmd *restoreSubcommand) Run(ctx context.Context, stdin io.Reader, stdout io.Writer) error { @@ -36,7 +38,12 @@ func (cmd *restoreSubcommand) Run(ctx context.Context, stdin io.Reader, stdout i return fmt.Errorf("restore: resolve sink: %w", err) } - manager := backup.NewManager(sink) + locator, err := backup.ResolveLocator(cmd.locator, sink) + if err != nil { + return fmt.Errorf("restore: resolve locator: %w", err) + } + + manager := backup.NewManager(sink, locator) pipeline := backup.NewPipeline(log.StandardLogger(), manager) decoder := json.NewDecoder(stdin) |