inventory: remove role.settings

Within a clan.service the module can access 'role.peer.settings' and 'role.peer.machine.jon.settings'
While the current machine is jon, accessing the role settings is arguably a design mistake.
I didn't catch that problem, unfortunately this might be a breaking change
This commit is contained in:
Johannes Kirschbauer
2025-10-19 16:43:21 +02:00
parent afcc5d9e26
commit 4442cb2fe0
3 changed files with 16 additions and 26 deletions

View File

@@ -97,11 +97,6 @@ let
inherit (v) settings; inherit (v) settings;
}).config; }).config;
}) role.machines; }) role.machines;
settings =
(evalMachineSettings {
inherit roleName instanceName;
inherit (role) settings;
}).config;
}) instance.roles; }) instance.roles;
in in
{ {
@@ -446,15 +441,12 @@ in
}; };
# ... # ...
}; };
settings = {
timeout = 30;
};
}; };
# ... # ...
}; };
``` ```
- `settings`: The settings of the role, as defined in `instances` - `settings`: The settings of the current machine, as defined in `instances`
```nix ```nix
{ {
timeout = 30; timeout = 30;

View File

@@ -123,9 +123,6 @@ in
}; };
expected = { expected = {
instanceName = "instance_foo"; instanceName = "instance_foo";
settings = {
timeout = "foo-peer-jon";
};
machine = { machine = {
name = "jon"; name = "jon";
roles = [ roles = [
@@ -137,12 +134,9 @@ in
controller = { controller = {
machines = { machines = {
jon = { jon = {
settings = { settings = { };
};
}; };
}; };
settings = {
};
}; };
peer = { peer = {
machines = { machines = {
@@ -152,11 +146,11 @@ in
}; };
}; };
}; };
settings = {
timeout = "foo-peer";
};
}; };
}; };
settings = {
timeout = "foo-peer-jon";
};
}; };
}; };

View File

@@ -70,8 +70,6 @@ let
roles.peer.tags.all = { }; roles.peer.tags.all = { };
}; };
}; };
filterInternals = lib.filterAttrs (n: _v: !lib.hasPrefix "_" n);
in in
{ {
@@ -89,7 +87,8 @@ in
# instance = instance_foo # instance = instance_foo
# roles = peer # roles = peer
# machines = jon # machines = jon
specificMachineSettings = filterInternals res.importedModulesEvaluated.self-A.result.allMachines.jon.passthru.instances.instance_foo.roles.peer.machines.jon.settings; specificMachineSettings =
res.importedModulesEvaluated.self-A.result.allMachines.jon.passthru.instances.instance_foo.roles.peer.machines.jon.settings;
hasRoleSettings = hasRoleSettings =
res.importedModulesEvaluated.self-A.result.allMachines.jon.passthru.instances.instance_foo.roles.peer res.importedModulesEvaluated.self-A.result.allMachines.jon.passthru.instances.instance_foo.roles.peer
@@ -100,16 +99,21 @@ in
# instance = instance_foo # instance = instance_foo
# roles = peer # roles = peer
# machines = * # machines = *
specificRoleSettings = filterInternals res.importedModulesEvaluated.self-A.result.allMachines.jon.passthru.instances.instance_foo.roles.peer.settings; specificRoleSettings =
res.importedModulesEvaluated.self-A.result.allMachines.jon.passthru.instances.instance_foo.roles.peer;
}; };
expected = { expected = rec {
hasMachineSettings = true; hasMachineSettings = true;
hasRoleSettings = false;
specificMachineSettings = { specificMachineSettings = {
timeout = "foo-peer-jon"; timeout = "foo-peer-jon";
}; };
hasRoleSettings = true;
specificRoleSettings = { specificRoleSettings = {
timeout = "foo-peer"; machines = {
jon = {
settings = specificMachineSettings;
};
};
}; };
}; };
}; };