diff options
-rw-r--r-- | changelogs/unreleased/sh-support-gitlab-shell-relative-path.yml | 5 | ||||
-rw-r--r-- | config.toml.example | 3 | ||||
-rw-r--r-- | go.mod | 3 | ||||
-rw-r--r-- | go.sum | 6 | ||||
-rw-r--r-- | internal/config/config.go | 7 | ||||
-rw-r--r-- | internal/service/hook/access.go | 1 |
6 files changed, 16 insertions, 9 deletions
diff --git a/changelogs/unreleased/sh-support-gitlab-shell-relative-path.yml b/changelogs/unreleased/sh-support-gitlab-shell-relative-path.yml new file mode 100644 index 000000000..d8916b838 --- /dev/null +++ b/changelogs/unreleased/sh-support-gitlab-shell-relative-path.yml @@ -0,0 +1,5 @@ +--- +title: Fix Git hooks when GitLab relative URL path and UNIX socket in use +merge_request: 2485 +author: +type: fixed diff --git a/config.toml.example b/config.toml.example index 1332f6f9d..d0b2db3d1 100644 --- a/config.toml.example +++ b/config.toml.example @@ -93,6 +93,9 @@ custom_hooks_dir = "/home/git/custom_hooks" [gitlab] secret_file = "/home/git/gitlab-shell/.gitlab_shell_secret" url = "http+unix://%2Fhome%2Fgit%2Fgitlab%2Ftmp%2Fsockets%2Fgitlab-workhorse.socket" +# Only needed if a UNIX socket is used in `url` and GitLab is configured to +# use a relative path (e.g. /gitlab). +# relative_url_root = '/' [gitlab.http-settings] # read_timeout = 300 @@ -12,13 +12,12 @@ require ( github.com/kelseyhightower/envconfig v1.3.0 github.com/lib/pq v1.2.0 github.com/olekukonko/tablewriter v0.0.2 - github.com/otiai10/curr v1.0.0 // indirect github.com/prometheus/client_golang v1.0.0 github.com/prometheus/procfs v0.0.3 // indirect github.com/rubenv/sql-migrate v0.0.0-20191213152630-06338513c237 github.com/sirupsen/logrus v1.4.2 github.com/stretchr/testify v1.4.0 - gitlab.com/gitlab-org/gitlab-shell v1.9.8-0.20200506213341-716e30c55e89 + gitlab.com/gitlab-org/gitlab-shell v0.0.0-20200821152636-82ec8144fb2a gitlab.com/gitlab-org/labkit v0.0.0-20200507062444-0149780c759d golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e golang.org/x/sys v0.0.0-20200113162924-86b910548bc1 @@ -350,10 +350,8 @@ github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZ github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= gitlab.com/gitlab-org/gitaly v1.68.0/go.mod h1:/pCsB918Zu5wFchZ9hLYin9WkJ2yQqdVNz0zlv5HbXg= -gitlab.com/gitlab-org/gitlab-shell v1.9.8-0.20200506213341-716e30c55e89 h1:gZwXV5WLPmJ3NDmH+zAZkgWLVhgKvamGAjLXU5W0GiU= -gitlab.com/gitlab-org/gitlab-shell v1.9.8-0.20200506213341-716e30c55e89 h1:gZwXV5WLPmJ3NDmH+zAZkgWLVhgKvamGAjLXU5W0GiU= -gitlab.com/gitlab-org/gitlab-shell v1.9.8-0.20200506213341-716e30c55e89/go.mod h1:oUGdKtJHWQP4/VQ/NONJZy/8X2E5ow2eGTUDwdzvGsc= -gitlab.com/gitlab-org/gitlab-shell v1.9.8-0.20200506213341-716e30c55e89/go.mod h1:oUGdKtJHWQP4/VQ/NONJZy/8X2E5ow2eGTUDwdzvGsc= +gitlab.com/gitlab-org/gitlab-shell v0.0.0-20200821152636-82ec8144fb2a h1:MkoiKzWGRz2RCfDU6uFAO1vDLNZMSlyDWadL41nYjfw= +gitlab.com/gitlab-org/gitlab-shell v0.0.0-20200821152636-82ec8144fb2a/go.mod h1:RABblvnnhHpFU/lexlwGqpKgZsLV3RGA2D/Elp5/KEA= gitlab.com/gitlab-org/labkit v0.0.0-20190221122536-0c3fc7cdd57c/go.mod h1:rYhLgfrbEcyfinG+R3EvKu6bZSsmwQqcXzLfHWSfUKM= gitlab.com/gitlab-org/labkit v0.0.0-20190221122536-0c3fc7cdd57c/go.mod h1:rYhLgfrbEcyfinG+R3EvKu6bZSsmwQqcXzLfHWSfUKM= gitlab.com/gitlab-org/labkit v0.0.0-20200507062444-0149780c759d h1:Q5yZi+AelheHuvq/OK6DiaBzLU1AHrm7eWh88uE8Tsk= diff --git a/internal/config/config.go b/internal/config/config.go index c43d4b6a8..9837c993b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -64,9 +64,10 @@ type GitlabShell struct { // Gitlab contains settings required to connect to the Gitlab api type Gitlab struct { - URL string `toml:"url" json:"url"` - HTTPSettings HTTPSettings `toml:"http-settings" json:"http_settings"` - SecretFile string `toml:"secret_file" json:"secret_file"` + URL string `toml:"url" json:"url"` + RelativeURLRoot string `toml:"relative_url_root" json:"relative_url_root"` + HTTPSettings HTTPSettings `toml:"http-settings" json:"http_settings"` + SecretFile string `toml:"secret_file" json:"secret_file"` } // Hooks contains the settings required for hooks diff --git a/internal/service/hook/access.go b/internal/service/hook/access.go index 4b1793696..13d76e287 100644 --- a/internal/service/hook/access.go +++ b/internal/service/hook/access.go @@ -75,6 +75,7 @@ func NewGitlabAPI(gitlabCfg config.Gitlab) (GitlabAPI, error) { httpClient := client.NewHTTPClient( url, + gitlabCfg.RelativeURLRoot, gitlabCfg.HTTPSettings.CAFile, gitlabCfg.HTTPSettings.CAPath, gitlabCfg.HTTPSettings.SelfSigned, |