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-09-20 15:15:49 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-20 15:16:32 +0300
commit59b691988d8719235b7032c59e91c5bf2637262d (patch)
tree58dc891dfa2e72b09e7c447249b04348dbdfa47c
parentd6c4f13dbff2729dffe834641d7e35cd6bbac5dc (diff)
helper: Move metatada-helpers into the metadata package
While the helpers `IncomingToOutgoing()` and `OutgoingToIncoming()` both fall into the metadata categories, they're still part of the generic "helper" package. Move them over into the "metadata" package to make them easier to find.
-rw-r--r--cmd/gitaly-hooks/hooks.go4
-rw-r--r--internal/git/remoterepo/repository_test.go3
-rw-r--r--internal/gitaly/hook/sidechannel_test.go8
-rw-r--r--internal/gitaly/service/operations/apply_patch_test.go4
-rw-r--r--internal/gitaly/service/operations/branches_test.go6
-rw-r--r--internal/gitaly/service/operations/rebase_test.go6
-rw-r--r--internal/gitaly/service/operations/tags_test.go6
-rw-r--r--internal/gitaly/service/ref/delete_refs_test.go4
-rw-r--r--internal/gitaly/service/repository/apply_gitattributes_test.go4
-rw-r--r--internal/gitaly/service/repository/config_test.go6
-rw-r--r--internal/gitaly/service/repository/create_from_bundle_test.go4
-rw-r--r--internal/gitaly/service/repository/create_test.go4
-rw-r--r--internal/gitaly/service/repository/fetch_remote_test.go4
-rw-r--r--internal/gitaly/service/repository/midx_test.go4
-rw-r--r--internal/gitaly/service/repository/remove_test.go4
-rw-r--r--internal/gitaly/service/repository/replicate.go3
-rw-r--r--internal/gitaly/service/repository/replicate_test.go12
-rw-r--r--internal/gitaly/service/smarthttp/receive_pack_test.go4
-rw-r--r--internal/gitaly/service/ssh/receive_pack_test.go4
-rw-r--r--internal/helper/storage.go20
-rw-r--r--internal/helper/storage_test.go16
-rw-r--r--internal/metadata/metadata.go20
-rw-r--r--internal/metadata/metadata_test.go26
-rw-r--r--internal/praefect/coordinator.go13
-rw-r--r--internal/praefect/grpc-proxy/proxy/examples_test.go20
-rw-r--r--internal/praefect/grpc-proxy/proxy/handler_ext_test.go32
-rw-r--r--internal/praefect/grpc-proxy/proxy/peeker_test.go6
-rw-r--r--internal/testhelper/featureset_test.go12
28 files changed, 137 insertions, 122 deletions
diff --git a/cmd/gitaly-hooks/hooks.go b/cmd/gitaly-hooks/hooks.go
index d65406cd6..a84ba637f 100644
--- a/cmd/gitaly-hooks/hooks.go
+++ b/cmd/gitaly-hooks/hooks.go
@@ -19,9 +19,9 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config/prometheus"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/hook"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitlab"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/env"
gitalylog "gitlab.com/gitlab-org/gitaly/v14/internal/log"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/stream"
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
@@ -344,7 +344,7 @@ func packObjectsHook(ctx context.Context, payload git.HooksPayload, hookClient g
var rpc string
var err error
- if featureflag.PackObjectsHookWithSidechannel.IsEnabled(helper.OutgoingToIncoming(ctx)) {
+ if featureflag.PackObjectsHookWithSidechannel.IsEnabled(metadata.OutgoingToIncoming(ctx)) {
rpc = "PackObjectsHookWithSidechannel"
err = handlePackObjectsWithSidechannel(ctx, hookClient, payload.Repo, fixedArgs)
} else {
diff --git a/internal/git/remoterepo/repository_test.go b/internal/git/remoterepo/repository_test.go
index b74f88f75..c04c9d38d 100644
--- a/internal/git/remoterepo/repository_test.go
+++ b/internal/git/remoterepo/repository_test.go
@@ -12,6 +12,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/commit"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/repository"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
@@ -52,7 +53,7 @@ func TestRepository(t *testing.T) {
gittest.TestRepository(t, cfg, func(t testing.TB, pbRepo *gitalypb.Repository) git.Repository {
t.Helper()
- r, err := remoterepo.New(helper.OutgoingToIncoming(ctx), pbRepo, pool)
+ r, err := remoterepo.New(metadata.OutgoingToIncoming(ctx), pbRepo, pool)
require.NoError(t, err)
return r
})
diff --git a/internal/gitaly/hook/sidechannel_test.go b/internal/gitaly/hook/sidechannel_test.go
index b142f1014..362b2432a 100644
--- a/internal/gitaly/hook/sidechannel_test.go
+++ b/internal/gitaly/hook/sidechannel_test.go
@@ -8,8 +8,8 @@ import (
"testing"
"github.com/stretchr/testify/require"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
- "google.golang.org/grpc/metadata"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
+ grpc_metadata "google.golang.org/grpc/metadata"
)
func TestSidechannel(t *testing.T) {
@@ -25,7 +25,7 @@ func TestSidechannel(t *testing.T) {
defer wt.Close()
// Server side
- ctxIn := helper.OutgoingToIncoming(ctxOut)
+ ctxIn := metadata.OutgoingToIncoming(ctxOut)
c, err := GetSidechannel(ctxIn)
require.NoError(t, err)
defer c.Close()
@@ -48,7 +48,7 @@ func TestGetSidechannel(t *testing.T) {
for _, tc := range testCases {
t.Run(tc, func(t *testing.T) {
- ctx := metadata.NewIncomingContext(
+ ctx := grpc_metadata.NewIncomingContext(
context.Background(),
map[string][]string{sidechannelHeader: {tc}},
)
diff --git a/internal/gitaly/service/operations/apply_patch_test.go b/internal/gitaly/service/operations/apply_patch_test.go
index 170e164fd..bc128093c 100644
--- a/internal/gitaly/service/operations/apply_patch_test.go
+++ b/internal/gitaly/service/operations/apply_patch_test.go
@@ -20,8 +20,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git2go"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
@@ -641,7 +641,7 @@ func testUserApplyPatchTransactional(t *testing.T, ctx context.Context) {
ctx = peer.NewContext(ctx, &peer.Peer{
AuthInfo: backchannel.WithID(nil, 1234),
})
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
patch := testhelper.MustReadFile(t, "testdata/0001-A-commit-from-a-patch.patch")
diff --git a/internal/gitaly/service/operations/branches_test.go b/internal/gitaly/service/operations/branches_test.go
index 3fdd04917..2bb6c47b5 100644
--- a/internal/gitaly/service/operations/branches_test.go
+++ b/internal/gitaly/service/operations/branches_test.go
@@ -12,7 +12,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/hook"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
@@ -162,7 +162,7 @@ func TestUserCreateBranchWithTransaction(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
client := newMuxedOperationClient(t, ctx, tc.address, cfg.Auth.Token,
backchannel.NewClientHandshaker(
@@ -506,7 +506,7 @@ func TestUserDeleteBranch_transaction(t *testing.T) {
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
client := newMuxedOperationClient(t, ctx, fmt.Sprintf("unix://"+cfg.GitalyInternalSocketPath()), cfg.Auth.Token,
backchannel.NewClientHandshaker(
diff --git a/internal/gitaly/service/operations/rebase_test.go b/internal/gitaly/service/operations/rebase_test.go
index aca107a66..7581b43c7 100644
--- a/internal/gitaly/service/operations/rebase_test.go
+++ b/internal/gitaly/service/operations/rebase_test.go
@@ -16,7 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
@@ -149,12 +149,12 @@ func TestUserRebaseConfirmableTransaction(t *testing.T) {
ctx := ctx
if tc.withTransaction {
- ctx = helper.OutgoingToIncoming(ctx)
+ ctx = metadata.OutgoingToIncoming(ctx)
var err error
ctx, err = txinfo.InjectTransaction(ctx, 1, "node", tc.primary)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
}
branchSha, err := repo.ResolveRevision(ctx, git.Revision(rebaseBranchName))
diff --git a/internal/gitaly/service/operations/tags_test.go b/internal/gitaly/service/operations/tags_test.go
index 7fd6f4137..fa7a202bd 100644
--- a/internal/gitaly/service/operations/tags_test.go
+++ b/internal/gitaly/service/operations/tags_test.go
@@ -16,8 +16,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/hook"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
@@ -357,10 +357,10 @@ func TestUserCreateTagWithTransaction(t *testing.T) {
// We need to convert to an incoming context first in
// order to preserve the feature flag.
- ctx = helper.OutgoingToIncoming(ctx)
+ ctx = metadata.OutgoingToIncoming(ctx)
ctx, err = txinfo.InjectTransaction(ctx, 1, "node", testCase.primary)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
response, err := client.UserCreateTag(ctx, request)
require.NoError(t, err)
diff --git a/internal/gitaly/service/ref/delete_refs_test.go b/internal/gitaly/service/ref/delete_refs_test.go
index a73ce0fa3..bbda1d6de 100644
--- a/internal/gitaly/service/ref/delete_refs_test.go
+++ b/internal/gitaly/service/ref/delete_refs_test.go
@@ -11,7 +11,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service"
hookservice "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/hook"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
@@ -109,7 +109,7 @@ func TestDeleteRefs_transaction(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
for _, tc := range []struct {
desc string
diff --git a/internal/gitaly/service/repository/apply_gitattributes_test.go b/internal/gitaly/service/repository/apply_gitattributes_test.go
index 3cebc3969..1fa728644 100644
--- a/internal/gitaly/service/repository/apply_gitattributes_test.go
+++ b/internal/gitaly/service/repository/apply_gitattributes_test.go
@@ -15,7 +15,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/backchannel"
"gitlab.com/gitlab-org/gitaly/v14/internal/git"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
@@ -208,7 +208,7 @@ func testApplyGitattributesWithTransaction(t *testing.T, ctx context.Context) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "primary", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
transactionServer.vote = func(request *gitalypb.VoteTransactionRequest) (*gitalypb.VoteTransactionResponse, error) {
return tc.voteFn(t, request)
diff --git a/internal/gitaly/service/repository/config_test.go b/internal/gitaly/service/repository/config_test.go
index 8988ae6ef..62739da74 100644
--- a/internal/gitaly/service/repository/config_test.go
+++ b/internal/gitaly/service/repository/config_test.go
@@ -15,7 +15,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/rubyserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
@@ -151,7 +151,7 @@ func TestDeleteConfigTransactional(t *testing.T) {
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
unmodifiedContents := testhelper.MustReadFile(t, filepath.Join(repoPath, "config"))
gittest.Exec(t, cfg, "-C", repoPath, "config", "delete.me", "now")
@@ -250,7 +250,7 @@ func testSetConfigTransactional(t *testing.T, cfg config.Cfg, rubySrv *rubyserve
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
unmodifiedContents := testhelper.MustReadFile(t, filepath.Join(repoPath, "config"))
diff --git a/internal/gitaly/service/repository/create_from_bundle_test.go b/internal/gitaly/service/repository/create_from_bundle_test.go
index 553d3701c..8ab62fedc 100644
--- a/internal/gitaly/service/repository/create_from_bundle_test.go
+++ b/internal/gitaly/service/repository/create_from_bundle_test.go
@@ -17,8 +17,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git/localrepo"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/tempdir"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
@@ -120,7 +120,7 @@ func TestServerCreateRepositoryFromBundleTransactional(t *testing.T) {
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "primary", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
stream, err := client.CreateRepositoryFromBundle(ctx)
require.NoError(t, err)
diff --git a/internal/gitaly/service/repository/create_test.go b/internal/gitaly/service/repository/create_test.go
index 55647c23d..165d1257a 100644
--- a/internal/gitaly/service/repository/create_test.go
+++ b/internal/gitaly/service/repository/create_test.go
@@ -16,7 +16,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config/auth"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
@@ -137,7 +137,7 @@ func TestCreateRepositoryTransactional(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
t.Run("initial creation without refs", func(t *testing.T) {
called = 0
diff --git a/internal/gitaly/service/repository/fetch_remote_test.go b/internal/gitaly/service/repository/fetch_remote_test.go
index 5fac9e4a5..a64a51d87 100644
--- a/internal/gitaly/service/repository/fetch_remote_test.go
+++ b/internal/gitaly/service/repository/fetch_remote_test.go
@@ -19,8 +19,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
@@ -222,7 +222,7 @@ func TestFetchRemote_transaction(t *testing.T) {
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
require.Equal(t, 0, txManager.votes)
diff --git a/internal/gitaly/service/repository/midx_test.go b/internal/gitaly/service/repository/midx_test.go
index da01b2f3c..c4ab36abe 100644
--- a/internal/gitaly/service/repository/midx_test.go
+++ b/internal/gitaly/service/repository/midx_test.go
@@ -18,8 +18,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git/stats"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
@@ -147,7 +147,7 @@ func testMidxRepackTransactional(t *testing.T, ctx context.Context) {
ctx = peer.NewContext(ctx, &peer.Peer{
AuthInfo: backchannel.WithID(nil, 1234),
})
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
_, err = client.MidxRepack(ctx, &gitalypb.MidxRepackRequest{
Repository: repo,
diff --git a/internal/gitaly/service/repository/remove_test.go b/internal/gitaly/service/repository/remove_test.go
index e7ffe490c..6ab87bf6f 100644
--- a/internal/gitaly/service/repository/remove_test.go
+++ b/internal/gitaly/service/repository/remove_test.go
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testserver"
"gitlab.com/gitlab-org/gitaly/v14/internal/transaction/txinfo"
@@ -56,7 +56,7 @@ func TestRemoveRepositoryTransactional(t *testing.T) {
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "primary", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
t.Run("with existing repository", func(t *testing.T) {
votes = []voting.Vote{}
diff --git a/internal/gitaly/service/repository/replicate.go b/internal/gitaly/service/repository/replicate.go
index 3892d2203..b55d3fc96 100644
--- a/internal/gitaly/service/repository/replicate.go
+++ b/internal/gitaly/service/repository/replicate.go
@@ -17,6 +17,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/safe"
"gitlab.com/gitlab-org/gitaly/v14/internal/tempdir"
@@ -57,7 +58,7 @@ func (s *server) ReplicateRepository(ctx context.Context, in *gitalypb.Replicate
// may still modify the repository even though the local side has
// returned already.
g, _ := errgroup.WithContext(ctx)
- outgoingCtx := helper.IncomingToOutgoing(ctx)
+ outgoingCtx := metadata.IncomingToOutgoing(ctx)
syncFuncs := []func(context.Context, *gitalypb.ReplicateRepositoryRequest) error{
s.syncGitconfig,
diff --git a/internal/gitaly/service/repository/replicate_test.go b/internal/gitaly/service/repository/replicate_test.go
index 742dcf753..0f3ccbd07 100644
--- a/internal/gitaly/service/repository/replicate_test.go
+++ b/internal/gitaly/service/repository/replicate_test.go
@@ -13,8 +13,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/git/gittest"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
@@ -23,7 +23,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
- "google.golang.org/grpc/metadata"
+ grpc_metadata "google.golang.org/grpc/metadata"
"google.golang.org/protobuf/proto"
)
@@ -63,7 +63,7 @@ func TestReplicateRepository(t *testing.T) {
ctx, cancel := testhelper.Context()
defer cancel()
md := testhelper.GitalyServersMetadataFromCfg(t, cfg)
- injectedCtx := metadata.NewOutgoingContext(ctx, md)
+ injectedCtx := grpc_metadata.NewOutgoingContext(ctx, md)
_, err = client.ReplicateRepository(injectedCtx, &gitalypb.ReplicateRepositoryRequest{
Repository: targetRepo,
@@ -131,7 +131,7 @@ func testReplicateRepositoryTransactional(t *testing.T, ctx context.Context) {
ctx, err := txinfo.InjectTransaction(ctx, 1, "primary", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
ctx = testhelper.MergeOutgoingMetadata(ctx, testhelper.GitalyServersMetadataFromCfg(t, cfg))
client := newMuxedRepositoryClient(t, ctx, cfg, serverSocketPath, backchannel.NewClientHandshaker(
@@ -332,7 +332,7 @@ func TestReplicateRepository_BadRepository(t *testing.T) {
defer cancel()
md := testhelper.GitalyServersMetadataFromCfg(t, cfg)
- injectedCtx := metadata.NewOutgoingContext(ctx, md)
+ injectedCtx := grpc_metadata.NewOutgoingContext(ctx, md)
_, err := client.ReplicateRepository(injectedCtx, &gitalypb.ReplicateRepositoryRequest{
Repository: targetRepo,
@@ -375,7 +375,7 @@ func TestReplicateRepository_FailedFetchInternalRemote(t *testing.T) {
defer cancel()
md := testhelper.GitalyServersMetadataFromCfg(t, cfg)
- injectedCtx := metadata.NewOutgoingContext(ctx, md)
+ injectedCtx := grpc_metadata.NewOutgoingContext(ctx, md)
_, err = repoClient.ReplicateRepository(injectedCtx, &gitalypb.ReplicateRepositoryRequest{
Repository: targetRepo,
diff --git a/internal/gitaly/service/smarthttp/receive_pack_test.go b/internal/gitaly/service/smarthttp/receive_pack_test.go
index 8de40ac40..1146958e2 100644
--- a/internal/gitaly/service/smarthttp/receive_pack_test.go
+++ b/internal/gitaly/service/smarthttp/receive_pack_test.go
@@ -22,8 +22,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/service/hook"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitlab"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
@@ -637,7 +637,7 @@ func TestPostReceiveWithReferenceTransactionHook(t *testing.T) {
ctx, err := txinfo.InjectTransaction(ctx, 1234, "primary", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
client := newMuxedSmartHTTPClient(t, ctx, addr, cfg.Auth.Token, func() backchannel.Server {
srv := grpc.NewServer()
diff --git a/internal/gitaly/service/ssh/receive_pack_test.go b/internal/gitaly/service/ssh/receive_pack_test.go
index a778d047c..f6978491d 100644
--- a/internal/gitaly/service/ssh/receive_pack_test.go
+++ b/internal/gitaly/service/ssh/receive_pack_test.go
@@ -23,8 +23,8 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/config"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/transaction"
"gitlab.com/gitlab-org/gitaly/v14/internal/gitlab"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/text"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testassert"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper/testcfg"
@@ -282,7 +282,7 @@ func TestReceivePackTransactional(t *testing.T) {
defer cancel()
ctx, err := txinfo.InjectTransaction(ctx, 1, "node", true)
require.NoError(t, err)
- ctx = helper.IncomingToOutgoing(ctx)
+ ctx = metadata.IncomingToOutgoing(ctx)
masterOID := text.ChompBytes(gittest.Exec(t, cfg, "-C", repoPath,
"rev-parse", "refs/heads/master"))
diff --git a/internal/helper/storage.go b/internal/helper/storage.go
index c6052d82e..3bbf277c2 100644
--- a/internal/helper/storage.go
+++ b/internal/helper/storage.go
@@ -54,26 +54,6 @@ func ExtractGitalyServer(ctx context.Context, storageName string) (storage.Serve
return gitalyServer, nil
}
-// IncomingToOutgoing creates an outgoing context out of an incoming context with the same storage metadata
-func IncomingToOutgoing(ctx context.Context) context.Context {
- md, ok := metadata.FromIncomingContext(ctx)
- if !ok {
- return ctx
- }
-
- return metadata.NewOutgoingContext(ctx, md)
-}
-
-// OutgoingToIncoming creates an incoming context out of an outgoing context with the same storage metadata
-func OutgoingToIncoming(ctx context.Context) context.Context {
- md, ok := metadata.FromOutgoingContext(ctx)
- if !ok {
- return ctx
- }
-
- return metadata.NewIncomingContext(ctx, md)
-}
-
// InjectGitalyServers injects gitaly-servers metadata into an outgoing context
func InjectGitalyServers(ctx context.Context, name, address, token string) (context.Context, error) {
gitalyServers := storage.GitalyServers{
diff --git a/internal/helper/storage_test.go b/internal/helper/storage_test.go
index 186cceda2..486efc12d 100644
--- a/internal/helper/storage_test.go
+++ b/internal/helper/storage_test.go
@@ -97,19 +97,3 @@ func TestInjectGitalyServers(t *testing.T) {
require.Equal(t, []string{"bar"}, md["foo"])
})
}
-
-func TestOutgoingToIncoming(t *testing.T) {
- ctx := context.Background()
- ctx, err := InjectGitalyServers(ctx, "a", "b", "c")
- require.NoError(t, err)
-
- _, err = ExtractGitalyServer(ctx, "a")
- require.Equal(t, ErrEmptyMetadata, err,
- "server should not be found in the incoming context")
-
- ctx = OutgoingToIncoming(ctx)
-
- info, err := ExtractGitalyServer(ctx, "a")
- require.NoError(t, err)
- require.Equal(t, storage.ServerInfo{Address: "b", Token: "c"}, info)
-}
diff --git a/internal/metadata/metadata.go b/internal/metadata/metadata.go
index e78ec0843..83e6e1247 100644
--- a/internal/metadata/metadata.go
+++ b/internal/metadata/metadata.go
@@ -6,6 +6,26 @@ import (
"google.golang.org/grpc/metadata"
)
+// IncomingToOutgoing creates an outgoing context out of an incoming context with the same storage metadata
+func IncomingToOutgoing(ctx context.Context) context.Context {
+ md, ok := metadata.FromIncomingContext(ctx)
+ if !ok {
+ return ctx
+ }
+
+ return metadata.NewOutgoingContext(ctx, md)
+}
+
+// OutgoingToIncoming creates an incoming context out of an outgoing context with the same storage metadata
+func OutgoingToIncoming(ctx context.Context) context.Context {
+ md, ok := metadata.FromOutgoingContext(ctx)
+ if !ok {
+ return ctx
+ }
+
+ return metadata.NewIncomingContext(ctx, md)
+}
+
// GetValue returns the first value in the metadata slice based on a key
func GetValue(ctx context.Context, key string) string {
md, ok := metadata.FromIncomingContext(ctx)
diff --git a/internal/metadata/metadata_test.go b/internal/metadata/metadata_test.go
new file mode 100644
index 000000000..6068c8fe8
--- /dev/null
+++ b/internal/metadata/metadata_test.go
@@ -0,0 +1,26 @@
+package metadata
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/gitaly/storage"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+)
+
+func TestOutgoingToIncoming(t *testing.T) {
+ ctx := context.Background()
+ ctx, err := helper.InjectGitalyServers(ctx, "a", "b", "c")
+ require.NoError(t, err)
+
+ _, err = helper.ExtractGitalyServer(ctx, "a")
+ require.Equal(t, helper.ErrEmptyMetadata, err,
+ "server should not be found in the incoming context")
+
+ ctx = OutgoingToIncoming(ctx)
+
+ info, err := helper.ExtractGitalyServer(ctx, "a")
+ require.NoError(t, err)
+ require.Equal(t, storage.ServerInfo{Address: "b", Token: "c"}, info)
+}
diff --git a/internal/praefect/coordinator.go b/internal/praefect/coordinator.go
index b2819380e..5d9a3a862 100644
--- a/internal/praefect/coordinator.go
+++ b/internal/praefect/coordinator.go
@@ -12,6 +12,7 @@ import (
"github.com/sirupsen/logrus"
gitalyerrors "gitlab.com/gitlab-org/gitaly/v14/internal/errors"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/middleware/metadatahandler"
"gitlab.com/gitlab-org/gitaly/v14/internal/praefect/commonerr"
"gitlab.com/gitlab-org/gitaly/v14/internal/praefect/config"
@@ -25,7 +26,7 @@ import (
"gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb"
"gitlab.com/gitlab-org/labkit/correlation"
"golang.org/x/sync/errgroup"
- "google.golang.org/grpc/metadata"
+ grpc_metadata "google.golang.org/grpc/metadata"
"google.golang.org/protobuf/proto"
)
@@ -372,7 +373,7 @@ func shouldRouteRepositoryAccessorToPrimary(ctx context.Context, call grpcCall)
// In case the call's metadata tells us to force-route to the primary, then we must abide
// and ignore what `forcePrimaryRPCs` says.
- if md, ok := metadata.FromIncomingContext(ctx); ok {
+ if md, ok := grpc_metadata.FromIncomingContext(ctx); ok {
header := md.Get(routeRepositoryAccessorPolicy)
if len(header) == 0 {
return forcePrimary
@@ -405,7 +406,7 @@ func (c *Coordinator) accessorStreamParameters(ctx context.Context, call grpcCal
metrics.ReadDistribution.WithLabelValues(virtualStorage, node.Storage).Inc()
return proxy.NewStreamParameters(proxy.Destination{
- Ctx: helper.IncomingToOutgoing(ctx),
+ Ctx: metadata.IncomingToOutgoing(ctx),
Conn: node.Connection,
Msg: b,
}, nil, nil, nil), nil
@@ -486,7 +487,7 @@ func (c *Coordinator) mutatorStreamParameters(ctx context.Context, call grpcCall
var finalizers []func() error
primaryDest := proxy.Destination{
- Ctx: helper.IncomingToOutgoing(ctx),
+ Ctx: metadata.IncomingToOutgoing(ctx),
Conn: route.Primary.Connection,
Msg: primaryMessage,
}
@@ -510,7 +511,7 @@ func (c *Coordinator) mutatorStreamParameters(ctx context.Context, call grpcCall
if err != nil {
return nil, err
}
- primaryDest.Ctx = helper.IncomingToOutgoing(injectedCtx)
+ primaryDest.Ctx = metadata.IncomingToOutgoing(injectedCtx)
primaryDest.ErrHandler = func(err error) error {
nodeErrors.Lock()
defer nodeErrors.Unlock()
@@ -531,7 +532,7 @@ func (c *Coordinator) mutatorStreamParameters(ctx context.Context, call grpcCall
}
secondaryDests = append(secondaryDests, proxy.Destination{
- Ctx: helper.IncomingToOutgoing(injectedCtx),
+ Ctx: metadata.IncomingToOutgoing(injectedCtx),
Conn: secondary.Connection,
Msg: secondaryMsg,
ErrHandler: func(err error) error {
diff --git a/internal/praefect/grpc-proxy/proxy/examples_test.go b/internal/praefect/grpc-proxy/proxy/examples_test.go
index 06b4a6c99..187d27e96 100644
--- a/internal/praefect/grpc-proxy/proxy/examples_test.go
+++ b/internal/praefect/grpc-proxy/proxy/examples_test.go
@@ -1,21 +1,17 @@
// Copyright 2017 Michal Witkowski. All Rights Reserved.
// See LICENSE for licensing terms.
-// TODO: remove the following linter override when the deprecations are fixed
-// in issue https://gitlab.com/gitlab-org/gitaly/issues/1663
-//lint:file-ignore SA1019 Ignore all gRPC deprecations until issue #1663
-
package proxy_test
import (
"context"
"strings"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/praefect/grpc-proxy/proxy"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
- "google.golang.org/grpc/metadata"
+ grpc_metadata "google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
@@ -44,16 +40,22 @@ func ExampleStreamDirector() {
if strings.HasPrefix(fullMethodName, "/com.example.internal.") {
return nil, status.Errorf(codes.Unimplemented, "Unknown method")
}
- md, ok := metadata.FromIncomingContext(ctx)
+ md, ok := grpc_metadata.FromIncomingContext(ctx)
if ok {
// Decide on which backend to dial
if val, exists := md[":authority"]; exists && val[0] == "staging.api.example.com" {
// Make sure we use DialContext so the dialing can be cancelled/time out together with the context.
conn, err := grpc.DialContext(ctx, "api-service.staging.svc.local", grpc.WithDefaultCallOptions(grpc.ForceCodec(proxy.NewCodec())))
- return proxy.NewStreamParameters(proxy.Destination{Conn: conn, Ctx: helper.IncomingToOutgoing(ctx)}, nil, nil, nil), err
+ return proxy.NewStreamParameters(proxy.Destination{
+ Conn: conn,
+ Ctx: metadata.IncomingToOutgoing(ctx),
+ }, nil, nil, nil), err
} else if val, exists := md[":authority"]; exists && val[0] == "api.example.com" {
conn, err := grpc.DialContext(ctx, "api-service.prod.svc.local", grpc.WithDefaultCallOptions(grpc.ForceCodec(proxy.NewCodec())))
- return proxy.NewStreamParameters(proxy.Destination{Conn: conn, Ctx: helper.IncomingToOutgoing(ctx)}, nil, nil, nil), err
+ return proxy.NewStreamParameters(proxy.Destination{
+ Conn: conn,
+ Ctx: metadata.IncomingToOutgoing(ctx),
+ }, nil, nil, nil), err
}
}
return nil, status.Errorf(codes.Unimplemented, "Unknown method")
diff --git a/internal/praefect/grpc-proxy/proxy/handler_ext_test.go b/internal/praefect/grpc-proxy/proxy/handler_ext_test.go
index 4557e5c11..d33fa458d 100644
--- a/internal/praefect/grpc-proxy/proxy/handler_ext_test.go
+++ b/internal/praefect/grpc-proxy/proxy/handler_ext_test.go
@@ -23,8 +23,8 @@ import (
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
"gitlab.com/gitlab-org/gitaly/v14/client"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
"gitlab.com/gitlab-org/gitaly/v14/internal/helper/fieldextractors"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/middleware/sentryhandler"
"gitlab.com/gitlab-org/gitaly/v14/internal/praefect/grpc-proxy/proxy"
pb "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/grpc-proxy/testdata"
@@ -33,7 +33,7 @@ import (
"go.uber.org/goleak"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
- "google.golang.org/grpc/metadata"
+ grpc_metadata "google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
)
@@ -64,7 +64,7 @@ type assertingService struct {
func (s *assertingService) PingEmpty(ctx context.Context, _ *pb.Empty) (*pb.PingResponse, error) {
// Check that this call has client's metadata.
- md, ok := metadata.FromIncomingContext(ctx)
+ md, ok := grpc_metadata.FromIncomingContext(ctx)
assert.True(s.t, ok, "PingEmpty call must have metadata in context")
_, ok = md[clientMdKey]
assert.True(s.t, ok, "PingEmpty call must have clients's custom headers in metadata")
@@ -73,8 +73,8 @@ func (s *assertingService) PingEmpty(ctx context.Context, _ *pb.Empty) (*pb.Ping
func (s *assertingService) Ping(ctx context.Context, ping *pb.PingRequest) (*pb.PingResponse, error) {
// Send user trailers and headers.
- require.NoError(s.t, grpc.SendHeader(ctx, metadata.Pairs(serverHeaderMdKey, "I like turtles.")))
- require.NoError(s.t, grpc.SetTrailer(ctx, metadata.Pairs(serverTrailerMdKey, "I like ending turtles.")))
+ require.NoError(s.t, grpc.SendHeader(ctx, grpc_metadata.Pairs(serverHeaderMdKey, "I like turtles.")))
+ require.NoError(s.t, grpc.SetTrailer(ctx, grpc_metadata.Pairs(serverTrailerMdKey, "I like ending turtles.")))
return &pb.PingResponse{Value: ping.Value, Counter: 42}, nil
}
@@ -84,16 +84,16 @@ func (s *assertingService) PingError(ctx context.Context, ping *pb.PingRequest)
func (s *assertingService) PingList(ping *pb.PingRequest, stream pb.TestService_PingListServer) error {
// Send user trailers and headers.
- require.NoError(s.t, stream.SendHeader(metadata.Pairs(serverHeaderMdKey, "I like turtles.")))
+ require.NoError(s.t, stream.SendHeader(grpc_metadata.Pairs(serverHeaderMdKey, "I like turtles.")))
for i := 0; i < countListResponses; i++ {
require.NoError(s.t, stream.Send(&pb.PingResponse{Value: ping.Value, Counter: int32(i)}))
}
- stream.SetTrailer(metadata.Pairs(serverTrailerMdKey, "I like ending turtles."))
+ stream.SetTrailer(grpc_metadata.Pairs(serverTrailerMdKey, "I like ending turtles."))
return nil
}
func (s *assertingService) PingStream(stream pb.TestService_PingStreamServer) error {
- require.NoError(s.t, stream.SendHeader(metadata.Pairs(serverHeaderMdKey, "I like turtles.")))
+ require.NoError(s.t, stream.SendHeader(grpc_metadata.Pairs(serverHeaderMdKey, "I like turtles.")))
counter := int32(0)
for {
ping, err := stream.Recv()
@@ -109,7 +109,7 @@ func (s *assertingService) PingStream(stream pb.TestService_PingStreamServer) er
}
counter++
}
- stream.SetTrailer(metadata.Pairs(serverTrailerMdKey, "I like ending turtles."))
+ stream.SetTrailer(grpc_metadata.Pairs(serverTrailerMdKey, "I like ending turtles."))
return nil
}
@@ -126,7 +126,7 @@ type ProxyHappySuite struct {
}
func (s *ProxyHappySuite) TestPingEmptyCarriesClientMetadata() {
- ctx := metadata.NewOutgoingContext(s.ctx, metadata.Pairs(clientMdKey, "true"))
+ ctx := grpc_metadata.NewOutgoingContext(s.ctx, grpc_metadata.Pairs(clientMdKey, "true"))
out, err := s.client.PingEmpty(ctx, &pb.Empty{})
require.NoError(s.T(), err, "PingEmpty should succeed without errors")
testassert.ProtoEqual(s.T(), &pb.PingResponse{Value: pingDefaultValue, Counter: 42}, out)
@@ -139,8 +139,8 @@ func (s *ProxyHappySuite) TestPingEmpty_StressTest() {
}
func (s *ProxyHappySuite) TestPingCarriesServerHeadersAndTrailers() {
- headerMd := make(metadata.MD)
- trailerMd := make(metadata.MD)
+ headerMd := make(grpc_metadata.MD)
+ trailerMd := make(grpc_metadata.MD)
// This is an awkward calling convention... but meh.
out, err := s.client.Ping(s.ctx, &pb.PingRequest{Value: "foo"}, grpc.Header(&headerMd), grpc.Trailer(&trailerMd))
require.NoError(s.T(), err, "Ping should succeed without errors")
@@ -179,7 +179,7 @@ func (s *ProxyHappySuite) TestPingErrorPropagatesAppError() {
func (s *ProxyHappySuite) TestDirectorErrorIsPropagated() {
// See SetupSuite where the StreamDirector has a special case.
- ctx := metadata.NewOutgoingContext(s.ctx, metadata.Pairs(rejectingMdKey, "true"))
+ ctx := grpc_metadata.NewOutgoingContext(s.ctx, grpc_metadata.Pairs(rejectingMdKey, "true"))
_, err := s.client.Ping(ctx, &pb.PingRequest{Value: "foo"})
require.Error(s.T(), err, "Director should reject this RPC")
assert.Equal(s.T(), codes.PermissionDenied, status.Code(err))
@@ -236,15 +236,15 @@ func (s *ProxyHappySuite) SetupSuite() {
return nil, err
}
- md, ok := metadata.FromIncomingContext(ctx)
+ md, ok := grpc_metadata.FromIncomingContext(ctx)
if ok {
if _, exists := md[rejectingMdKey]; exists {
- return proxy.NewStreamParameters(proxy.Destination{Ctx: helper.IncomingToOutgoing(ctx), Msg: payload}, nil, nil, nil), status.Errorf(codes.PermissionDenied, "testing rejection")
+ return proxy.NewStreamParameters(proxy.Destination{Ctx: metadata.IncomingToOutgoing(ctx), Msg: payload}, nil, nil, nil), status.Errorf(codes.PermissionDenied, "testing rejection")
}
}
// Explicitly copy the metadata, otherwise the tests will fail.
- return proxy.NewStreamParameters(proxy.Destination{Ctx: helper.IncomingToOutgoing(ctx), Conn: s.connProxy2Server, Msg: payload}, nil, nil, nil), nil
+ return proxy.NewStreamParameters(proxy.Destination{Ctx: metadata.IncomingToOutgoing(ctx), Conn: s.connProxy2Server, Msg: payload}, nil, nil, nil), nil
}
// Setup backend server for test suite
diff --git a/internal/praefect/grpc-proxy/proxy/peeker_test.go b/internal/praefect/grpc-proxy/proxy/peeker_test.go
index 4e22de92a..4c3a62931 100644
--- a/internal/praefect/grpc-proxy/proxy/peeker_test.go
+++ b/internal/praefect/grpc-proxy/proxy/peeker_test.go
@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
"gitlab.com/gitlab-org/gitaly/v14/internal/praefect/grpc-proxy/proxy"
testservice "gitlab.com/gitlab-org/gitaly/v14/internal/praefect/grpc-proxy/testdata"
"gitlab.com/gitlab-org/gitaly/v14/internal/testhelper"
@@ -37,7 +37,7 @@ func TestStreamPeeking(t *testing.T) {
require.NoError(t, err)
require.True(t, proto.Equal(pingReqSent, peekedRequest), "expected to be the same")
- return proxy.NewStreamParameters(proxy.Destination{Ctx: helper.IncomingToOutgoing(ctx), Conn: backendCC, Msg: peekedMsg}, nil, nil, nil), nil
+ return proxy.NewStreamParameters(proxy.Destination{Ctx: metadata.IncomingToOutgoing(ctx), Conn: backendCC, Msg: peekedMsg}, nil, nil, nil), nil
}
pingResp := &testservice.PingResponse{
@@ -100,7 +100,7 @@ func TestStreamInjecting(t *testing.T) {
newPayload, err := proto.Marshal(peekedRequest)
require.NoError(t, err)
- return proxy.NewStreamParameters(proxy.Destination{Ctx: helper.IncomingToOutgoing(ctx), Conn: backendCC, Msg: newPayload}, nil, nil, nil), nil
+ return proxy.NewStreamParameters(proxy.Destination{Ctx: metadata.IncomingToOutgoing(ctx), Conn: backendCC, Msg: newPayload}, nil, nil, nil), nil
}
pingResp := &testservice.PingResponse{
diff --git a/internal/testhelper/featureset_test.go b/internal/testhelper/featureset_test.go
index 443756ad1..2d1872203 100644
--- a/internal/testhelper/featureset_test.go
+++ b/internal/testhelper/featureset_test.go
@@ -5,9 +5,9 @@ import (
"testing"
"github.com/stretchr/testify/require"
- "gitlab.com/gitlab-org/gitaly/v14/internal/helper"
+ "gitlab.com/gitlab-org/gitaly/v14/internal/metadata"
ff "gitlab.com/gitlab-org/gitaly/v14/internal/metadata/featureflag"
- "google.golang.org/grpc/metadata"
+ grpc_metadata "google.golang.org/grpc/metadata"
)
var (
@@ -155,14 +155,14 @@ func TestFeatureSets_Run(t *testing.T) {
NewFeatureSets([]ff.FeatureFlag{
featureFlagB, featureFlagA,
}).Run(t, func(t *testing.T, ctx context.Context) {
- incomingMD, ok := metadata.FromIncomingContext(ctx)
+ incomingMD, ok := grpc_metadata.FromIncomingContext(ctx)
require.True(t, ok)
- outgoingMD, ok := metadata.FromOutgoingContext(ctx)
+ outgoingMD, ok := grpc_metadata.FromOutgoingContext(ctx)
require.True(t, ok)
- incomingCtx := metadata.NewIncomingContext(context.Background(), incomingMD)
- outgoingCtx := helper.OutgoingToIncoming(metadata.NewOutgoingContext(context.Background(), outgoingMD))
+ incomingCtx := grpc_metadata.NewIncomingContext(context.Background(), incomingMD)
+ outgoingCtx := metadata.OutgoingToIncoming(grpc_metadata.NewOutgoingContext(context.Background(), outgoingMD))
incomingFlags = append(incomingFlags, [2]bool{
featureFlagB.IsDisabled(incomingCtx),