summaryrefslogtreecommitdiff
path: root/internal/command
diff options
context:
space:
mode:
Diffstat (limited to 'internal/command')
-rw-r--r--internal/command/receivepack/gitalycall.go4
-rw-r--r--internal/command/receivepack/gitalycall_test.go7
-rw-r--r--internal/command/receivepack/receivepack.go2
-rw-r--r--internal/command/uploadarchive/gitalycall.go4
-rw-r--r--internal/command/uploadarchive/gitalycall_test.go6
-rw-r--r--internal/command/uploadarchive/uploadarchive.go2
-rw-r--r--internal/command/uploadpack/gitalycall.go4
-rw-r--r--internal/command/uploadpack/gitalycall_test.go5
-rw-r--r--internal/command/uploadpack/uploadpack.go2
9 files changed, 21 insertions, 15 deletions
diff --git a/internal/command/receivepack/gitalycall.go b/internal/command/receivepack/gitalycall.go
index 713f323..06e7b2c 100644
--- a/internal/command/receivepack/gitalycall.go
+++ b/internal/command/receivepack/gitalycall.go
@@ -12,7 +12,7 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/handler"
)
-func (c *Command) performGitalyCall(response *accessverifier.Response) error {
+func (c *Command) performGitalyCall(ctx context.Context, response *accessverifier.Response) error {
gc := &handler.GitalyCommand{
Config: c.Config,
ServiceName: string(commandargs.ReceivePack),
@@ -30,7 +30,7 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error {
GitConfigOptions: response.GitConfigOptions,
}
- return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
+ return gc.RunGitalyCommand(ctx, func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
ctx, cancel := gc.PrepareContext(ctx, request.Repository, response, c.Args.Env)
defer cancel()
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go
index 9a1019d..70f2b2e 100644
--- a/internal/command/receivepack/gitalycall_test.go
+++ b/internal/command/receivepack/gitalycall_test.go
@@ -6,8 +6,8 @@ import (
"testing"
"github.com/sirupsen/logrus"
-
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/labkit/correlation"
"gitlab.com/gitlab-org/gitlab-shell/client/testserver"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs"
@@ -61,8 +61,9 @@ func TestReceivePack(t *testing.T) {
}
hook := testhelper.SetupLogger()
+ ctx := correlation.ContextWithCorrelation(context.Background(), "a-correlation-id")
- err := cmd.Execute(context.Background())
+ err := cmd.Execute(ctx)
require.NoError(t, err)
if tc.username != "" {
@@ -80,6 +81,6 @@ func TestReceivePack(t *testing.T) {
require.Contains(t, entries[1].Message, "remote_ip=127.0.0.1")
require.Contains(t, entries[1].Message, "gl_key_type=key")
require.Contains(t, entries[1].Message, "gl_key_id=123")
- require.Contains(t, entries[1].Message, "correlation_id=")
+ require.Contains(t, entries[1].Message, "correlation_id=a-correlation-id")
}
}
diff --git a/internal/command/receivepack/receivepack.go b/internal/command/receivepack/receivepack.go
index 4d5c686..27e4b72 100644
--- a/internal/command/receivepack/receivepack.go
+++ b/internal/command/receivepack/receivepack.go
@@ -38,7 +38,7 @@ func (c *Command) Execute(ctx context.Context) error {
return customAction.Execute(ctx, response)
}
- return c.performGitalyCall(response)
+ return c.performGitalyCall(ctx, response)
}
func (c *Command) verifyAccess(ctx context.Context, repo string) (*accessverifier.Response, error) {
diff --git a/internal/command/uploadarchive/gitalycall.go b/internal/command/uploadarchive/gitalycall.go
index 05bb794..5b66bbb 100644
--- a/internal/command/uploadarchive/gitalycall.go
+++ b/internal/command/uploadarchive/gitalycall.go
@@ -12,7 +12,7 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/handler"
)
-func (c *Command) performGitalyCall(response *accessverifier.Response) error {
+func (c *Command) performGitalyCall(ctx context.Context, response *accessverifier.Response) error {
gc := &handler.GitalyCommand{
Config: c.Config,
ServiceName: string(commandargs.UploadArchive),
@@ -23,7 +23,7 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error {
request := &pb.SSHUploadArchiveRequest{Repository: &response.Gitaly.Repo}
- return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
+ return gc.RunGitalyCommand(ctx, func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
ctx, cancel := gc.PrepareContext(ctx, request.Repository, response, c.Args.Env)
defer cancel()
diff --git a/internal/command/uploadarchive/gitalycall_test.go b/internal/command/uploadarchive/gitalycall_test.go
index 03223e9..b89b749 100644
--- a/internal/command/uploadarchive/gitalycall_test.go
+++ b/internal/command/uploadarchive/gitalycall_test.go
@@ -6,8 +6,8 @@ import (
"testing"
"github.com/sirupsen/logrus"
-
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/labkit/correlation"
"gitlab.com/gitlab-org/gitlab-shell/client/testserver"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs"
@@ -36,8 +36,9 @@ func TestUploadPack(t *testing.T) {
}
hook := testhelper.SetupLogger()
+ ctx := correlation.ContextWithCorrelation(context.Background(), "a-correlation-id")
- err := cmd.Execute(context.Background())
+ err := cmd.Execute(ctx)
require.NoError(t, err)
require.Equal(t, "UploadArchive: "+repo, output.String())
@@ -50,4 +51,5 @@ func TestUploadPack(t *testing.T) {
require.Contains(t, entries[1].Message, "command=git-upload-archive")
require.Contains(t, entries[1].Message, "gl_key_type=key")
require.Contains(t, entries[1].Message, "gl_key_id=123")
+ require.Contains(t, entries[1].Message, "correlation_id=a-correlation-id")
}
diff --git a/internal/command/uploadarchive/uploadarchive.go b/internal/command/uploadarchive/uploadarchive.go
index 178b42b..3c86be3 100644
--- a/internal/command/uploadarchive/uploadarchive.go
+++ b/internal/command/uploadarchive/uploadarchive.go
@@ -28,7 +28,7 @@ func (c *Command) Execute(ctx context.Context) error {
return err
}
- return c.performGitalyCall(response)
+ return c.performGitalyCall(ctx, response)
}
func (c *Command) verifyAccess(ctx context.Context, repo string) (*accessverifier.Response, error) {
diff --git a/internal/command/uploadpack/gitalycall.go b/internal/command/uploadpack/gitalycall.go
index 5a8a605..a263fc4 100644
--- a/internal/command/uploadpack/gitalycall.go
+++ b/internal/command/uploadpack/gitalycall.go
@@ -12,7 +12,7 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/handler"
)
-func (c *Command) performGitalyCall(response *accessverifier.Response) error {
+func (c *Command) performGitalyCall(ctx context.Context, response *accessverifier.Response) error {
gc := &handler.GitalyCommand{
Config: c.Config,
ServiceName: string(commandargs.UploadPack),
@@ -27,7 +27,7 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error {
GitConfigOptions: response.GitConfigOptions,
}
- return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
+ return gc.RunGitalyCommand(ctx, func(ctx context.Context, conn *grpc.ClientConn) (int32, error) {
ctx, cancel := gc.PrepareContext(ctx, request.Repository, response, c.Args.Env)
defer cancel()
diff --git a/internal/command/uploadpack/gitalycall_test.go b/internal/command/uploadpack/gitalycall_test.go
index d945764..bedc6e6 100644
--- a/internal/command/uploadpack/gitalycall_test.go
+++ b/internal/command/uploadpack/gitalycall_test.go
@@ -7,6 +7,7 @@ import (
"time"
"github.com/stretchr/testify/require"
+ "gitlab.com/gitlab-org/labkit/correlation"
"gitlab.com/gitlab-org/gitlab-shell/client/testserver"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs"
@@ -35,8 +36,9 @@ func TestUploadPack(t *testing.T) {
}
hook := testhelper.SetupLogger()
+ ctx := correlation.ContextWithCorrelation(context.Background(), "a-correlation-id")
- err := cmd.Execute(context.Background())
+ err := cmd.Execute(ctx)
require.NoError(t, err)
require.Equal(t, "UploadPack: "+repo, output.String())
@@ -48,6 +50,7 @@ func TestUploadPack(t *testing.T) {
require.Contains(t, entries[1].Message, "command=git-upload-pack")
require.Contains(t, entries[1].Message, "gl_key_type=key")
require.Contains(t, entries[1].Message, "gl_key_id=123")
+ require.Contains(t, entries[1].Message, "correlation_id=a-correlation-id")
return true
}, time.Second, time.Millisecond)
diff --git a/internal/command/uploadpack/uploadpack.go b/internal/command/uploadpack/uploadpack.go
index fca3823..82e4d6e 100644
--- a/internal/command/uploadpack/uploadpack.go
+++ b/internal/command/uploadpack/uploadpack.go
@@ -38,7 +38,7 @@ func (c *Command) Execute(ctx context.Context) error {
return customAction.Execute(ctx, response)
}
- return c.performGitalyCall(response)
+ return c.performGitalyCall(ctx, response)
}
func (c *Command) verifyAccess(ctx context.Context, repo string) (*accessverifier.Response, error) {