diff options
Diffstat (limited to 'internal/helper/storage.go')
-rw-r--r-- | internal/helper/storage.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/helper/storage.go b/internal/helper/storage.go index 83341b0c4..4e535a5d6 100644 --- a/internal/helper/storage.go +++ b/internal/helper/storage.go @@ -33,3 +33,21 @@ func ExtractGitalyServers(ctx context.Context) (gitalyServersInfo storage.Gitaly return } + +// InjectGitalyServers injects gitaly-servers metadata into an outgoing context +func InjectGitalyServers(ctx context.Context, name, address, token string) (context.Context, error) { + + gitalyServers := storage.GitalyServers{ + name: { + "address": address, + "token": token, + }, + } + + gitalyServersJSON, err := json.Marshal(gitalyServers) + if err != nil { + return nil, err + } + + return metadata.NewOutgoingContext(ctx, metadata.Pairs("gitaly-servers", base64.StdEncoding.EncodeToString(gitalyServersJSON))), nil +} |