-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package vcs | ||
|
||
import ( | ||
"fmt" | ||
github2 "github.com/diggerhq/digger/ee/cli/pkg/github" | ||
"github.com/diggerhq/digger/libs/ci" | ||
"github.com/diggerhq/digger/libs/ci/gitlab" | ||
"github.com/diggerhq/digger/libs/spec" | ||
"os" | ||
) | ||
|
||
type VCSProviderAdvanced struct{} | ||
|
||
func (v VCSProviderAdvanced) GetPrService(vcsSpec spec.VcsSpec) (ci.PullRequestService, error) { | ||
switch vcsSpec.VcsType { | ||
case "github": | ||
token := os.Getenv("GITHUB_TOKEN") | ||
if token == "" { | ||
return nil, fmt.Errorf("failed to get github service: GITHUB_TOKEN not specified") | ||
} | ||
return github2.GithubServiceProviderAdvanced{}.NewService(token, vcsSpec.RepoName, vcsSpec.RepoOwner) | ||
case "gitlab": | ||
token := os.Getenv("GITLAB_TOKEN") | ||
if token == "" { | ||
return nil, fmt.Errorf("failed to get gitlab service: GITLAB_TOKEN not specified") | ||
} | ||
context, err := gitlab.ParseGitLabContext() | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get gitlab service, could not parse context: %v", err) | ||
} | ||
baseUrl := os.Getenv("DIGGER_GITLAB_BASE_URL") | ||
return gitlab.NewGitLabService(token, context, baseUrl) | ||
default: | ||
return nil, fmt.Errorf("could not get PRService, unknown type %v", vcsSpec.VcsType) | ||
} | ||
} | ||
|
||
func (v VCSProviderAdvanced) GetOrgService(vcsSpec spec.VcsSpec) (ci.OrgService, error) { | ||
switch vcsSpec.VcsType { | ||
case "gitlab": | ||
token := os.Getenv("GITLAB_TOKEN") | ||
if token == "" { | ||
return nil, fmt.Errorf("failed to get gitlab service: GITLAB_TOKEN not specified") | ||
} | ||
context, err := gitlab.ParseGitLabContext() | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get gitlab service, could not parse context: %v", err) | ||
} | ||
baseUrl := os.Getenv("DIGGER_GITLAB_BASE_URL") | ||
return gitlab.NewGitLabService(token, context, baseUrl) | ||
default: | ||
return nil, fmt.Errorf("could not get PRService, unknown type %v", vcsSpec.VcsType) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters