From f6b4830c0b68f3b5c616236bc9d51943765c8b4a Mon Sep 17 00:00:00 2001 From: amine Date: Tue, 10 Dec 2019 20:30:29 +0100 Subject: bridge/gitlab: support self-hosted GitLab instance --- bridge/gitlab/gitlab.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'bridge/gitlab/gitlab.go') 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 } -- cgit