fix(gerrit): make buildbot able to read the priv ssh key

Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
raito 2024-07-17 16:49:03 +02:00
parent 4e5f0cb44b
commit a473100d29
2 changed files with 6 additions and 4 deletions

View file

@ -599,13 +599,14 @@ def nix_build_config(
def read_secret_file(secret_name: str) -> str:
return assemble_secret_file_path(secret_name).read_text().rstrip()
def assemble_secret_file_path(secret_name: str) -> Path:
directory = os.environ.get("CREDENTIALS_DIRECTORY")
if directory is None:
print("directory not set", file=sys.stderr)
sys.exit(1)
return Path(directory).joinpath(secret_name).read_text().rstrip()
return Path(directory).joinpath(secret_name)
def config_for_project(
config: dict[str, Any],

View file

@ -209,7 +209,7 @@ in
"${cfg.gerrit.domain}",
"${cfg.gerrit.username}",
"${toString cfg.gerrit.port}",
"${cfg.gerrit.privateKeyFile}",
assemble_secret_file_path('buildbot-service-private-key'),
projects=${builtins.toJSON cfg.gerrit.projects},
allowed_origins=${builtins.toJSON cfg.allowedOrigins},
url=${builtins.toJSON config.services.buildbot-master.buildbotUrl},
@ -269,6 +269,7 @@ in
LoadCredential = [
"buildbot-nix-workers:${cfg.workersFile}"
"buildbot-oauth2-secret:${cfg.oauth2.clientSecretFile}"
"buildbot-service-private-key:${cfg.gerrit.privateKeyFile}"
];
};
};