diff options
author | Michael Muré <batolettre@gmail.com> | 2019-12-10 21:13:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-10 21:13:54 +0100 |
commit | e96d8e6771086e20639a16abf6af30f2faa006a0 (patch) | |
tree | 606c0d2897c06e4ca226d377917437c62fdd1560 /bridge/gitlab/gitlab.go | |
parent | ef6801a37f75fbc5f65b0a5db194b7f88b439e7b (diff) | |
parent | f6b4830c0b68f3b5c616236bc9d51943765c8b4a (diff) | |
download | git-bug-e96d8e6771086e20639a16abf6af30f2faa006a0.tar.gz |
Merge pull request #274 from MichaelMure/gitlab-bridge
bridge/gitlab: support self-hosted GitLab instance
Diffstat (limited to 'bridge/gitlab/gitlab.go')
-rw-r--r-- | bridge/gitlab/gitlab.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bridge/gitlab/gitlab.go b/bridge/gitlab/gitlab.go index bcc50e4c..9298dc8e 100644 --- a/bridge/gitlab/gitlab.go +++ b/bridge/gitlab/gitlab.go @@ -17,9 +17,12 @@ const ( metaKeyGitlabUrl = "gitlab-url" metaKeyGitlabLogin = "gitlab-login" metaKeyGitlabProject = "gitlab-project-id" + metaKeyGitlabBaseUrl = "gitlab-base-url" - keyProjectID = "project-id" + keyProjectID = "project-id" + keyGitlabBaseUrl = "base-url" + defaultBaseURL = "https://gitlab.com/" defaultTimeout = 60 * time.Second ) @@ -37,10 +40,16 @@ func (*Gitlab) NewExporter() core.Exporter { return &gitlabExporter{} } -func buildClient(token *auth.Token) *gitlab.Client { - client := &http.Client{ +func buildClient(baseURL string, token *auth.Token) (*gitlab.Client, error) { + httpClient := &http.Client{ Timeout: defaultTimeout, } - return gitlab.NewClient(client, token.Value) + gitlabClient := gitlab.NewClient(httpClient, token.Value) + err := gitlabClient.SetBaseURL(baseURL) + if err != nil { + return nil, err + } + + return gitlabClient, nil } |