move extraConfig into configurator
extraConfig can be only set once. By moving it to the configurator we allow users to set this option themself.
This commit is contained in:
parent
dd6eacc4c4
commit
cbe4ce0571
|
@ -750,6 +750,7 @@ class NixConfigurator(ConfiguratorBase):
|
||||||
nix_eval_max_memory_size: int,
|
nix_eval_max_memory_size: int,
|
||||||
nix_workers_secret_name: str = "buildbot-nix-workers",
|
nix_workers_secret_name: str = "buildbot-nix-workers",
|
||||||
outputs_path: str | None = None,
|
outputs_path: str | None = None,
|
||||||
|
prometheus_exporter_port: int | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.nix_workers_secret_name = nix_workers_secret_name
|
self.nix_workers_secret_name = nix_workers_secret_name
|
||||||
|
@ -763,6 +764,7 @@ class NixConfigurator(ConfiguratorBase):
|
||||||
self.outputs_path = None
|
self.outputs_path = None
|
||||||
else:
|
else:
|
||||||
self.outputs_path = Path(outputs_path)
|
self.outputs_path = Path(outputs_path)
|
||||||
|
self.prometheus_exporter_port = prometheus_exporter_port
|
||||||
|
|
||||||
def configure(self, config: dict[str, Any]) -> None:
|
def configure(self, config: dict[str, Any]) -> None:
|
||||||
projects = load_projects(self.github.token(), self.github.project_cache_file)
|
projects = load_projects(self.github.token(), self.github.project_cache_file)
|
||||||
|
@ -839,13 +841,20 @@ class NixConfigurator(ConfiguratorBase):
|
||||||
context=Interpolate("buildbot/%(prop:status_name)s"),
|
context=Interpolate("buildbot/%(prop:status_name)s"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if self.prometheus_exporter_port:
|
||||||
|
config["services"].append(
|
||||||
|
reporters.Prometheus(port=self.prometheus_exporter_port)
|
||||||
|
)
|
||||||
|
|
||||||
systemd_secrets = secrets.SecretInAFile(
|
systemd_secrets = secrets.SecretInAFile(
|
||||||
dirname=os.environ["CREDENTIALS_DIRECTORY"]
|
dirname=os.environ["CREDENTIALS_DIRECTORY"]
|
||||||
)
|
)
|
||||||
config["secretsProviders"].append(systemd_secrets)
|
config["secretsProviders"].append(systemd_secrets)
|
||||||
config["www"]["change_hook_dialects"] = config["www"].get(
|
|
||||||
"change_hook_dialects", {}
|
config["www"].setdefault("plugins", {})
|
||||||
)
|
config["www"]["plugins"].update(dict(base_react={}))
|
||||||
|
|
||||||
|
config["www"].setdefault("change_hook_dialects", {})
|
||||||
config["www"]["change_hook_dialects"]["github"] = {
|
config["www"]["change_hook_dialects"]["github"] = {
|
||||||
"secret": webhook_secret,
|
"secret": webhook_secret,
|
||||||
"strict": True,
|
"strict": True,
|
||||||
|
@ -853,8 +862,8 @@ class NixConfigurator(ConfiguratorBase):
|
||||||
"github_property_whitelist": "*",
|
"github_property_whitelist": "*",
|
||||||
}
|
}
|
||||||
|
|
||||||
if not config["www"].get("auth"):
|
if "auth" not in config["www"]:
|
||||||
config["www"]["avatar_methods"] = config["www"].get("avatar_methods", [])
|
config["www"].setdefault("avatar_methods", [])
|
||||||
config["www"]["avatar_methods"].append(
|
config["www"]["avatar_methods"].append(
|
||||||
util.AvatarGitHub(token=self.github.token())
|
util.AvatarGitHub(token=self.github.token())
|
||||||
)
|
)
|
||||||
|
|
|
@ -126,15 +126,6 @@ in
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from buildbot_nix import GithubConfig, NixConfigurator
|
from buildbot_nix import GithubConfig, NixConfigurator
|
||||||
'';
|
'';
|
||||||
extraConfig = ''
|
|
||||||
c["www"]["plugins"] = c["www"].get("plugins", {})
|
|
||||||
c["www"]["plugins"].update(
|
|
||||||
dict(base_react={})
|
|
||||||
)
|
|
||||||
${lib.optionalString (cfg.prometheusExporterPort != null) ''
|
|
||||||
c['services'].append(reporters.Prometheus(port=${builtins.toString cfg.prometheusExporterPort}))
|
|
||||||
''}
|
|
||||||
'';
|
|
||||||
configurators = [
|
configurators = [
|
||||||
''
|
''
|
||||||
util.JanitorConfigurator(logHorizon=timedelta(weeks=4), hour=12, dayOfWeek=6)
|
util.JanitorConfigurator(logHorizon=timedelta(weeks=4), hour=12, dayOfWeek=6)
|
||||||
|
@ -152,6 +143,7 @@ in
|
||||||
nix_eval_worker_count=${builtins.toJSON cfg.evalWorkerCount},
|
nix_eval_worker_count=${builtins.toJSON cfg.evalWorkerCount},
|
||||||
nix_supported_systems=${builtins.toJSON cfg.buildSystems},
|
nix_supported_systems=${builtins.toJSON cfg.buildSystems},
|
||||||
outputs_path=${if cfg.outputsPath == null then "None" else builtins.toJSON cfg.outputsPath},
|
outputs_path=${if cfg.outputsPath == null then "None" else builtins.toJSON cfg.outputsPath},
|
||||||
|
prometheus_exporter_port=${if cfg.prometheusExporterPort == null then "None" else builtins.toJSON cfg.prometheusExporterPort},
|
||||||
)
|
)
|
||||||
''
|
''
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue