diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-11-25 11:22:04 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-12-03 11:15:11 +0300 |
commit | 5f26864076c1e609d7babd2a92d67accd69a4def (patch) | |
tree | 1acd304aa57f3ab0de4e656fa9dfd438cff27f4c /cmd | |
parent | 191ad3314c72fc2a20bbf5f9715c61766f441ec9 (diff) |
featureflag: Consolidate feature flags context API
Consolidate the feature flags context APIs such that we have the same
set of functions for creating feature flags in incoming and outgoing
contexts.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly-hooks/hooks_test.go | 4 | ||||
-rw-r--r-- | cmd/gitaly-ssh/main.go | 9 | ||||
-rw-r--r-- | cmd/praefect/subcmd_track_repository_test.go | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go index 20e3ef44b..856730900 100644 --- a/cmd/gitaly-hooks/hooks_test.go +++ b/cmd/gitaly-hooks/hooks_test.go @@ -51,8 +51,8 @@ var ( ) func rawFeatureFlags(ctx context.Context) featureflag.Raw { - ctx = featureflag.IncomingCtxWithFeatureFlag(ctx, enabledFeatureFlag) - ctx = featureflag.IncomingCtxWithDisabledFeatureFlag(ctx, disabledFeatureFlag) + ctx = featureflag.IncomingCtxWithFeatureFlag(ctx, enabledFeatureFlag, true) + ctx = featureflag.IncomingCtxWithFeatureFlag(ctx, disabledFeatureFlag, false) return featureflag.RawFromContext(ctx) } diff --git a/cmd/gitaly-ssh/main.go b/cmd/gitaly-ssh/main.go index c5a7e561f..b7a4f51dd 100644 --- a/cmd/gitaly-ssh/main.go +++ b/cmd/gitaly-ssh/main.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "strconv" "strings" gitalyauth "gitlab.com/gitlab-org/gitaly/v14/auth" @@ -87,7 +88,13 @@ func (cmd gitalySSHCommand) run() (int, error) { if len(flagPairSplit) != 2 { continue } - ctx = featureflag.OutgoingCtxWithFeatureFlagValue(ctx, featureflag.FeatureFlag{Name: flagPairSplit[0]}, flagPairSplit[1]) + + enabled, err := strconv.ParseBool(flagPairSplit[1]) + if err != nil { + continue + } + + ctx = featureflag.OutgoingCtxWithFeatureFlag(ctx, featureflag.FeatureFlag{Name: flagPairSplit[0]}, enabled) } } diff --git a/cmd/praefect/subcmd_track_repository_test.go b/cmd/praefect/subcmd_track_repository_test.go index b0cc9e673..5f410d5f3 100644 --- a/cmd/praefect/subcmd_track_repository_test.go +++ b/cmd/praefect/subcmd_track_repository_test.go @@ -109,7 +109,7 @@ func TestAddRepository_Exec(t *testing.T) { ctx, cancel := testhelper.Context() defer cancel() - ctx = featureflag.OutgoingCtxWithFeatureFlagValue(ctx, featureflag.TxAtomicRepositoryCreation, "true") + ctx = featureflag.OutgoingCtxWithFeatureFlag(ctx, featureflag.TxAtomicRepositoryCreation, true) gitaly1RepositoryClient := gitalypb.NewRepositoryServiceClient(gitalyCC) |