diff options
author | James Fargher <jfargher@gitlab.com> | 2023-02-15 07:07:36 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2023-02-15 22:20:46 +0300 |
commit | 9f819695070bce6fd0f410af1182697ec35a58c1 (patch) | |
tree | d4835827c9ab51f4862d9fc0bb7d2ce1624c556d /cmd | |
parent | 01930dff6714cd9b904163a50658609c9ad24d75 (diff) |
storage: Extract InjectGitalyServersEnv into storage package
Colocates this function with other functions that manipulate this value
on context.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly-backup/main.go | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/cmd/gitaly-backup/main.go b/cmd/gitaly-backup/main.go index 97334021f..eed6a6d63 100644 --- a/cmd/gitaly-backup/main.go +++ b/cmd/gitaly-backup/main.go @@ -3,14 +3,11 @@ package main import ( "context" "flag" - "fmt" "io" "os" "gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/storage" - "gitlab.com/gitlab-org/gitaly/v15/internal/helper/env" "gitlab.com/gitlab-org/gitaly/v15/internal/log" - "google.golang.org/grpc/metadata" ) type subcmd interface { @@ -45,7 +42,7 @@ func main() { subcmd.Flags(subcmdFlags) _ = subcmdFlags.Parse(flags.Args()[2:]) - ctx, err := injectGitalyServersEnv(context.Background()) + ctx, err := storage.InjectGitalyServersEnv(context.Background()) if err != nil { logger.Fatalf("%s", err) } @@ -54,20 +51,3 @@ func main() { logger.Fatalf("%s", err) } } - -func injectGitalyServersEnv(ctx context.Context) (context.Context, error) { - rawServers := env.GetString("GITALY_SERVERS", "") - if rawServers == "" { - return ctx, nil - } - - md := metadata.Pairs("gitaly-servers", rawServers) - ctx = metadata.NewIncomingContext(ctx, md) - - // Make sure we fail early if the value in the env var cannot be interpreted. - if _, err := storage.ExtractGitalyServers(ctx); err != nil { - return nil, fmt.Errorf("injecting GITALY_SERVERS: %w", err) - } - - return ctx, nil -} |