@@ -101,7 +101,7 @@ def scan_repository_contents_recursive(
101101def scan_repository_contents (
102102 github_client : GithubClient , repository : GithubRepository
103103) -> tuple [set [str ], dict [str , dict ]]:
104- repository_languages = list (respect_rate_limit (repository .get_languages , github_client ).keys ())
104+ repository_languages = list (respect_rate_limit (lambda : repository .get_languages () , github_client ).keys ())
105105 logger .info (f"{ repository .full_name } : Language(s) detected: { ', ' .join (repository_languages )} " )
106106
107107 language_analysers = get_language_analysers (repository_languages )
@@ -204,8 +204,8 @@ def scan_repositories(
204204def get_organisations_of_user (github_client : GithubClient ) -> set [GithubOrganisation ]:
205205 organisations_to_scan = set ()
206206
207- for repo in github_client .get_user ().get_repos ():
208- organisations_to_scan .add (repo )
207+ for org in github_client .get_user ().get_orgs ():
208+ organisations_to_scan .add (org )
209209
210210 return organisations_to_scan
211211
@@ -250,13 +250,17 @@ def scan_with_config(
250250
251251 # Get all of the repos belonging to users in the config
252252 for user , user_config in config .users .items ():
253- repositories_to_scan .update (respect_rate_limit (get_repositories_of_user (github_client , user , user_config )))
253+ repositories_to_scan .update (respect_rate_limit (
254+ lambda : get_repositories_of_user (github_client , user , user_config ),
255+ github_client
256+ ))
254257
255258 # Get all of the repos beloning to orgs in the config
256259 for organisation , organisation_config in config .organisations .items ():
257- repositories_to_scan .update (respect_rate_limit (get_repositories_of_organisation (
258- github_client , organisation , organisation_config
259- )))
260+ repositories_to_scan .update (respect_rate_limit (
261+ lambda : get_repositories_of_organisation (github_client , organisation , organisation_config ),
262+ github_client
263+ ))
260264
261265 # Filter out any repos which have been explicitly excluded
262266 repositories_to_scan = set (filter (lambda repo : not config .skip_repo (repo ), repositories_to_scan ))
@@ -287,7 +291,7 @@ def scan_with_config(
287291 return 0 , 0
288292
289293 return (
290- repositories_to_scan ,
294+ { respect_rate_limit ( lambda : repository . full_name , github_client ) for repository in repositories_to_scan } ,
291295 scan_repositories (github_client , firetail_app_token , firetail_api_url , repositories_to_scan )
292296 )
293297
@@ -297,17 +301,21 @@ def scan_without_config(
297301) -> tuple [set [GithubRepository ], int ]:
298302 github_client = github .Github (github_token )
299303
300- organisations_to_scan : set [GithubOrganisation ] = respect_rate_limit (get_organisations_of_user (github_client ))
304+ organisations_to_scan : set [GithubOrganisation ] = respect_rate_limit (
305+ lambda : get_organisations_of_user (github_client ),
306+ github_client
307+ )
301308
302309 repositories_to_scan = set ()
303310 for organisation in organisations_to_scan :
304311 logger .info (f"{ organisation .login } : Getting repositories..." )
305- repositories_to_scan .update (respect_rate_limit (get_repositories_of_organisation (
306- github_client , organisation .login , OrgConfig ()
307- )))
312+ repositories_to_scan .update (respect_rate_limit (
313+ lambda : get_repositories_of_organisation (github_client , organisation .login , OrgConfig ()),
314+ github_client
315+ ))
308316
309317 return (
310- repositories_to_scan ,
318+ { respect_rate_limit ( lambda : repository . full_name , github_client ) for repository in repositories_to_scan } ,
311319 scan_repositories (github_client , firetail_app_token , firetail_api_url , repositories_to_scan )
312320 )
313321
@@ -321,7 +329,7 @@ def scan() -> tuple[set[str], int]:
321329 for env_var_name , env_var_value in required_env_vars .items ():
322330 if env_var_value in {None , "" }:
323331 logger .critical (f"{ env_var_name } not set in environment. Cannot scan." )
324- return 0 , 0
332+ return set () , 0
325333
326334 config_dict = None
327335 try :
@@ -342,4 +350,4 @@ def scan() -> tuple[set[str], int]:
342350 GITHUB_TOKEN , FIRETAIL_APP_TOKEN , FIRETAIL_API_URL
343351 )
344352
345- return { repository . full_name for repository in repositories_scanned } , openapi_specs_discovered
353+ return repositories_scanned , openapi_specs_discovered
0 commit comments