fix(gerrit): make buildbot able to read the priv ssh key
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
4e5f0cb44b
commit
8a1b11f8b1
|
@ -597,15 +597,15 @@ def nix_build_config(
|
||||||
factory=factory,
|
factory=factory,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def assemble_secret_file_path(secret_name: str) -> Path:
|
||||||
def read_secret_file(secret_name: str) -> str:
|
|
||||||
directory = os.environ.get("CREDENTIALS_DIRECTORY")
|
directory = os.environ.get("CREDENTIALS_DIRECTORY")
|
||||||
if directory is None:
|
if directory is None:
|
||||||
print("directory not set", file=sys.stderr)
|
print("directory not set", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
return Path(directory).joinpath(secret_name).read_text().rstrip()
|
return Path(directory).joinpath(secret_name)
|
||||||
|
|
||||||
|
|
||||||
|
def read_secret_file(secret_name: str) -> str:
|
||||||
|
return assemble_secret_file_path(secret_name).read_text().rstrip()
|
||||||
|
|
||||||
def config_for_project(
|
def config_for_project(
|
||||||
config: dict[str, Any],
|
config: dict[str, Any],
|
||||||
|
|
|
@ -188,7 +188,7 @@ in
|
||||||
home = "/var/lib/buildbot";
|
home = "/var/lib/buildbot";
|
||||||
extraImports = ''
|
extraImports = ''
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from buildbot_nix import GerritNixConfigurator, read_secret_file, make_oauth2_method, OAuth2Config
|
from buildbot_nix import GerritNixConfigurator, read_secret_file, make_oauth2_method, OAuth2Config, assemble_secret_file_path
|
||||||
|
|
||||||
# TODO(raito): make me configurable from the NixOS module.
|
# TODO(raito): make me configurable from the NixOS module.
|
||||||
# how?
|
# how?
|
||||||
|
@ -209,7 +209,7 @@ in
|
||||||
"${cfg.gerrit.domain}",
|
"${cfg.gerrit.domain}",
|
||||||
"${cfg.gerrit.username}",
|
"${cfg.gerrit.username}",
|
||||||
"${toString cfg.gerrit.port}",
|
"${toString cfg.gerrit.port}",
|
||||||
"${cfg.gerrit.privateKeyFile}",
|
assemble_secret_file_path('buildbot-service-private-key'),
|
||||||
projects=${builtins.toJSON cfg.gerrit.projects},
|
projects=${builtins.toJSON cfg.gerrit.projects},
|
||||||
allowed_origins=${builtins.toJSON cfg.allowedOrigins},
|
allowed_origins=${builtins.toJSON cfg.allowedOrigins},
|
||||||
url=${builtins.toJSON config.services.buildbot-master.buildbotUrl},
|
url=${builtins.toJSON config.services.buildbot-master.buildbotUrl},
|
||||||
|
@ -269,6 +269,7 @@ in
|
||||||
LoadCredential = [
|
LoadCredential = [
|
||||||
"buildbot-nix-workers:${cfg.workersFile}"
|
"buildbot-nix-workers:${cfg.workersFile}"
|
||||||
"buildbot-oauth2-secret:${cfg.oauth2.clientSecretFile}"
|
"buildbot-oauth2-secret:${cfg.oauth2.clientSecretFile}"
|
||||||
|
"buildbot-service-private-key:${cfg.gerrit.privateKeyFile}"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue