victoriametrics & vmagent: Make the config check optional

This follows the pattern that AlertManager uses. Currently if you use
environment variables, the config check will fail.
This commit is contained in:
Mike Kusold
2025-06-25 08:55:34 -06:00
parent 78658c0cc9
commit 292073c5cc
2 changed files with 36 additions and 8 deletions
@@ -24,10 +24,13 @@ let
checkedConfig =
file:
pkgs.runCommand "checked-config" { nativeBuildInputs = [ cfg.package ]; } ''
ln -s ${file} $out
${lib.escapeShellArgs startCLIList} -promscrape.config=${file} -dryRun
'';
if cfg.checkConfig then
pkgs.runCommand "checked-config" { nativeBuildInputs = [ cfg.package ]; } ''
ln -s ${file} $out
${lib.escapeShellArgs startCLIList} -promscrape.config=${file} -dryRun
''
else
file;
in
{
options.services.victoriametrics = {
@@ -127,6 +130,17 @@ in
or {command}`victoriametrics -help` for more information.
'';
};
checkConfig = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Check configuration.
If you use credentials stored in external files (`environmentFile`, etc),
they will not be visible and it will report errors, despite a correct configuration.
'';
};
};
config = lib.mkIf cfg.enable {
+18 -4
View File
@@ -30,10 +30,13 @@ let
checkedConfig =
file:
pkgs.runCommand "checked-config" { nativeBuildInputs = [ cfg.package ]; } ''
ln -s ${file} $out
${lib.escapeShellArgs startCLIList} -promscrape.config=${file} -dryRun
'';
if cfg.checkConfig then
pkgs.runCommand "checked-config" { nativeBuildInputs = [ cfg.package ]; } ''
ln -s ${file} $out
${lib.escapeShellArgs startCLIList} -promscrape.config=${file} -dryRun
''
else
file;
in
{
imports = [
@@ -119,6 +122,17 @@ in
or {command}`vmagent -help` for more information.
'';
};
checkConfig = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Check configuration.
If you use credentials stored in external files (`environmentFile`, etc),
they will not be visible and it will report errors, despite a correct configuration.
'';
};
};
config = lib.mkIf cfg.enable {