diff options
author | Nick Thomas <nick@gitlab.com> | 2021-03-16 15:25:44 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2021-03-16 15:25:44 +0000 |
commit | dc2bddcc325f224ba074cb4d67ecba44ed15daae (patch) | |
tree | 9c37f5ade4a95622b30a7a47befcb46b185b9682 /internal/handler/exec.go | |
parent | e79f115d93a9f00f3e4f8a22ec770fdf4c3e1947 (diff) | |
parent | d539068dc372e46d10adee89e9b96b59156a2bb6 (diff) | |
download | gitlab-shell-dc2bddcc325f224ba074cb4d67ecba44ed15daae.tar.gz |
Merge branch '496-move-env-introspection-to-sshenv' into 'main'
chore: Move environment introspection to sshenv module
See merge request gitlab-org/gitlab-shell!451
Diffstat (limited to 'internal/handler/exec.go')
-rw-r--r-- | internal/handler/exec.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/handler/exec.go b/internal/handler/exec.go index 5ead63e..ac59dab 100644 --- a/internal/handler/exec.go +++ b/internal/handler/exec.go @@ -61,10 +61,10 @@ func (gc *GitalyCommand) RunGitalyCommand(handler GitalyHandlerFunc) error { // PrepareContext wraps a given context with a correlation ID and logs the command to // be run. -func (gc *GitalyCommand) PrepareContext(ctx context.Context, repository *pb.Repository, response *accessverifier.Response, protocol string) (context.Context, context.CancelFunc) { +func (gc *GitalyCommand) PrepareContext(ctx context.Context, repository *pb.Repository, response *accessverifier.Response, env sshenv.Env) (context.Context, context.CancelFunc) { ctx, cancel := context.WithCancel(ctx) - gc.LogExecution(repository, response, protocol) + gc.LogExecution(repository, response, env) if response.CorrelationID != "" { ctx = correlation.ContextWithCorrelation(ctx, response.CorrelationID) @@ -78,13 +78,13 @@ func (gc *GitalyCommand) PrepareContext(ctx context.Context, repository *pb.Repo md.Append("key_type", response.KeyType) md.Append("user_id", response.UserId) md.Append("username", response.Username) - md.Append("remote_ip", sshenv.LocalAddr()) + md.Append("remote_ip", env.RemoteAddr) ctx = metadata.NewOutgoingContext(ctx, md) return ctx, cancel } -func (gc *GitalyCommand) LogExecution(repository *pb.Repository, response *accessverifier.Response, protocol string) { +func (gc *GitalyCommand) LogExecution(repository *pb.Repository, response *accessverifier.Response, env sshenv.Env) { fields := log.Fields{ "command": gc.ServiceName, "correlation_id": response.CorrelationID, @@ -92,8 +92,8 @@ func (gc *GitalyCommand) LogExecution(repository *pb.Repository, response *acces "gl_repository": repository.GlRepository, "user_id": response.UserId, "username": response.Username, - "git_protocol": protocol, - "remote_ip": sshenv.LocalAddr(), + "git_protocol": env.GitProtocolVersion, + "remote_ip": env.RemoteAddr, "gl_key_type": response.KeyType, "gl_key_id": response.KeyId, } |