Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Fargher <jfargher@gitlab.com>2021-10-11 06:04:53 +0300
committerJames Fargher <jfargher@gitlab.com>2021-10-18 03:27:57 +0300
commitc6b9c28d8d2aa2378ffb4f515d60dbead054c642 (patch)
tree2bfbbf1d2bfebf3f62be05b7640918ca5db710ec /internal
parenta7806265151e4156549800619a4f83fc455d9dd2 (diff)
backup: Allow creating an incremental backup from the create command
Now that incremental backups can be created, we add the boilerplate in order to expose this to the commandline.
Diffstat (limited to 'internal')
-rw-r--r--internal/backup/pipeline.go21
-rw-r--r--internal/backup/pipeline_test.go12
2 files changed, 18 insertions, 15 deletions
diff --git a/internal/backup/pipeline.go b/internal/backup/pipeline.go
index 6aa43aee6..926c8397e 100644
--- a/internal/backup/pipeline.go
+++ b/internal/backup/pipeline.go
@@ -34,17 +34,19 @@ type Pipeline interface {
// CreateCommand creates a backup for a repository
type CreateCommand struct {
- strategy Strategy
- server storage.ServerInfo
- repository *gitalypb.Repository
+ strategy Strategy
+ server storage.ServerInfo
+ repository *gitalypb.Repository
+ incremental bool
}
// NewCreateCommand builds a CreateCommand
-func NewCreateCommand(strategy Strategy, server storage.ServerInfo, repo *gitalypb.Repository) *CreateCommand {
+func NewCreateCommand(strategy Strategy, server storage.ServerInfo, repo *gitalypb.Repository, incremental bool) *CreateCommand {
return &CreateCommand{
- strategy: strategy,
- server: server,
- repository: repo,
+ strategy: strategy,
+ server: server,
+ repository: repo,
+ incremental: incremental,
}
}
@@ -61,8 +63,9 @@ func (cmd CreateCommand) Name() string {
// Execute performs the backup
func (cmd CreateCommand) Execute(ctx context.Context) error {
return cmd.strategy.Create(ctx, &CreateRequest{
- Server: cmd.server,
- Repository: cmd.repository,
+ Server: cmd.server,
+ Repository: cmd.repository,
+ Incremental: cmd.incremental,
})
}
diff --git a/internal/backup/pipeline_test.go b/internal/backup/pipeline_test.go
index 99112b544..73021d767 100644
--- a/internal/backup/pipeline_test.go
+++ b/internal/backup/pipeline_test.go
@@ -69,8 +69,8 @@ func TestParallelPipeline(t *testing.T) {
defer cancel()
for i := 0; i < 10; i++ {
- p.Handle(ctx, NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "storage1"}))
- p.Handle(ctx, NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "storage2"}))
+ p.Handle(ctx, NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "storage1"}, false))
+ p.Handle(ctx, NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "storage2"}, false))
}
require.NoError(t, p.Done())
})
@@ -88,7 +88,7 @@ func TestParallelPipeline(t *testing.T) {
cancel()
<-ctx.Done()
- p.Handle(ctx, NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "default"}))
+ p.Handle(ctx, NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "default"}, false))
err := p.Done()
require.EqualError(t, err, "pipeline: context canceled")
@@ -136,9 +136,9 @@ func testPipeline(t *testing.T, init func() Pipeline) {
defer cancel()
commands := []Command{
- NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "normal"}),
- NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "skip"}),
- NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "error"}),
+ NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "normal"}, false),
+ NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "skip"}, false),
+ NewCreateCommand(strategy, storage.ServerInfo{}, &gitalypb.Repository{StorageName: "error"}, false),
}
for _, cmd := range commands {
p.Handle(ctx, cmd)