Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Wiedler <iwiedler@gitlab.com>2020-04-29 20:03:29 +0300
committerIgor Wiedler <iwiedler@gitlab.com>2020-04-29 20:03:29 +0300
commit245060539bcca5e6d52f38bee1c9d23a516911d3 (patch)
tree98ee5b05c787b7157798579c582efa84d4f2d2e7
parentddabe70ff60e44bc0b072138f019a6d6b0b411c7 (diff)
introduce separate config flag internal-gitlab-server
-rw-r--r--app_config.go3
-rw-r--r--internal/source/gitlab/client/client.go2
-rw-r--r--main.go11
3 files changed, 14 insertions, 2 deletions
diff --git a/app_config.go b/app_config.go
index 245a9e0d..44e37f13 100644
--- a/app_config.go
+++ b/app_config.go
@@ -29,6 +29,7 @@ type appConfig struct {
StoreSecret string
GitLabServer string
+ InternalGitLabServer string
GitLabAPISecretKey []byte
GitlabClientHTTPTimeout time.Duration
GitlabJWTTokenExpiration time.Duration
@@ -42,7 +43,7 @@ type appConfig struct {
// GitlabServerURL returns URL to a GitLab instance.
func (config appConfig) GitlabServerURL() string {
- return config.GitLabServer
+ return config.InternalGitLabServer
}
// GitlabClientSecret returns GitLab server access token.
diff --git a/internal/source/gitlab/client/client.go b/internal/source/gitlab/client/client.go
index afe9da6f..9a5affa2 100644
--- a/internal/source/gitlab/client/client.go
+++ b/internal/source/gitlab/client/client.go
@@ -27,7 +27,7 @@ type Client struct {
}
// NewClient initializes and returns new Client baseUrl is
-// appConfig.GitLabServer secretKey is appConfig.GitLabAPISecretKey
+// appConfig.InternalGitLabServer secretKey is appConfig.GitLabAPISecretKey
func NewClient(baseURL string, secretKey []byte, connectionTimeout, jwtTokenExpiry time.Duration) (*Client, error) {
if len(baseURL) == 0 || len(secretKey) == 0 {
return nil, errors.New("GitLab API URL or API secret has not been provided")
diff --git a/main.go b/main.go
index 9a316c5e..dfd9bf44 100644
--- a/main.go
+++ b/main.go
@@ -61,6 +61,7 @@ var (
secret = flag.String("auth-secret", "", "Cookie store hash key, should be at least 32 bytes long.")
gitLabAuthServer = flag.String("auth-server", "", "DEPRECATED, use gitlab-server instead. GitLab server, for example https://www.gitlab.com")
gitLabServer = flag.String("gitlab-server", "", "GitLab server, for example https://www.gitlab.com")
+ internalGitLabServer = flag.String("internal-gitlab-server", "", "Internal GitLab server for API requests, for example https://www.gitlab.com (defaults to value of gitlab-server)")
gitLabAPISecretKey = flag.String("api-secret-key", "", "File with secret key used to authenticate with the GitLab API")
gitlabClientHTTPTimeout = flag.Duration("gitlab-client-http-timeout", 10*time.Second, "GitLab API HTTP client connection timeout in seconds (default: 10s)")
gitlabClientJWTExpiry = flag.Duration("gitlab-client-jwt-expiry", 30*time.Second, "JWT Token expiry time in seconds (default: 30s)")
@@ -107,6 +108,14 @@ func gitlabServerFromFlags() string {
return host.FromString(url.Host)
}
+func internalGitlabServerFromFlags() string {
+ if *internalGitLabServer != "" {
+ return *internalGitLabServer
+ }
+
+ return gitlabServerFromFlags()
+}
+
func setArtifactsServer(artifactsServer string, artifactsServerTimeout int, config *appConfig) {
u, err := url.Parse(artifactsServer)
if err != nil {
@@ -181,6 +190,7 @@ func configFromFlags() appConfig {
}
config.GitLabServer = gitlabServerFromFlags()
+ config.InternalGitLabServer = internalGitlabServerFromFlags()
config.GitlabClientHTTPTimeout = *gitlabClientHTTPTimeout
config.GitlabJWTTokenExpiration = *gitlabClientJWTExpiry
config.StoreSecret = *secret
@@ -265,6 +275,7 @@ func loadConfig() appConfig {
"tls-max-version": *tlsMaxVersion,
"use-http-2": config.HTTP2,
"gitlab-server": config.GitLabServer,
+ "internal-gitlab-server": config.InternalGitLabServer,
"api-secret-key": *gitLabAPISecretKey,
"auth-redirect-uri": config.RedirectURI,
}).Debug("Start daemon with configuration")