Inventory: migrate failure test message
This commit is contained in:
@@ -7,7 +7,14 @@ let
|
|||||||
|
|
||||||
resolveTags =
|
resolveTags =
|
||||||
# Inventory, { machines :: [string], tags :: [string] }
|
# Inventory, { machines :: [string], tags :: [string] }
|
||||||
{ serviceName, instanceName, roleName, inventory, members}: {
|
{
|
||||||
|
serviceName,
|
||||||
|
instanceName,
|
||||||
|
roleName,
|
||||||
|
inventory,
|
||||||
|
members,
|
||||||
|
}:
|
||||||
|
{
|
||||||
machines =
|
machines =
|
||||||
members.machines or [ ]
|
members.machines or [ ]
|
||||||
++ (builtins.foldl' (
|
++ (builtins.foldl' (
|
||||||
@@ -25,7 +32,7 @@ let
|
|||||||
in
|
in
|
||||||
if tagMembers == [ ] then
|
if tagMembers == [ ] then
|
||||||
throw ''
|
throw ''
|
||||||
inventory.services.${serviceName}.${instanceName}: - ${roleName} tags: no machine with '${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
|
||||||
@@ -54,8 +61,15 @@ let
|
|||||||
acc2: instanceName: serviceConfig:
|
acc2: instanceName: serviceConfig:
|
||||||
let
|
let
|
||||||
resolvedRoles = builtins.mapAttrs (
|
resolvedRoles = builtins.mapAttrs (
|
||||||
roleName: members: resolveTags {
|
roleName: members:
|
||||||
inherit serviceName instanceName roleName inventory members;
|
resolveTags {
|
||||||
|
inherit
|
||||||
|
serviceName
|
||||||
|
instanceName
|
||||||
|
roleName
|
||||||
|
inventory
|
||||||
|
members
|
||||||
|
;
|
||||||
}
|
}
|
||||||
) serviceConfig.roles;
|
) serviceConfig.roles;
|
||||||
|
|
||||||
|
|||||||
@@ -14,13 +14,6 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
machineRef = lib.mkOptionType {
|
|
||||||
name = "str";
|
|
||||||
description = "Machine :: [${builtins.concatStringsSep " | " (builtins.attrNames config.machines)}]";
|
|
||||||
check = v: lib.isString v && builtins.elem v (builtins.attrNames config.machines);
|
|
||||||
merge = lib.mergeEqualOption;
|
|
||||||
};
|
|
||||||
|
|
||||||
moduleConfig = lib.mkOption {
|
moduleConfig = lib.mkOption {
|
||||||
default = { };
|
default = { };
|
||||||
type = types.attrsOf types.anything;
|
type = types.attrsOf types.anything;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@
|
|||||||
expr = configs;
|
expr = configs;
|
||||||
expectedError = {
|
expectedError = {
|
||||||
type = "ThrownError";
|
type = "ThrownError";
|
||||||
msg = "Tag: '\\w+' not found";
|
msg = "no machine with tag '\\w+' found";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user