From f1ec61c73087f08d76bc3f117dc169a30e5a13f6 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 26 Mar 2020 20:49:25 -0700 Subject: Log git-{upload-pack,receive-pack} requests This restores the previous Ruby gitlab-shell behavior. --- internal/command/receivepack/gitalycall.go | 12 ++++++++++++ internal/command/uploadpack/gitalycall.go | 12 ++++++++++++ 2 files changed, 24 insertions(+) (limited to 'internal/command') diff --git a/internal/command/receivepack/gitalycall.go b/internal/command/receivepack/gitalycall.go index 529b296..de41b25 100644 --- a/internal/command/receivepack/gitalycall.go +++ b/internal/command/receivepack/gitalycall.go @@ -6,6 +6,7 @@ import ( "google.golang.org/grpc" + log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/client" pb "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" @@ -31,6 +32,17 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error { GitConfigOptions: response.GitConfigOptions, } + fields := log.Fields{ + "command": "git-receive-pack", + "gl_project_path": request.Repository.GlProjectPath, + "gl_repository": request.Repository.GlRepository, + "user_id": response.UserId, + "username": response.Username, + "git_protocol": request.GitProtocol, + } + + log.WithFields(fields).Info("executing git command") + return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() diff --git a/internal/command/uploadpack/gitalycall.go b/internal/command/uploadpack/gitalycall.go index 26f87f8..c55ce55 100644 --- a/internal/command/uploadpack/gitalycall.go +++ b/internal/command/uploadpack/gitalycall.go @@ -6,6 +6,7 @@ import ( "google.golang.org/grpc" + log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/client" pb "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs" @@ -28,6 +29,17 @@ func (c *Command) performGitalyCall(response *accessverifier.Response) error { GitConfigOptions: response.GitConfigOptions, } + fields := log.Fields{ + "command": "git-upload-pack", + "gl_project_path": request.Repository.GlProjectPath, + "gl_repository": request.Repository.GlRepository, + "user_id": response.UserId, + "username": response.Username, + "git_protocol": request.GitProtocol, + } + + log.WithFields(fields).Info("executing git command") + return gc.RunGitalyCommand(func(ctx context.Context, conn *grpc.ClientConn) (int32, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() -- cgit v1.2.1