Skip to content

Commit

Permalink
feat(gitlab): option to change base-url for gitlab (#69)
Browse files Browse the repository at this point in the history
This also changes the gh-base-url flag to base-url
  • Loading branch information
mareksimunek authored Feb 16, 2021
1 parent 7a32bb6 commit 147ebe6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func init() {
func platformFlags() *flag.FlagSet {
flags := flag.NewFlagSet("platform", flag.ExitOnError)

flags.StringP("gh-base-url", "g", "", "Base URL of the (v3) GitHub API, needs to be changed if GitHub enterprise is used.")
flags.StringP("base-url", "g", "", "Base URL of the (v3) GitHub API, needs to be changed if GitHub enterprise is used. Or self-managed gitlab url (https://gitlab.my-company.com)")
flags.StringP("token", "T", "", "The GitHub/GitLab personal access token. Can also be set using the GITHUB_TOKEN/GITLAB_TOKEN environment variable.")

flags.StringSliceP("org", "O", nil, "The name of a GitHub organization. All repositories in that organization will be used.")
Expand Down Expand Up @@ -135,7 +135,7 @@ func getVersionController(flag *flag.FlagSet) (multigitter.VersionController, er
}

func createGithubClient(flag *flag.FlagSet) (multigitter.VersionController, error) {
ghBaseURL, _ := flag.GetString("gh-base-url")
gitBaseURL, _ := flag.GetString("base-url")
orgs, _ := flag.GetStringSlice("org")
users, _ := flag.GetStringSlice("user")
repos, _ := flag.GetStringSlice("repo")
Expand Down Expand Up @@ -167,7 +167,7 @@ func createGithubClient(flag *flag.FlagSet) (multigitter.VersionController, erro
}
}

vc, err := github.New(token, ghBaseURL, github.RepositoryListing{
vc, err := github.New(token, gitBaseURL, github.RepositoryListing{
Organizations: orgs,
Users: users,
Repositories: repoRefs,
Expand All @@ -180,6 +180,7 @@ func createGithubClient(flag *flag.FlagSet) (multigitter.VersionController, erro
}

func createGitlabClient(flag *flag.FlagSet) (multigitter.VersionController, error) {
gitBaseURL, _ := flag.GetString("base-url")
groups, _ := flag.GetStringSlice("group")
users, _ := flag.GetStringSlice("user")
projects, _ := flag.GetStringSlice("project")
Expand All @@ -197,7 +198,7 @@ func createGitlabClient(flag *flag.FlagSet) (multigitter.VersionController, erro
}
}

vc, err := gitlab.New(token, "", gitlab.RepositoryListing{
vc, err := gitlab.New(token, gitBaseURL, gitlab.RepositoryListing{
Groups: groups,
Users: users,
Projects: projRefs,
Expand Down

0 comments on commit 147ebe6

Please sign in to comment.