Skip to content

Commit 9831a48

Browse files
committed
support org service
1 parent 1716c40 commit 9831a48

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

libs/spec/providers.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,6 @@ func (v VCSProviderBasic) GetPrService(vcsSpec VcsSpec) (ci.PullRequestService,
186186
return nil, fmt.Errorf("failed to get github service: GITHUB_TOKEN not specified")
187187
}
188188
return github.GithubServiceProviderBasic{}.NewService(token, vcsSpec.RepoName, vcsSpec.RepoOwner)
189-
case "gitlab":
190-
token := os.Getenv("GITLAB_TOKEN")
191-
if token == "" {
192-
return nil, fmt.Errorf("failed to get gitlab service: GITLAB_TOKEN not specified")
193-
}
194-
context, err := gitlab.ParseGitLabContext()
195-
if err != nil {
196-
return nil, fmt.Errorf("failed to get gitlab service, could not parse context: %v", err)
197-
}
198-
return gitlab.NewGitLabService(token, context, "")
199189
case "bitbucket":
200190
token := os.Getenv("DIGGER_BITBUCKET_ACCESS_TOKEN")
201191
if token == "" {
@@ -207,6 +197,16 @@ func (v VCSProviderBasic) GetPrService(vcsSpec VcsSpec) (ci.PullRequestService,
207197
RepoWorkspace: vcsSpec.RepoOwner,
208198
RepoName: vcsSpec.RepoName,
209199
}, nil
200+
case "gitlab":
201+
token := os.Getenv("GITLAB_TOKEN")
202+
if token == "" {
203+
return nil, fmt.Errorf("failed to get gitlab service: GITLAB_TOKEN not specified")
204+
}
205+
context, err := gitlab.ParseGitLabContext()
206+
if err != nil {
207+
return nil, fmt.Errorf("failed to get gitlab service, could not parse context: %v", err)
208+
}
209+
return gitlab.NewGitLabService(token, context, "")
210210

211211
default:
212212
return nil, fmt.Errorf("could not get PRService, unknown type %v", vcsSpec.VcsType)
@@ -223,6 +223,17 @@ func (v VCSProviderBasic) GetOrgService(vcsSpec VcsSpec) (ci.OrgService, error)
223223
return nil, fmt.Errorf("failed to get github service: GITHUB_TOKEN not specified")
224224
}
225225
return github.GithubServiceProviderBasic{}.NewService(token, vcsSpec.RepoName, vcsSpec.RepoOwner)
226+
case "bitbucket":
227+
token := os.Getenv("DIGGER_BITBUCKET_ACCESS_TOKEN")
228+
if token == "" {
229+
return nil, fmt.Errorf("failed to get bitbucket service: GITLAB_TOKEN not specified")
230+
}
231+
return bitbucket.BitbucketAPI{
232+
AuthToken: token,
233+
HttpClient: http.Client{},
234+
RepoWorkspace: vcsSpec.RepoOwner,
235+
RepoName: vcsSpec.RepoName,
236+
}, nil
226237
case "gitlab":
227238
token := os.Getenv("GITLAB_TOKEN")
228239
if token == "" {

0 commit comments

Comments
 (0)