mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 16:39:07 +01:00
sops: Add assertion to validate that all secrets are actually used
This commit is contained in:
parent
1fc79bee5c
commit
3af7d23a46
2 changed files with 32 additions and 12 deletions
|
|
@ -36,11 +36,21 @@ in
|
|||
};
|
||||
|
||||
assertions =
|
||||
config.sops.secrets
|
||||
|> lib.attrNames
|
||||
|> lib.map (secretPath: {
|
||||
assertion = cfg.secrets |> lib.hasAttrByPath (secretPath |> lib.splitString "/");
|
||||
message = "Sops secret `${secretPath}` must be defined in secrets.json";
|
||||
});
|
||||
(
|
||||
config.sops.secrets
|
||||
|> lib.attrNames
|
||||
|> lib.map (secretPath: {
|
||||
assertion = cfg.secrets |> lib.hasAttrByPath (secretPath |> lib.splitString "/");
|
||||
message = "Sops secret `${secretPath}` is used in a module but not defined in secrets.json";
|
||||
})
|
||||
)
|
||||
++ (
|
||||
lib.removeAttrs cfg.secrets [ "sops" ]
|
||||
|> lib.mapAttrsToListRecursive (path: _: path |> lib.concatStringsSep "/")
|
||||
|> lib.map (secretPath: {
|
||||
assertion = config.sops.secrets |> lib.hasAttr secretPath;
|
||||
message = "Sops secret `${secretPath}` is defined in secrets.json but not used in any module";
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue