Skip to content

Commit 676e0f0

Browse files
committed
fix gitlab client issues
1 parent 924b57b commit 676e0f0

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
1111
### Fixed
1212
### Security
1313

14+
## [1.2.2] - DATE
15+
### Added
16+
### Changed
17+
### Deprecated
18+
### Removed
19+
### Fixed
20+
- GitLab client; thanks @awesomebytes
21+
### Security
22+
1423
## [1.2.1] - 03/02/20
1524
### Added
1625
### Changed

cmd/clone_gitlab.go

+16-11
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ import (
1111

1212
func getGitLabOrgCloneUrls() ([]Repo, error) {
1313
repoData := []Repo{}
14-
client := gitlab.NewClient(nil, os.Getenv("GHORG_GITLAB_TOKEN"))
14+
client, err := determineClient()
1515

16-
baseURL := os.Getenv("GHORG_SCM_BASE_URL")
17-
18-
if baseURL != "" {
19-
client.SetBaseURL(baseURL)
16+
if err != nil {
17+
colorlog.PrintError(err)
2018
}
2119

2220
namespace := os.Getenv("GHORG_GITLAB_DEFAULT_NAMESPACE")
@@ -86,18 +84,25 @@ func getGitLabOrgCloneUrls() ([]Repo, error) {
8684
return repoData, nil
8785
}
8886

89-
// func getUsersUID(username string) int {
87+
func determineClient() (*gitlab.Client, error) {
88+
baseURL := os.Getenv("GHORG_SCM_BASE_URL")
89+
token := os.Getenv("GHORG_GITLAB_TOKEN")
90+
91+
if baseURL != "" {
92+
client, err := gitlab.NewClient(token, gitlab.WithBaseURL(baseURL))
93+
return client, err
94+
}
9095

91-
// }
96+
return gitlab.NewClient(token)
97+
}
9298

9399
func getGitLabUserCloneUrls() ([]Repo, error) {
94100
cloneData := []Repo{}
95-
client := gitlab.NewClient(nil, os.Getenv("GHORG_GITLAB_TOKEN"))
96101

97-
baseURL := os.Getenv("GHORG_SCM_BASE_URL")
102+
client, err := determineClient()
98103

99-
if baseURL != "" {
100-
client.SetBaseURL(baseURL)
104+
if err != nil {
105+
colorlog.PrintError(err)
101106
}
102107

103108
opt := &gitlab.ListProjectsOptions{

cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ var versionCmd = &cobra.Command{
1515
Short: "Print the version number of Ghorg",
1616
Long: `All software has versions. This is Ghorg's`,
1717
Run: func(cmd *cobra.Command, args []string) {
18-
fmt.Println("1.2.1")
18+
fmt.Println("1.2.2")
1919
},
2020
}

0 commit comments

Comments
 (0)