Inventory: warning on undefined tags, instead of error.
This commit is contained in:
committed by
hsjobeki
parent
037549ba38
commit
85d03f106b
@@ -28,10 +28,10 @@ let
|
||||
);
|
||||
in
|
||||
if tagMembers == [ ] then
|
||||
throw ''
|
||||
lib.warn ''
|
||||
inventory.services.${serviceName}.${instanceName}: - ${roleName} tags: no machine with tag '${tag}' found.
|
||||
Available tags: ${builtins.toJSON (lib.unique availableTags)}
|
||||
''
|
||||
'' []
|
||||
else
|
||||
acc ++ tagMembers
|
||||
) [ ] members.tags or [ ]);
|
||||
|
||||
@@ -42,7 +42,7 @@ in
|
||||
checks = {
|
||||
lib-inventory-eval = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
||||
export HOME="$(realpath .)"
|
||||
|
||||
export NIX_ABORT_ON_WARN=1
|
||||
nix-unit --eval-store "$HOME" \
|
||||
--extra-experimental-features flakes \
|
||||
${inputOverrides} \
|
||||
|
||||
@@ -178,6 +178,8 @@ in
|
||||
msg = "Roles roleXYZ are not defined in the service borgbackup.";
|
||||
};
|
||||
};
|
||||
# Needs NIX_ABORT_ON_WARN=1
|
||||
# So the lib.warn is turned into abort
|
||||
test_inventory_tag_doesnt_exist =
|
||||
let
|
||||
configs = buildInventory {
|
||||
@@ -201,8 +203,9 @@ in
|
||||
{
|
||||
expr = configs;
|
||||
expectedError = {
|
||||
type = "ThrownError";
|
||||
msg = "no machine with tag '\\w+' found";
|
||||
type = "Error";
|
||||
# TODO: Add warning matching in nix-unit
|
||||
msg = ".*";
|
||||
};
|
||||
};
|
||||
test_inventory_disabled_service =
|
||||
|
||||
Reference in New Issue
Block a user