mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 22:29:06 +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
|
|
@ -38,11 +38,21 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
assertions =
|
assertions =
|
||||||
config.sops.secrets
|
(
|
||||||
|> lib.attrNames
|
config.sops.secrets
|
||||||
|> lib.map (secretPath: {
|
|> lib.attrNames
|
||||||
assertion = cfg.secrets |> lib.hasAttrByPath (secretPath |> lib.splitString "/");
|
|> lib.map (secretPath: {
|
||||||
message = "Sops secret `${secretPath}` must be defined in secrets.json";
|
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";
|
||||||
|
})
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,21 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
assertions =
|
assertions =
|
||||||
config.sops.secrets
|
(
|
||||||
|> lib.attrNames
|
config.sops.secrets
|
||||||
|> lib.map (secretPath: {
|
|> lib.attrNames
|
||||||
assertion = cfg.secrets |> lib.hasAttrByPath (secretPath |> lib.splitString "/");
|
|> lib.map (secretPath: {
|
||||||
message = "Sops secret `${secretPath}` must be defined in secrets.json";
|
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