@@ -160,7 +160,7 @@ func (s *Source) newClient() (*gitlab.Client, error) {
160
160
func (s * Source ) getAllProjects (apiClient * gitlab.Client ) ([]* gitlab.Project , error ) {
161
161
// projects without repo will get user projects, groups projects, and subgroup projects.
162
162
user , _ , err := apiClient .Users .CurrentUser ()
163
- //TODO what happens if the user is anonymous
163
+
164
164
if err != nil {
165
165
return nil , errors .Errorf ("unable to authenticate using: %s" , s .authMethod )
166
166
}
@@ -173,7 +173,7 @@ func (s *Source) getAllProjects(apiClient *gitlab.Client) ([]*gitlab.Project, er
173
173
for {
174
174
userProjects , res , err := apiClient .Projects .ListUserProjects (user .ID , projectQueryOptions )
175
175
if err != nil {
176
- return nil , errors .Errorf ("received error on listing projects: %s\n " , err )
176
+ return nil , errors .Errorf ("received error on listing user projects: %s\n " , err )
177
177
}
178
178
for _ , prj := range userProjects {
179
179
projects [prj .ID ] = prj
@@ -197,7 +197,7 @@ func (s *Source) getAllProjects(apiClient *gitlab.Client) ([]*gitlab.Project, er
197
197
for {
198
198
groupList , res , err := apiClient .Groups .ListGroups (& listGroupsOptions )
199
199
if err != nil {
200
- return nil , errors .Errorf ("received error on listing projects : %s\n " , err )
200
+ return nil , errors .Errorf ("received error on listing groups, you probably don't have permissions to do that : %s\n " , err )
201
201
}
202
202
groups = append (groups , groupList ... )
203
203
listGroupsOptions .Page = res .NextPage
@@ -214,7 +214,8 @@ func (s *Source) getAllProjects(apiClient *gitlab.Client) ([]*gitlab.Project, er
214
214
for {
215
215
grpPrjs , res , err := apiClient .Groups .ListGroupProjects (group .ID , listGroupProjectOptions )
216
216
if err != nil {
217
- return nil , errors .Errorf ("received error on listing projects: %s\n " , err )
217
+ log .WithError (err ).WithField ("group" , group .FullPath ).Warn ("received error on listing group projects, you probably don't have permissions to do that" )
218
+ break
218
219
}
219
220
for _ , prj := range grpPrjs {
220
221
projects [prj .ID ] = prj
0 commit comments