summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2020-08-17 22:19:56 -0700
committerStan Hu <stanhu@gmail.com>2020-08-20 16:54:36 -0700
commiteb3b35b9b0cc55fb8464d9b0662e6b94aafc54cc (patch)
treef25886b6a225f108c67c423dcbe13f027d4a18c1 /internal
parentfa730d2f859671f54c6f88bf2551fc771a1a5e6a (diff)
downloadgitlab-shell-sh-fix-unix-relative-url-access.tar.gz
Fix gitlab-shell not handling relative URLs over UNIX socketssh-fix-unix-relative-url-access
From https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/4498#note_397401883, if you specify a relative path such as: ``` external_url 'http://gitlab.example.com/gitlab' ``` gitlab-shell doesn't have a way to pass the `/gitlab` to the host. For example, let's say we have: ``` gitlab_url: "http+unix://%2Fvar%2Fopt%2Fgitlab%2Fgitlab-workhorse%2Fsocket" ``` If we have `/gitlab` as the relative path, how do we specify what is the UNIX socket path and what is the relative path? If we specify: ``` gitlab_url: "http+unix:///var/opt/gitlab/gitlab-workhorse.socket/gitlab ``` This is ambiguous. Is the socket in `/var/opt/gitlab/gitlab-workhorse.socket/gitlab` or in `/var/opt/gitlab/gitlab-workhorse.socket`? To fix this, this merge request adds an optional `gitlab_relative_url_root` config parameter: ``` gitlab_url: "http+unix://%2Fvar%2Fopt%2Fgitlab%2Fgitlab-workhorse%2Fsocket" gitlab_relative_url_root: /gitlab ``` This is only used with UNIX domain sockets to disambiguate the socket and base URL path. If `gitlab_url` uses `http://` or `https://`, then `gitlab_relative_url_root` is ignored. Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/476
Diffstat (limited to 'internal')
-rw-r--r--internal/config/config.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index be9efa3..e7abd59 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -27,16 +27,17 @@ type HttpSettingsConfig struct {
}
type Config struct {
- RootDir string
- LogFile string `yaml:"log_file"`
- LogFormat string `yaml:"log_format"`
- GitlabUrl string `yaml:"gitlab_url"`
- GitlabTracing string `yaml:"gitlab_tracing"`
- SecretFilePath string `yaml:"secret_file"`
- Secret string `yaml:"secret"`
- SslCertDir string `yaml:"ssl_cert_dir"`
- HttpSettings HttpSettingsConfig `yaml:"http_settings"`
- HttpClient *client.HttpClient
+ RootDir string
+ LogFile string `yaml:"log_file"`
+ LogFormat string `yaml:"log_format"`
+ GitlabUrl string `yaml:"gitlab_url"`
+ GitlabRelativeURLRoot string `yaml:"gitlab_relative_url_root"`
+ GitlabTracing string `yaml:"gitlab_tracing"`
+ SecretFilePath string `yaml:"secret_file"`
+ Secret string `yaml:"secret"`
+ SslCertDir string `yaml:"ssl_cert_dir"`
+ HttpSettings HttpSettingsConfig `yaml:"http_settings"`
+ HttpClient *client.HttpClient
}
func (c *Config) GetHttpClient() *client.HttpClient {
@@ -46,6 +47,7 @@ func (c *Config) GetHttpClient() *client.HttpClient {
client := client.NewHTTPClient(
c.GitlabUrl,
+ c.GitlabRelativeURLRoot,
c.HttpSettings.CaFile,
c.HttpSettings.CaPath,
c.HttpSettings.SelfSignedCert,