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
|
in
|
||||||
if tagMembers == [ ] then
|
if tagMembers == [ ] then
|
||||||
throw ''
|
lib.warn ''
|
||||||
inventory.services.${serviceName}.${instanceName}: - ${roleName} tags: no machine with tag '${tag}' found.
|
inventory.services.${serviceName}.${instanceName}: - ${roleName} tags: no machine with tag '${tag}' found.
|
||||||
Available tags: ${builtins.toJSON (lib.unique availableTags)}
|
Available tags: ${builtins.toJSON (lib.unique availableTags)}
|
||||||
''
|
'' []
|
||||||
else
|
else
|
||||||
acc ++ tagMembers
|
acc ++ tagMembers
|
||||||
) [ ] members.tags or [ ]);
|
) [ ] members.tags or [ ]);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ in
|
|||||||
checks = {
|
checks = {
|
||||||
lib-inventory-eval = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
lib-inventory-eval = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
||||||
export HOME="$(realpath .)"
|
export HOME="$(realpath .)"
|
||||||
|
export NIX_ABORT_ON_WARN=1
|
||||||
nix-unit --eval-store "$HOME" \
|
nix-unit --eval-store "$HOME" \
|
||||||
--extra-experimental-features flakes \
|
--extra-experimental-features flakes \
|
||||||
${inputOverrides} \
|
${inputOverrides} \
|
||||||
|
|||||||
@@ -178,6 +178,8 @@ in
|
|||||||
msg = "Roles roleXYZ are not defined in the service borgbackup.";
|
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 =
|
test_inventory_tag_doesnt_exist =
|
||||||
let
|
let
|
||||||
configs = buildInventory {
|
configs = buildInventory {
|
||||||
@@ -201,8 +203,9 @@ in
|
|||||||
{
|
{
|
||||||
expr = configs;
|
expr = configs;
|
||||||
expectedError = {
|
expectedError = {
|
||||||
type = "ThrownError";
|
type = "Error";
|
||||||
msg = "no machine with tag '\\w+' found";
|
# TODO: Add warning matching in nix-unit
|
||||||
|
msg = ".*";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
test_inventory_disabled_service =
|
test_inventory_disabled_service =
|
||||||
|
|||||||
Reference in New Issue
Block a user