Inventory: fix tests
This commit is contained in:
@@ -93,7 +93,6 @@ let
|
|||||||
roleServiceConfigs = builtins.map (
|
roleServiceConfigs = builtins.map (
|
||||||
role: serviceConfig.roles.${role}.config or { }
|
role: serviceConfig.roles.${role}.config or { }
|
||||||
) inverseRoles.${machineName} or [ ];
|
) inverseRoles.${machineName} or [ ];
|
||||||
dbg = v: lib.traceSeq v v;
|
|
||||||
|
|
||||||
customImports = map (s: "${directory}/${s}") (
|
customImports = map (s: "${directory}/${s}") (
|
||||||
globalImports ++ machineImports ++ roleServiceImports
|
globalImports ++ machineImports ++ roleServiceImports
|
||||||
@@ -104,7 +103,7 @@ let
|
|||||||
acc2
|
acc2
|
||||||
++ [
|
++ [
|
||||||
{
|
{
|
||||||
imports = dbg ([ clan-core.clanModules.${moduleName} ] ++ roleModules ++ customImports);
|
imports = [ clan-core.clanModules.${moduleName} ] ++ roleModules ++ customImports;
|
||||||
config.clan.${moduleName} = lib.mkMerge (
|
config.clan.${moduleName} = lib.mkMerge (
|
||||||
[
|
[
|
||||||
globalConfig
|
globalConfig
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ let
|
|||||||
importsOption = lib.mkOption {
|
importsOption = lib.mkOption {
|
||||||
default = [ ];
|
default = [ ];
|
||||||
type = t.listOf t.str;
|
type = t.listOf t.str;
|
||||||
# apply = map (pathOrString: "${pathOrString}");
|
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,25 +2,31 @@
|
|||||||
{
|
{
|
||||||
test_inventory_empty = {
|
test_inventory_empty = {
|
||||||
# Empty inventory should return an empty module
|
# Empty inventory should return an empty module
|
||||||
expr = buildInventory { };
|
expr = buildInventory {
|
||||||
|
inventory = { };
|
||||||
|
directory = ./.;
|
||||||
|
};
|
||||||
expected = { };
|
expected = { };
|
||||||
};
|
};
|
||||||
test_inventory_role_imports =
|
test_inventory_role_imports =
|
||||||
let
|
let
|
||||||
configs = buildInventory {
|
configs = buildInventory {
|
||||||
services = {
|
directory = ./.;
|
||||||
borgbackup.instance_1 = {
|
inventory = {
|
||||||
roles.server.machines = [ "backup_server" ];
|
services = {
|
||||||
roles.client.machines = [
|
borgbackup.instance_1 = {
|
||||||
"client_1_machine"
|
roles.server.machines = [ "backup_server" ];
|
||||||
"client_2_machine"
|
roles.client.machines = [
|
||||||
];
|
"client_1_machine"
|
||||||
|
"client_2_machine"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
machines = {
|
||||||
|
"backup_server" = { };
|
||||||
|
"client_1_machine" = { };
|
||||||
|
"client_2_machine" = { };
|
||||||
};
|
};
|
||||||
};
|
|
||||||
machines = {
|
|
||||||
"backup_server" = { };
|
|
||||||
"client_1_machine" = { };
|
|
||||||
"client_2_machine" = { };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@@ -49,18 +55,21 @@
|
|||||||
test_inventory_tag_resolve =
|
test_inventory_tag_resolve =
|
||||||
let
|
let
|
||||||
configs = buildInventory {
|
configs = buildInventory {
|
||||||
services = {
|
directory = ./.;
|
||||||
borgbackup.instance_1 = {
|
inventory = {
|
||||||
roles.client.tags = [ "backup" ];
|
services = {
|
||||||
|
borgbackup.instance_1 = {
|
||||||
|
roles.client.tags = [ "backup" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
machines = {
|
||||||
machines = {
|
"not_used_machine" = { };
|
||||||
"not_used_machine" = { };
|
"client_1_machine" = {
|
||||||
"client_1_machine" = {
|
tags = [ "backup" ];
|
||||||
tags = [ "backup" ];
|
};
|
||||||
};
|
"client_2_machine" = {
|
||||||
"client_2_machine" = {
|
tags = [ "backup" ];
|
||||||
tags = [ "backup" ];
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -85,14 +94,17 @@
|
|||||||
test_inventory_multiple_roles =
|
test_inventory_multiple_roles =
|
||||||
let
|
let
|
||||||
configs = buildInventory {
|
configs = buildInventory {
|
||||||
services = {
|
directory = ./.;
|
||||||
borgbackup.instance_1 = {
|
inventory = {
|
||||||
roles.client.machines = [ "machine_1" ];
|
services = {
|
||||||
roles.server.machines = [ "machine_1" ];
|
borgbackup.instance_1 = {
|
||||||
|
roles.client.machines = [ "machine_1" ];
|
||||||
|
roles.server.machines = [ "machine_1" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
machines = {
|
||||||
|
"machine_1" = { };
|
||||||
};
|
};
|
||||||
};
|
|
||||||
machines = {
|
|
||||||
"machine_1" = { };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@@ -112,13 +124,16 @@
|
|||||||
test_inventory_role_doesnt_exist =
|
test_inventory_role_doesnt_exist =
|
||||||
let
|
let
|
||||||
configs = buildInventory {
|
configs = buildInventory {
|
||||||
services = {
|
directory = ./.;
|
||||||
borgbackup.instance_1 = {
|
inventory = {
|
||||||
roles.roleXYZ.machines = [ "machine_1" ];
|
services = {
|
||||||
|
borgbackup.instance_1 = {
|
||||||
|
roles.roleXYZ.machines = [ "machine_1" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
machines = {
|
||||||
|
"machine_1" = { };
|
||||||
};
|
};
|
||||||
};
|
|
||||||
machines = {
|
|
||||||
"machine_1" = { };
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
@@ -132,15 +147,18 @@
|
|||||||
test_inventory_tag_doesnt_exist =
|
test_inventory_tag_doesnt_exist =
|
||||||
let
|
let
|
||||||
configs = buildInventory {
|
configs = buildInventory {
|
||||||
services = {
|
directory = ./.;
|
||||||
borgbackup.instance_1 = {
|
inventory = {
|
||||||
roles.client.machines = [ "machine_1" ];
|
services = {
|
||||||
roles.client.tags = [ "tagXYZ" ];
|
borgbackup.instance_1 = {
|
||||||
|
roles.client.machines = [ "machine_1" ];
|
||||||
|
roles.client.tags = [ "tagXYZ" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
machines = {
|
||||||
machines = {
|
"machine_1" = {
|
||||||
"machine_1" = {
|
tags = [ "tagABC" ];
|
||||||
tags = [ "tagABC" ];
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user