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>2021-07-09 16:04:05 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-07-09 16:18:39 +0300
commite93bfbd5904cb72c62aa01aeb93a9cd082aa6e93 (patch)
treecfb52223c019256ac19e1fd9954f2a4787c60697
parent1791308b17aa763d37a4181439685428a5346e93 (diff)
global: Convert users to use feature flag receiver
Instead of `featureflag.IsEnabled(ctx. featureflag.MyFeatureFlag)`, all callers are now converted to use the new receiver functions on feature flags to avoid stuttering.
-rw-r--r--cmd/gitaly-hooks/hooks_test.go4
-rw-r--r--internal/gitaly/service/blob/lfs_pointers.go6
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts.go2
-rw-r--r--internal/gitaly/service/conflicts/resolve_conflicts_test.go2
-rw-r--r--internal/gitaly/service/ref/refs.go2
-rw-r--r--internal/gitaly/service/ref/refs_test.go2
-rw-r--r--internal/gitaly/service/remote/fetch_internal_remote.go2
-rw-r--r--internal/gitaly/service/remote/update_remote_mirror.go4
-rw-r--r--internal/gitaly/service/repository/config.go2
-rw-r--r--internal/gitaly/service/repository/create_from_bundle.go2
-rw-r--r--internal/gitaly/service/repository/create_from_bundle_test.go2
-rw-r--r--internal/gitaly/service/repository/replicate.go2
-rw-r--r--internal/gitaly/service/repository/replicate_test.go2
-rw-r--r--internal/praefect/coordinator.go2
-rw-r--r--internal/testhelper/featureset_test.go8
15 files changed, 22 insertions, 22 deletions
diff --git a/cmd/gitaly-hooks/hooks_test.go b/cmd/gitaly-hooks/hooks_test.go
index 661e0667c..d0f219bc8 100644
--- a/cmd/gitaly-hooks/hooks_test.go
+++ b/cmd/gitaly-hooks/hooks_test.go
@@ -578,8 +578,8 @@ type featureFlagAsserter struct {
}
func (svc featureFlagAsserter) assertFlags(ctx context.Context) {
- assert.True(svc.t, featureflag.IsEnabled(ctx, enabledFeatureFlag))
- assert.True(svc.t, featureflag.IsDisabled(ctx, disabledFeatureFlag))
+ assert.True(svc.t, enabledFeatureFlag.IsEnabled(ctx))
+ assert.True(svc.t, disabledFeatureFlag.IsDisabled(ctx))
}
func (svc featureFlagAsserter) PreReceiveHook(stream gitalypb.HookService_PreReceiveHookServer) error {
diff --git a/internal/gitaly/service/blob/lfs_pointers.go b/internal/gitaly/service/blob/lfs_pointers.go
index 73bf82199..76646cd0b 100644
--- a/internal/gitaly/service/blob/lfs_pointers.go
+++ b/internal/gitaly/service/blob/lfs_pointers.go
@@ -62,7 +62,7 @@ func (s *server) ListLFSPointers(in *gitalypb.ListLFSPointersRequest, stream git
repo := s.localrepo(in.GetRepository())
- if featureflag.IsDisabled(ctx, featureflag.LFSPointersPipeline) {
+ if featureflag.LFSPointersPipeline.IsDisabled(ctx) {
if err := findLFSPointersByRevisions(ctx, repo, s.gitCmdFactory, chunker, int(in.Limit), in.Revisions...); err != nil {
if !errors.Is(err, errLimitReached) {
return err
@@ -121,7 +121,7 @@ func (s *server) ListAllLFSPointers(in *gitalypb.ListAllLFSPointersRequest, stre
},
})
- if featureflag.IsDisabled(ctx, featureflag.LFSPointersPipeline) {
+ if featureflag.LFSPointersPipeline.IsDisabled(ctx) {
cmd, err := repo.Exec(ctx, git.SubCmd{
Name: "cat-file",
Flags: []git.Option{
@@ -184,7 +184,7 @@ func (s *server) GetLFSPointers(req *gitalypb.GetLFSPointersRequest, stream gita
},
})
- if featureflag.IsDisabled(ctx, featureflag.LFSPointersPipeline) {
+ if featureflag.LFSPointersPipeline.IsDisabled(ctx) {
objectIDs := strings.Join(req.BlobIds, "\n")
if err := readLFSPointers(ctx, repo, chunker, strings.NewReader(objectIDs), 0); err != nil {
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts.go b/internal/gitaly/service/conflicts/resolve_conflicts.go
index d9de3d00b..96674ba16 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts.go
@@ -197,7 +197,7 @@ func (s *server) resolveConflicts(header *gitalypb.ResolveConflictsRequestHeader
return err
}
- if featureflag.IsEnabled(ctx, featureflag.ResolveConflictsWithHooks) {
+ if featureflag.ResolveConflictsWithHooks.IsEnabled(ctx) {
if err := s.updater.UpdateReference(
ctx,
header.Repository,
diff --git a/internal/gitaly/service/conflicts/resolve_conflicts_test.go b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
index 5c471dbef..7eab20e24 100644
--- a/internal/gitaly/service/conflicts/resolve_conflicts_test.go
+++ b/internal/gitaly/service/conflicts/resolve_conflicts_test.go
@@ -192,7 +192,7 @@ func testSuccessfulResolveConflictsRequestHelper(t *testing.T, ctx context.Conte
require.Equal(t, string(headCommit.Committer.Email), "johndoe@gitlab.com")
require.Equal(t, string(headCommit.Subject), conflictResolutionCommitMessage)
- if featureflag.IsEnabled(ctx, featureflag.ResolveConflictsWithHooks) {
+ if featureflag.ResolveConflictsWithHooks.IsEnabled(ctx) {
require.Equal(t, 2, hookCount)
} else {
require.Equal(t, 0, hookCount)
diff --git a/internal/gitaly/service/ref/refs.go b/internal/gitaly/service/ref/refs.go
index e13818824..0969f8316 100644
--- a/internal/gitaly/service/ref/refs.go
+++ b/internal/gitaly/service/ref/refs.go
@@ -140,7 +140,7 @@ func (s *server) FindAllTags(in *gitalypb.FindAllTagsRequest, stream gitalypb.Re
repo := s.localrepo(in.GetRepository())
- if featureflag.IsEnabled(ctx, featureflag.FindAllTagsPipeline) {
+ if featureflag.FindAllTagsPipeline.IsEnabled(ctx) {
if err := s.findAllTags(ctx, repo, stream); err != nil {
return helper.ErrInternal(err)
}
diff --git a/internal/gitaly/service/ref/refs_test.go b/internal/gitaly/service/ref/refs_test.go
index ce0cbd7e5..81f7585cf 100644
--- a/internal/gitaly/service/ref/refs_test.go
+++ b/internal/gitaly/service/ref/refs_test.go
@@ -685,7 +685,7 @@ func testFindAllTagNestedTags(t *testing.T, ctx context.Context) {
// opportunistically peels any tag objects for us. This is a lot
// more efficient, and thus we don't have the previous limitations
// anymore with the new code which does use this.
- if info.Type == "commit" && (depth < catfile.MaxTagReferenceDepth || featureflag.IsEnabled(ctx, featureflag.FindAllTagsPipeline)) {
+ if info.Type == "commit" && (depth < catfile.MaxTagReferenceDepth || featureflag.FindAllTagsPipeline.IsEnabled(ctx)) {
commit, err := catfile.GetCommit(ctx, batch, git.Revision(tc.originalOid))
require.NoError(t, err)
expectedTag.TargetCommit = commit
diff --git a/internal/gitaly/service/remote/fetch_internal_remote.go b/internal/gitaly/service/remote/fetch_internal_remote.go
index 5c72264c1..71fb457d8 100644
--- a/internal/gitaly/service/remote/fetch_internal_remote.go
+++ b/internal/gitaly/service/remote/fetch_internal_remote.go
@@ -107,7 +107,7 @@ func (s *server) FetchInternalRemote(ctx context.Context, req *gitalypb.FetchInt
if err := FetchInternalRemote(ctx, s.cfg, s.conns, repo, req.RemoteRepository); err != nil {
var fetchErr fetchFailedError
- if featureflag.IsDisabled(ctx, featureflag.FetchInternalRemoteErrors) && errors.As(err, &fetchErr) {
+ if featureflag.FetchInternalRemoteErrors.IsDisabled(ctx) && errors.As(err, &fetchErr) {
// Design quirk: if the fetch fails, this RPC returns Result: false, but no error.
ctxlogrus.Extract(ctx).WithError(fetchErr.err).WithField("stderr", fetchErr.stderr).Warn("git fetch failed")
return &gitalypb.FetchInternalRemoteResponse{Result: false}, nil
diff --git a/internal/gitaly/service/remote/update_remote_mirror.go b/internal/gitaly/service/remote/update_remote_mirror.go
index 1f1131ce5..734f18ffc 100644
--- a/internal/gitaly/service/remote/update_remote_mirror.go
+++ b/internal/gitaly/service/remote/update_remote_mirror.go
@@ -36,7 +36,7 @@ func (s *server) UpdateRemoteMirror(stream gitalypb.RemoteService_UpdateRemoteMi
return helper.ErrInvalidArgument(err)
}
- if featureflag.IsEnabled(stream.Context(), featureflag.GoUpdateRemoteMirror) {
+ if featureflag.GoUpdateRemoteMirror.IsEnabled(stream.Context()) {
if err := s.goUpdateRemoteMirror(stream, firstRequest); err != nil {
return helper.ErrInternal(err)
}
@@ -337,7 +337,7 @@ func validateUpdateRemoteMirrorRequest(ctx context.Context, req *gitalypb.Update
return fmt.Errorf("remote is missing URL")
}
- if featureflag.IsDisabled(ctx, featureflag.GoUpdateRemoteMirror) {
+ if featureflag.GoUpdateRemoteMirror.IsDisabled(ctx) {
return fmt.Errorf("in-memory remotes require `gitaly_go_update_remote_mirror` feature flag")
}
}
diff --git a/internal/gitaly/service/repository/config.go b/internal/gitaly/service/repository/config.go
index f7ffa5626..2c4453ff9 100644
--- a/internal/gitaly/service/repository/config.go
+++ b/internal/gitaly/service/repository/config.go
@@ -151,7 +151,7 @@ func (s *server) SetConfig(ctx context.Context, req *gitalypb.SetConfigRequest)
// can't use `git config foo.bar secret` because that leaks secrets.
// Also we can use git2go implementation of SetConfig
- if featureflag.IsEnabled(ctx, featureflag.GoSetConfig) {
+ if featureflag.GoSetConfig.IsEnabled(ctx) {
return s.setConfigGit2Go(ctx, req)
}
diff --git a/internal/gitaly/service/repository/create_from_bundle.go b/internal/gitaly/service/repository/create_from_bundle.go
index d53c947c7..034cde81c 100644
--- a/internal/gitaly/service/repository/create_from_bundle.go
+++ b/internal/gitaly/service/repository/create_from_bundle.go
@@ -94,7 +94,7 @@ func (s *server) CreateRepositoryFromBundle(stream gitalypb.RepositoryService_Cr
}
fetchFlags := []git.Option{git.Flag{Name: "--quiet"}}
- if featureflag.IsEnabled(ctx, featureflag.CreateRepositoryFromBundleAtomicFetch) {
+ if featureflag.CreateRepositoryFromBundleAtomicFetch.IsEnabled(ctx) {
fetchFlags = append(fetchFlags, git.Flag{Name: "--atomic"})
}
diff --git a/internal/gitaly/service/repository/create_from_bundle_test.go b/internal/gitaly/service/repository/create_from_bundle_test.go
index cbaeaf3c1..cea7ad9a8 100644
--- a/internal/gitaly/service/repository/create_from_bundle_test.go
+++ b/internal/gitaly/service/repository/create_from_bundle_test.go
@@ -167,7 +167,7 @@ func testServerCreateRepositoryFromBundleTransactional(t *testing.T, ctx context
// If the following feature flag is enabled, then we'll use the `--atomic` flag for
// git-fetch(1) and thus bundle all reference updates into a single transaction. Otherwise,
// the old behaviour will create one transaction per reference.
- if featureflag.IsEnabled(ctx, featureflag.CreateRepositoryFromBundleAtomicFetch) {
+ if featureflag.CreateRepositoryFromBundleAtomicFetch.IsEnabled(ctx) {
votingInput = append(votingInput,
fmt.Sprintf("%s %s refs/keep-around/2\n%s %s refs/keep-around/1\n", git.ZeroOID, masterOID, git.ZeroOID, masterOID),
fmt.Sprintf("%s %s refs/keep-around/2\n%s %s refs/keep-around/1\n", git.ZeroOID, masterOID, git.ZeroOID, masterOID),
diff --git a/internal/gitaly/service/repository/replicate.go b/internal/gitaly/service/repository/replicate.go
index 08d1fcbcd..27f6735f6 100644
--- a/internal/gitaly/service/repository/replicate.go
+++ b/internal/gitaly/service/repository/replicate.go
@@ -192,7 +192,7 @@ func (s *server) createFromSnapshot(ctx context.Context, in *gitalypb.ReplicateR
}
func (s *server) syncRepository(ctx context.Context, in *gitalypb.ReplicateRepositoryRequest) error {
- if featureflag.IsEnabled(ctx, featureflag.ReplicateRepositoryDirectFetch) {
+ if featureflag.ReplicateRepositoryDirectFetch.IsEnabled(ctx) {
repo := s.localrepo(in.GetRepository())
if err := remote.FetchInternalRemote(ctx, s.cfg, s.conns, repo, in.GetSource()); err != nil {
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index 5d3113a59..eb5f424bd 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -167,7 +167,7 @@ func testReplicateRepositoryTransactional(t *testing.T, ctx context.Context) {
Source: sourceRepo,
})
- if featureflag.IsEnabled(ctx, featureflag.ReplicateRepositoryDirectFetch) {
+ if featureflag.ReplicateRepositoryDirectFetch.IsEnabled(ctx) {
require.NoError(t, err)
require.Equal(t, 2, votes)
} else {
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index 3ae9863d0..bbdf4e86b 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -42,7 +42,7 @@ func transactionsDisabled(context.Context) bool { return false }
func transactionsFlag(flag featureflag.FeatureFlag) transactionsCondition {
return func(ctx context.Context) bool {
- return featureflag.IsEnabled(ctx, flag)
+ return flag.IsEnabled(ctx)
}
}
diff --git a/internal/testhelper/featureset_test.go b/internal/testhelper/featureset_test.go
index 498da6623..443756ad1 100644
--- a/internal/testhelper/featureset_test.go
+++ b/internal/testhelper/featureset_test.go
@@ -165,12 +165,12 @@ func TestFeatureSets_Run(t *testing.T) {
outgoingCtx := helper.OutgoingToIncoming(metadata.NewOutgoingContext(context.Background(), outgoingMD))
incomingFlags = append(incomingFlags, [2]bool{
- ff.IsDisabled(incomingCtx, featureFlagB),
- ff.IsDisabled(incomingCtx, featureFlagA),
+ featureFlagB.IsDisabled(incomingCtx),
+ featureFlagA.IsDisabled(incomingCtx),
})
outgoingFlags = append(outgoingFlags, [2]bool{
- ff.IsDisabled(outgoingCtx, featureFlagB),
- ff.IsDisabled(outgoingCtx, featureFlagA),
+ featureFlagB.IsDisabled(outgoingCtx),
+ featureFlagA.IsDisabled(outgoingCtx),
})
})