@@ -11,12 +11,10 @@ import (
11
11
12
12
func getGitLabOrgCloneUrls () ([]Repo , error ) {
13
13
repoData := []Repo {}
14
- client := gitlab . NewClient ( nil , os . Getenv ( "GHORG_GITLAB_TOKEN" ) )
14
+ client , err := determineClient ( )
15
15
16
- baseURL := os .Getenv ("GHORG_SCM_BASE_URL" )
17
-
18
- if baseURL != "" {
19
- client .SetBaseURL (baseURL )
16
+ if err != nil {
17
+ colorlog .PrintError (err )
20
18
}
21
19
22
20
namespace := os .Getenv ("GHORG_GITLAB_DEFAULT_NAMESPACE" )
@@ -86,18 +84,25 @@ func getGitLabOrgCloneUrls() ([]Repo, error) {
86
84
return repoData , nil
87
85
}
88
86
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
+ }
90
95
91
- // }
96
+ return gitlab .NewClient (token )
97
+ }
92
98
93
99
func getGitLabUserCloneUrls () ([]Repo , error ) {
94
100
cloneData := []Repo {}
95
- client := gitlab .NewClient (nil , os .Getenv ("GHORG_GITLAB_TOKEN" ))
96
101
97
- baseURL := os . Getenv ( "GHORG_SCM_BASE_URL" )
102
+ client , err := determineClient ( )
98
103
99
- if baseURL != "" {
100
- client . SetBaseURL ( baseURL )
104
+ if err != nil {
105
+ colorlog . PrintError ( err )
101
106
}
102
107
103
108
opt := & gitlab.ListProjectsOptions {
0 commit comments