From 93a20641d51bef355ce41d7d362b5d12d91b68da Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Thu, 14 Jan 2021 11:37:22 +0100 Subject: [PATCH] hooks: Override the user agent to Gitaly GitLab-Shell provides Gitaly with the client to connect to GitLab-Rails. This sets the user agent for the HTTP requests to `GitLab-Shell`, and thus Gitaly isn't easy to spot in logs. This change sets the Gitaly version string as user agent, which than also allows to differentiate versions during deploys. --- .../unreleased/zj-set-user-agent-hook-api-calls.yml | 5 +++++ go.mod | 4 ++-- go.sum | 8 ++++---- internal/gitaly/hook/access.go | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 changelogs/unreleased/zj-set-user-agent-hook-api-calls.yml diff --git a/changelogs/unreleased/zj-set-user-agent-hook-api-calls.yml b/changelogs/unreleased/zj-set-user-agent-hook-api-calls.yml new file mode 100644 index 00000000000..a88051781f6 --- /dev/null +++ b/changelogs/unreleased/zj-set-user-agent-hook-api-calls.yml @@ -0,0 +1,5 @@ +--- +title: 'hooks: Override the user agent to Gitaly' +merge_request: 3008 +author: +type: changed diff --git a/go.mod b/go.mod index fd3064e5b13..eb73c5a163c 100644 --- a/go.mod +++ b/go.mod @@ -37,11 +37,11 @@ require ( github.com/stretchr/testify v1.6.1 github.com/uber/jaeger-client-go v2.15.0+incompatible gitlab.com/gitlab-org/gitlab-shell v1.9.8-0.20201117050822-3f9890ef73dc - gitlab.com/gitlab-org/labkit v1.0.0 + gitlab.com/gitlab-org/labkit v1.3.0 golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 - golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 + golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 golang.org/x/text v0.3.3 // indirect google.golang.org/grpc v1.29.1 gopkg.in/yaml.v2 v2.3.0 // indirect diff --git a/go.sum b/go.sum index 60e64d9e85c..30b20075d94 100644 --- a/go.sum +++ b/go.sum @@ -463,8 +463,8 @@ gitlab.com/gitlab-org/labkit v0.0.0-20190221122536-0c3fc7cdd57c/go.mod h1:rYhLgf gitlab.com/gitlab-org/labkit v0.0.0-20190221122536-0c3fc7cdd57c/go.mod h1:rYhLgfrbEcyfinG+R3EvKu6bZSsmwQqcXzLfHWSfUKM= gitlab.com/gitlab-org/labkit v0.0.0-20200908084045-45895e129029 h1:L7b9YLsU3zBfTShAPl4fjhgFdfSvuo9tu4VobJdcKDs= gitlab.com/gitlab-org/labkit v0.0.0-20200908084045-45895e129029/go.mod h1:SNfxkfUwVNECgtmluVayv0GWFgEjjBs5AzgsowPQuo0= -gitlab.com/gitlab-org/labkit v1.0.0 h1:t2Wr8ygtvHfXAMlCkoEdk5pdb5Gy1IYdr41H7t4kAYw= -gitlab.com/gitlab-org/labkit v1.0.0/go.mod h1:nohrYTSLDnZix0ebXZrbZJjymRar8HeV2roWL5/jw2U= +gitlab.com/gitlab-org/labkit v1.3.0 h1:PDP4id5YEvw6juWrGE88LcTtEridtRAOyvNvUOtcc9o= +gitlab.com/gitlab-org/labkit v1.3.0/go.mod h1:nohrYTSLDnZix0ebXZrbZJjymRar8HeV2roWL5/jw2U= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2 h1:75k/FF0Q2YM8QYo07VPddOLBslDt1MZOdEslOHvmzAs= @@ -589,8 +589,8 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f h1:6Sc1XOXTulBN6imkqo6XoAXDEzoQ4/ro6xy7Vn8+rOM= golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78 h1:nVuTkr9L6Bq62qpUqKo/RnZCFfzDBL0bYo6w9OJUqZY= +golang.org/x/sys v0.0.0-20210113181707-4bcb84eeeb78/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= diff --git a/internal/gitaly/hook/access.go b/internal/gitaly/hook/access.go index adb95702820..70e4ec4a4ae 100644 --- a/internal/gitaly/hook/access.go +++ b/internal/gitaly/hook/access.go @@ -136,6 +136,7 @@ func NewGitlabAPI(gitlabCfg config.Gitlab, tlsCfg config.TLS) (GitlabAPI, error) if err != nil { return nil, err } + client.SetUserAgent(version.GetVersion()) return &gitlabAPI{client: client}, nil } -- GitLab