Commit 29bdb29a authored by Andreas Fuchs's avatar Andreas Fuchs
Browse files

vmalert: Fail if encountering missing rule paths

Previously, when using toString for interpolating paths, the build process wouldn't attempt to copy the given path into the store; that would then result in hard-to-debug errors when running the vmalert service (it launches, but treats the missing as a non-issue, so you run with no alerting).

Instead, use string interpolation to resolve the file from the given path. This properly fails the build if a missing file is referenced.
parent 315fc655
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -25,14 +25,16 @@ let
    in
    attrsOf (either valueType (listOf valueType));

  mkCliVal = value: if isPath value then "${value}" else toString value;

  mkLine =
    key: value:
    if value == true then
      "-${key}"
    else if isList value then
      concatMapStringsSep " " (v: "-${key}=${escapeShellArg (toString v)}") value
      concatMapStringsSep " " (v: "-${key}=${escapeShellArg (mkCliVal v)}") value
    else
      "-${key}=${escapeShellArg (toString value)}";
      "-${key}=${escapeShellArg (mkCliVal value)}";

  vmalertName = name: "vmalert" + lib.optionalString (name != "") ("-" + name);
  enabledInstances = lib.filterAttrs (name: conf: conf.enable) config.services.vmalert.instances;