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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-06-30 14:25:12 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-06 09:14:56 +0300
commitbe54a19d04d6a091b77ddba09267afa9b7a7597b (patch)
treee8ba6d744dcdf3d856ff412c1bae79ce25b25baf
parentf00ed2d000b6d92dd54b18dcec09ab7976497634 (diff)
hooks: Convert payload to use actual feature flags
We're currently injecting raw feature flags into the hooks payload so that these flags can be set in the outgoing context that's used to connect back to Gitaly again. We're reducing the use of raw feature flags though in favor of using the typed `FeatureFlag` structure. Convert the hooks payload to instead inject `FeatureFlag`s directly with their respective value so that we can get rid of raw feature flags. This is technically-seen a breaking change because any old server that is running would still inject the old set of feature flags which the new binary doesn't understand anymore. As a consequence, it wouldn't use any feature flags at all. This is fine though: none of our hook RPCs is using feature flags right now, so this doesn't change anything.
-rw-r--r--cmd/gitaly-hooks/hooks.go5
-rw-r--r--cmd/gitaly-hooks/hooks_test.go8
-rw-r--r--internal/git/hooks_options.go2
-rw-r--r--internal/git/hooks_payload.go41
-rw-r--r--internal/git/hooks_payload_test.go11
-rw-r--r--internal/git/updateref/update_with_hooks.go4
-rw-r--r--internal/git/updateref/update_with_hooks_test.go33
-rw-r--r--internal/gitaly/hook/postreceive_test.go8
-rw-r--r--internal/gitaly/hook/prereceive_test.go8
-rw-r--r--internal/gitaly/hook/transactions_test.go2
-rw-r--r--internal/gitaly/hook/update_test.go8
-rw-r--r--internal/gitaly/service/hook/post_receive_test.go4
-rw-r--r--internal/gitaly/service/hook/pre_receive_test.go8
-rw-r--r--internal/gitaly/service/hook/reference_transaction_test.go2
-rw-r--r--internal/gitaly/service/hook/update_test.go2
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go13
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go12
17 files changed, 112 insertions, 59 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go
index 35248e143..95bca501e 100644
--- a/cmd/gitaly-hooks/hooks.go
+++ b/cmd/gitaly-hooks/hooks.go
@@ -161,7 +161,10 @@ func executeHook(cmd hookCommand, args []string) error {
hookClient := gitalypb.NewHookServiceClient(conn)
- ctx = featureflag.OutgoingWithRaw(ctx, payload.FeatureFlags)
+ for _, flag := range payload.FeatureFlagsWithValue {
+ ctx = featureflag.OutgoingCtxWithFeatureFlag(ctx, flag.Flag, flag.Enabled)
+ }
+
if err := cmd.exec(ctx, payload, hookClient, args); err != nil {
return err
}
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index 9db2ea23f..7e3f6d8ed 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -50,10 +50,10 @@ var (
disabledFeatureFlag = featureflag.FeatureFlag{Name: "disabled-feature-flag", OnByDefault: true}
)
-func rawFeatureFlags(ctx context.Context) featureflag.Raw {
+func featureFlags(ctx context.Context) map[featureflag.FeatureFlag]bool {
ctx = featureflag.IncomingCtxWithFeatureFlag(ctx, enabledFeatureFlag, true)
ctx = featureflag.IncomingCtxWithFeatureFlag(ctx, disabledFeatureFlag, false)
- return featureflag.RawFromContext(ctx)
+ return featureflag.FromContext(ctx)
}
// envForHooks generates a set of environment variables for gitaly hooks
@@ -62,7 +62,7 @@ func envForHooks(t testing.TB, ctx context.Context, cfg config.Cfg, repo *gitaly
UserID: glHookValues.GLID,
Username: glHookValues.GLUsername,
Protocol: glHookValues.GLProtocol,
- }, git.AllHooks, rawFeatureFlags(ctx)).Env()
+ }, git.AllHooks, featureFlags(ctx)).Env()
require.NoError(t, err)
env := append(command.AllowedEnvironment(os.Environ()), []string{
@@ -413,7 +413,7 @@ func TestHooksPostReceiveFailed(t *testing.T) {
Protocol: glProtocol,
},
git.PostReceiveHook,
- rawFeatureFlags(ctx),
+ featureFlags(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/git/hooks_options.go b/internal/git/hooks_options.go
index 5a24f8a9d..9a77a2ce8 100644
--- a/internal/git/hooks_options.go
+++ b/internal/git/hooks_options.go
@@ -115,7 +115,7 @@ func (cc *cmdCfg) configureHooks(
transaction,
userDetails,
requestedHooks,
- featureflag.RawFromContext(ctx)).Env()
+ featureflag.FromContext(ctx)).Env()
if err != nil {
return err
}
diff --git a/internal/git/hooks_payload.go b/internal/git/hooks_payload.go
index f0185d495..918164f79 100644
--- a/internal/git/hooks_payload.go
+++ b/internal/git/hooks_payload.go
@@ -47,14 +47,23 @@ const (
ReceivePackHooks = ReferenceTransactionHook | UpdateHook | PreReceiveHook | PostReceiveHook
)
+// FeatureFlagWithValue is used as part of the HooksPayload to pass on feature flags with their
+// values to gitaly-hooks.
+type FeatureFlagWithValue struct {
+ // Flag is the feature flag.
+ Flag featureflag.FeatureFlag `json:"flag"`
+ // Enabled indicates whether the flag is enabled or not.
+ Enabled bool `json:"enabled"`
+}
+
// HooksPayload holds parameters required for all hooks.
type HooksPayload struct {
// RequestedHooks is a bitfield of requested Hooks. Hooks which
// were not requested will not get executed.
RequestedHooks Hook `json:"requested_hooks"`
- // FeatureFlags contains feature flags with their values. They are set
- // into the outgoing context when calling HookService.
- FeatureFlags featureflag.Raw `json:"feature_flags,omitempty"`
+ // FeatureFlagsWithValue contains feature flags with their values. They are set into the
+ // outgoing context when calling HookService.
+ FeatureFlagsWithValue []FeatureFlagWithValue `json:"feature_flags_with_value,omitempty"`
// Repo is the repository in which the hook is running.
Repo *gitalypb.Repository `json:"-"`
@@ -110,17 +119,25 @@ func NewHooksPayload(
tx *txinfo.Transaction,
userDetails *UserDetails,
requestedHooks Hook,
- featureFlags featureflag.Raw,
+ featureFlagsWithValue map[featureflag.FeatureFlag]bool,
) HooksPayload {
+ flags := make([]FeatureFlagWithValue, 0, len(featureFlagsWithValue))
+ for flag, enabled := range featureFlagsWithValue {
+ flags = append(flags, FeatureFlagWithValue{
+ Flag: flag,
+ Enabled: enabled,
+ })
+ }
+
return HooksPayload{
- Repo: repo,
- RuntimeDir: cfg.RuntimeDir,
- InternalSocket: cfg.InternalSocketPath(),
- InternalSocketToken: cfg.Auth.Token,
- Transaction: tx,
- UserDetails: userDetails,
- RequestedHooks: requestedHooks,
- FeatureFlags: featureFlags,
+ Repo: repo,
+ RuntimeDir: cfg.RuntimeDir,
+ InternalSocket: cfg.InternalSocketPath(),
+ InternalSocketToken: cfg.Auth.Token,
+ Transaction: tx,
+ UserDetails: userDetails,
+ RequestedHooks: requestedHooks,
+ FeatureFlagsWithValue: flags,
}
}
diff --git a/internal/git/hooks_payload_test.go b/internal/git/hooks_payload_test.go
index b6220d656..361e68a7f 100644
--- a/internal/git/hooks_payload_test.go
+++ b/internal/git/hooks_payload_test.go
@@ -27,7 +27,9 @@ func TestHooksPayload(t *testing.T) {
})
t.Run("roundtrip succeeds", func(t *testing.T) {
- env, err := git.NewHooksPayload(cfg, repo, nil, nil, git.PreReceiveHook, featureflag.Raw{"flag-key": "flag-value"}).Env()
+ env, err := git.NewHooksPayload(cfg, repo, nil, nil, git.PreReceiveHook, map[featureflag.FeatureFlag]bool{
+ {Name: "flag_key"}: true,
+ }).Env()
require.NoError(t, err)
payload, err := git.HooksPayloadFromEnv([]string{
@@ -43,7 +45,12 @@ func TestHooksPayload(t *testing.T) {
RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.InternalSocketPath(),
RequestedHooks: git.PreReceiveHook,
- FeatureFlags: featureflag.Raw{"flag-key": "flag-value"},
+ FeatureFlagsWithValue: []git.FeatureFlagWithValue{
+ {
+ Flag: featureflag.FeatureFlag{Name: "flag_key"},
+ Enabled: true,
+ },
+ },
}, payload)
})
diff --git a/internal/git/updateref/update_with_hooks.go b/internal/git/updateref/update_with_hooks.go
index de4c7cb92..fbd615be4 100644
--- a/internal/git/updateref/update_with_hooks.go
+++ b/internal/git/updateref/update_with_hooks.go
@@ -188,7 +188,7 @@ func (u *UpdaterWithHooks) UpdateReference(
quarantinedRepo = quarantineDir.QuarantinedRepo()
}
- hooksPayload, err := git.NewHooksPayload(u.cfg, quarantinedRepo, transaction, &receiveHooksPayload, git.ReceivePackHooks, featureflag.RawFromContext(ctx)).Env()
+ hooksPayload, err := git.NewHooksPayload(u.cfg, quarantinedRepo, transaction, &receiveHooksPayload, git.ReceivePackHooks, featureflag.FromContext(ctx)).Env()
if err != nil {
return err
}
@@ -210,7 +210,7 @@ func (u *UpdaterWithHooks) UpdateReference(
// We only need to update the hooks payload to the unquarantined repo in case we
// had a quarantine environment. Otherwise, the initial hooks payload is for the
// real repository anyway.
- hooksPayload, err = git.NewHooksPayload(u.cfg, repo, transaction, &receiveHooksPayload, git.ReceivePackHooks, featureflag.RawFromContext(ctx)).Env()
+ hooksPayload, err = git.NewHooksPayload(u.cfg, repo, transaction, &receiveHooksPayload, git.ReceivePackHooks, featureflag.FromContext(ctx)).Env()
if err != nil {
return err
}
diff --git a/internal/git/updateref/update_with_hooks_test.go b/internal/git/updateref/update_with_hooks_test.go
index fa02c5069..cf2464a58 100644
--- a/internal/git/updateref/update_with_hooks_test.go
+++ b/internal/git/updateref/update_with_hooks_test.go
@@ -110,15 +110,24 @@ func TestUpdaterWithHooks_UpdateReference(t *testing.T) {
oldRev := "1e292f8fedd741b75372e19097c76d327140c312"
- payload, err := git.NewHooksPayload(cfg, repo, nil, &git.UserDetails{
- UserID: "1234",
- Username: "Username",
- Protocol: "web",
- }, git.ReceivePackHooks, featureflag.RawFromContext(ctx)).Env()
- require.NoError(t, err)
+ requirePayload := func(t *testing.T, env []string) {
+ require.Len(t, env, 1)
+
+ expectedPayload := git.NewHooksPayload(cfg, repo, nil, &git.UserDetails{
+ UserID: "1234",
+ Username: "Username",
+ Protocol: "web",
+ }, git.ReceivePackHooks, featureflag.FromContext(ctx))
+
+ actualPayload, err := git.HooksPayloadFromEnv(env)
+ require.NoError(t, err)
+
+ // Flags aren't sorted, so we just verify they contain the same elements.
+ require.ElementsMatch(t, expectedPayload.FeatureFlagsWithValue, actualPayload.FeatureFlagsWithValue)
+ expectedPayload.FeatureFlagsWithValue = nil
+ actualPayload.FeatureFlagsWithValue = nil
- expectedEnv := []string{
- payload,
+ require.Equal(t, expectedPayload, actualPayload)
}
referenceTransactionCalls := 0
@@ -138,21 +147,21 @@ func TestUpdaterWithHooks_UpdateReference(t *testing.T) {
require.NoError(t, err)
require.Equal(t, fmt.Sprintf("%s %s refs/heads/master\n", oldRev, git.ZeroOID.String()), string(changes))
require.Empty(t, pushOptions)
- require.Equal(t, env, expectedEnv)
+ requirePayload(t, env)
return nil
},
update: func(t *testing.T, ctx context.Context, repo *gitalypb.Repository, ref, oldValue, newValue string, env []string, stdout, stderr io.Writer) error {
require.Equal(t, "refs/heads/master", ref)
require.Equal(t, oldRev, oldValue)
require.Equal(t, newValue, git.ZeroOID.String())
- require.Equal(t, env, expectedEnv)
+ requirePayload(t, env)
return nil
},
postReceive: func(t *testing.T, ctx context.Context, repo *gitalypb.Repository, pushOptions, env []string, stdin io.Reader, stdout, stderr io.Writer) error {
changes, err := io.ReadAll(stdin)
require.NoError(t, err)
require.Equal(t, fmt.Sprintf("%s %s refs/heads/master\n", oldRev, git.ZeroOID.String()), string(changes))
- require.Equal(t, env, expectedEnv)
+ requirePayload(t, env)
require.Empty(t, pushOptions)
return nil
},
@@ -169,7 +178,7 @@ func TestUpdaterWithHooks_UpdateReference(t *testing.T) {
}
referenceTransactionCalls++
- require.Equal(t, env, expectedEnv)
+ requirePayload(t, env)
return nil
},
expectedRefDeletion: true,
diff --git a/internal/gitaly/hook/postreceive_test.go b/internal/gitaly/hook/postreceive_test.go
index d8afe3ff5..f78265d9f 100644
--- a/internal/gitaly/hook/postreceive_test.go
+++ b/internal/gitaly/hook/postreceive_test.go
@@ -83,7 +83,7 @@ func TestPostReceive_customHook(t *testing.T) {
ctx := testhelper.Context(t)
- payload, err := git.NewHooksPayload(cfg, repo, nil, receiveHooksPayload, git.PostReceiveHook, featureflag.RawFromContext(ctx)).Env()
+ payload, err := git.NewHooksPayload(cfg, repo, nil, receiveHooksPayload, git.PostReceiveHook, featureflag.FromContext(ctx)).Env()
require.NoError(t, err)
primaryPayload, err := git.NewHooksPayload(
@@ -94,7 +94,7 @@ func TestPostReceive_customHook(t *testing.T) {
},
receiveHooksPayload,
git.PostReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -106,7 +106,7 @@ func TestPostReceive_customHook(t *testing.T) {
},
receiveHooksPayload,
git.PostReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -387,7 +387,7 @@ func TestPostReceive_quarantine(t *testing.T) {
Protocol: "web",
},
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/hook/prereceive_test.go b/internal/gitaly/hook/prereceive_test.go
index 12dc504bd..7dfc05cee 100644
--- a/internal/gitaly/hook/prereceive_test.go
+++ b/internal/gitaly/hook/prereceive_test.go
@@ -42,7 +42,7 @@ func TestPrereceive_customHooks(t *testing.T) {
ctx := testhelper.Context(t)
- payload, err := git.NewHooksPayload(cfg, repo, nil, receiveHooksPayload, git.PreReceiveHook, featureflag.RawFromContext(ctx)).Env()
+ payload, err := git.NewHooksPayload(cfg, repo, nil, receiveHooksPayload, git.PreReceiveHook, featureflag.FromContext(ctx)).Env()
require.NoError(t, err)
primaryPayload, err := git.NewHooksPayload(
@@ -53,7 +53,7 @@ func TestPrereceive_customHooks(t *testing.T) {
},
receiveHooksPayload,
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -65,7 +65,7 @@ func TestPrereceive_customHooks(t *testing.T) {
},
receiveHooksPayload,
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -206,7 +206,7 @@ func TestPrereceive_quarantine(t *testing.T) {
Protocol: "web",
},
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/hook/transactions_test.go b/internal/gitaly/hook/transactions_test.go
index 5c485983f..727485fd9 100644
--- a/internal/gitaly/hook/transactions_test.go
+++ b/internal/gitaly/hook/transactions_test.go
@@ -45,7 +45,7 @@ func TestHookManager_stopCalled(t *testing.T) {
Protocol: "web",
},
git.ReferenceTransactionHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/hook/update_test.go b/internal/gitaly/hook/update_test.go
index 464340861..326f2dca1 100644
--- a/internal/gitaly/hook/update_test.go
+++ b/internal/gitaly/hook/update_test.go
@@ -39,7 +39,7 @@ func TestUpdate_customHooks(t *testing.T) {
ctx := testhelper.Context(t)
- payload, err := git.NewHooksPayload(cfg, repo, nil, receiveHooksPayload, git.UpdateHook, featureflag.RawFromContext(ctx)).Env()
+ payload, err := git.NewHooksPayload(cfg, repo, nil, receiveHooksPayload, git.UpdateHook, featureflag.FromContext(ctx)).Env()
require.NoError(t, err)
primaryPayload, err := git.NewHooksPayload(
@@ -50,7 +50,7 @@ func TestUpdate_customHooks(t *testing.T) {
},
receiveHooksPayload,
git.UpdateHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -62,7 +62,7 @@ func TestUpdate_customHooks(t *testing.T) {
},
receiveHooksPayload,
git.UpdateHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -237,7 +237,7 @@ func TestUpdate_quarantine(t *testing.T) {
Protocol: "web",
},
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/service/hook/post_receive_test.go b/internal/gitaly/service/hook/post_receive_test.go
index 39b0aeb27..96b3d221f 100644
--- a/internal/gitaly/service/hook/post_receive_test.go
+++ b/internal/gitaly/service/hook/post_receive_test.go
@@ -109,7 +109,7 @@ func TestHooksMissingStdin(t *testing.T) {
Protocol: "protocol",
},
git.PostReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -237,7 +237,7 @@ To create a merge request for okay, visit:
Protocol: "protocol",
},
git.PostReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/service/hook/pre_receive_test.go b/internal/gitaly/service/hook/pre_receive_test.go
index 34175bb46..12fed62be 100644
--- a/internal/gitaly/service/hook/pre_receive_test.go
+++ b/internal/gitaly/service/hook/pre_receive_test.go
@@ -149,7 +149,7 @@ func TestPreReceiveHook_GitlabAPIAccess(t *testing.T) {
Protocol: protocol,
},
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -271,7 +271,7 @@ func TestPreReceive_APIErrors(t *testing.T) {
Protocol: "web",
},
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -345,7 +345,7 @@ exit %d
Protocol: "web",
},
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
@@ -478,7 +478,7 @@ func TestPreReceiveHook_Primary(t *testing.T) {
Protocol: "web",
},
git.PreReceiveHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/service/hook/reference_transaction_test.go b/internal/gitaly/service/hook/reference_transaction_test.go
index b466cee33..5a1c2c9eb 100644
--- a/internal/gitaly/service/hook/reference_transaction_test.go
+++ b/internal/gitaly/service/hook/reference_transaction_test.go
@@ -155,7 +155,7 @@ func TestReferenceTransactionHook(t *testing.T) {
},
nil,
git.ReferenceTransactionHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/service/hook/update_test.go b/internal/gitaly/service/hook/update_test.go
index 98e30678c..233745f6c 100644
--- a/internal/gitaly/service/hook/update_test.go
+++ b/internal/gitaly/service/hook/update_test.go
@@ -47,7 +47,7 @@ func TestUpdate_CustomHooks(t *testing.T) {
Protocol: "web",
},
git.UpdateHook,
- featureflag.RawFromContext(ctx),
+ featureflag.FromContext(ctx),
).Env()
require.NoError(t, err)
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 79233fed4..7f9a46ff1 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -105,6 +105,18 @@ func TestPostReceivePack_successful(t *testing.T) {
// figuring out their actual contents. So let's just remove it, too.
payload.Transaction = nil
+ var expectedFeatureFlags []git.FeatureFlagWithValue
+ for feature, enabled := range featureflag.FromContext(ctx) {
+ expectedFeatureFlags = append(expectedFeatureFlags, git.FeatureFlagWithValue{
+ Flag: feature, Enabled: enabled,
+ })
+ }
+
+ // Compare here without paying attention to the order given that flags aren't sorted and
+ // unset the struct member afterwards.
+ require.ElementsMatch(t, expectedFeatureFlags, payload.FeatureFlagsWithValue)
+ payload.FeatureFlagsWithValue = nil
+
require.Equal(t, git.HooksPayload{
RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.InternalSocketPath(),
@@ -115,7 +127,6 @@ func TestPostReceivePack_successful(t *testing.T) {
Protocol: "http",
},
RequestedHooks: git.ReceivePackHooks,
- FeatureFlags: featureflag.RawFromContext(ctx),
}, payload)
}
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index e5cbb7c3c..a65c17ef5 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -152,11 +152,18 @@ func TestReceivePackPushSuccess(t *testing.T) {
// figuring out their actual contents. So let's just remove it, too.
payload.Transaction = nil
- expectedFeatureFlags := featureflag.Raw{}
+ var expectedFeatureFlags []git.FeatureFlagWithValue
for _, feature := range featureflag.DefinedFlags() {
- expectedFeatureFlags[feature.MetadataKey()] = "true"
+ expectedFeatureFlags = append(expectedFeatureFlags, git.FeatureFlagWithValue{
+ Flag: feature, Enabled: true,
+ })
}
+ // Compare here without paying attention to the order given that flags aren't sorted and
+ // unset the struct member afterwards.
+ require.ElementsMatch(t, expectedFeatureFlags, payload.FeatureFlagsWithValue)
+ payload.FeatureFlagsWithValue = nil
+
require.Equal(t, git.HooksPayload{
RuntimeDir: cfg.RuntimeDir,
InternalSocket: cfg.InternalSocketPath(),
@@ -167,7 +174,6 @@ func TestReceivePackPushSuccess(t *testing.T) {
Protocol: "ssh",
},
RequestedHooks: git.ReceivePackHooks,
- FeatureFlags: expectedFeatureFlags,
}, payload)
}