diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2020-03-03 20:26:03 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2020-03-03 20:26:03 +0300 |
commit | 7f89a20fe54eda0fbdd75e78bf58548b87a71485 (patch) | |
tree | 83d48c02adc241923ec3763bd9287343afa3b683 | |
parent | 2c719dfeadf8c045ca49004801725c17f538c82e (diff) | |
parent | f38f37e13f8cef14a8552f24df0acc1d61ff2d9e (diff) |
Merge branch 'po-protocol-v2-ssh-log' into 'master'
Improve visibility of SSH Git wire protocol requests
See merge request gitlab-org/gitaly!1849
-rw-r--r-- | internal/git/protocol.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/internal/git/protocol.go b/internal/git/protocol.go index ba8f6609e..6b0541027 100644 --- a/internal/git/protocol.go +++ b/internal/git/protocol.go @@ -7,6 +7,7 @@ import ( grpc_ctxtags "github.com/grpc-ecosystem/go-grpc-middleware/tags" "github.com/prometheus/client_golang/prometheus" + "gitlab.com/gitlab-org/gitaly/internal/log" ) const ( @@ -36,11 +37,19 @@ type RequestWithGitProtocol interface { // AddGitProtocolEnv checks whether the request has Git protocol v2 // and sets this in the environment. func AddGitProtocolEnv(ctx context.Context, req RequestWithGitProtocol, env []string) []string { - protocol := "v0" + var protocol string - if req.GetGitProtocol() == ProtocolV2 { + switch gp := req.GetGitProtocol(); gp { + case ProtocolV2: env = append(env, fmt.Sprintf("GIT_PROTOCOL=%s", ProtocolV2)) protocol = "v2" + case "": + protocol = "v0" + default: + log.Default(). + WithField("git_protocol", gp). + Warn("invalid git protocol requested") + protocol = "invalid" } service, method := methodFromContext(ctx) |