@@ -418,7 +418,11 @@ def get_repo_token(self, repo_full_name: str) -> RepoToken:
418
418
return self .installation_tokens [installation_id ]
419
419
420
420
def create_secret_providers (self ) -> list [SecretProviderBase ]:
421
- return [GitHubAppSecretService (self .installation_tokens , self .jwt_token )]
421
+ return [
422
+ GitHubAppSecretService (
423
+ self .project_id_map , self .installation_tokens , self .jwt_token
424
+ )
425
+ ]
422
426
423
427
def create_reporter (self ) -> ReporterBase :
424
428
def get_github_token (props : Properties ) -> str :
@@ -465,12 +469,17 @@ def create_reload_builder_steps(
465
469
466
470
class GitHubAppSecretService (SecretProviderBase ):
467
471
name : str | None = "GitHubAppSecretService" # type: ignore[assignment]
472
+ project_id_map : dict [str , int ]
468
473
installation_tokens : dict [int , InstallationToken ]
469
474
jwt_token : JWTToken
470
475
471
476
def reconfigService ( # type: ignore[override]
472
- self , installation_tokens : dict [int , InstallationToken ], jwt_token : JWTToken
477
+ self ,
478
+ project_id_map : dict [str , int ],
479
+ installation_tokens : dict [int , InstallationToken ],
480
+ jwt_token : JWTToken ,
473
481
) -> None :
482
+ self .project_id_map = project_id_map
474
483
self .installation_tokens = installation_tokens
475
484
self .jwt_token = jwt_token
476
485
@@ -479,9 +488,14 @@ def get(self, entry: str) -> str | None:
479
488
get the value from the file identified by 'entry'
480
489
"""
481
490
if entry .startswith ("github-token-" ):
482
- return self .installation_tokens [
483
- int (entry .removeprefix ("github-token-" ))
484
- ].get ()
491
+ try :
492
+ return self .installation_tokens [
493
+ int (entry .removeprefix ("github-token-" ))
494
+ ].get ()
495
+ except ValueError :
496
+ return self .installation_tokens [
497
+ self .project_id_map [entry .removeprefix ("github-token-" )]
498
+ ].get ()
485
499
if entry == "github-jwt-token" :
486
500
return self .jwt_token .get ()
487
501
return None
0 commit comments