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/export.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'bridge/gitlab/export.go') diff --git a/bridge/gitlab/export.go b/bridge/gitlab/export.go index 373cf637..d42ef1cd 100644 --- a/bridge/gitlab/export.go +++ b/bridge/gitlab/export.go @@ -62,7 +62,11 @@ func (ge *gitlabExporter) cacheAllClient(repo repository.RepoConfig) error { for _, cred := range creds { if _, ok := ge.identityClient[cred.UserId()]; !ok { - client := buildClient(creds[0].(*auth.Token)) + client, err := buildClient(ge.conf[keyGitlabBaseUrl], creds[0].(*auth.Token)) + if err != nil { + return err + } + ge.identityClient[cred.UserId()] = client } } @@ -133,6 +137,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc var err error var bugGitlabID int var bugGitlabIDString string + var GitlabBaseUrl string var bugCreationId string // Special case: @@ -153,6 +158,12 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc // get gitlab bug ID gitlabID, ok := snapshot.GetCreateMetadata(metaKeyGitlabId) if ok { + gitlabBaseUrl, ok := snapshot.GetCreateMetadata(metaKeyGitlabBaseUrl) + if ok && gitlabBaseUrl != ge.conf[gitlabBaseUrl] { + out <- core.NewExportNothing(b.Id(), "skipping issue imported from another Gitlab instance") + return + } + projectID, ok := snapshot.GetCreateMetadata(metaKeyGitlabProject) if !ok { err := fmt.Errorf("expected to find gitlab project id") @@ -199,6 +210,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, sinc metaKeyGitlabId: idString, metaKeyGitlabUrl: url, metaKeyGitlabProject: ge.repositoryID, + metaKeyGitlabBaseUrl: GitlabBaseUrl, }, ) if err != nil { -- cgit