depot/ops/vault/cfg/policies-raw.nix

16 lines
508 B
Nix
Raw Permalink Normal View History

2022-03-14 23:34:33 +00:00
{ lib, ... }:
let
inherit (lib) hasSuffix filterAttrs removeSuffix attrNames nameValuePair mapToAttrs;
policiesFiles = builtins.readDir ./policies;
rawPolicies = attrNames (filterAttrs (filename: filetype: filetype == "regular" && hasSuffix ".hcl" filename) policiesFiles);
in {
resource.vault_policy = (mapToAttrs (filename: let
name = removeSuffix ".hcl" filename;
in nameValuePair name {
inherit name;
policy = builtins.readFile (./policies + "/${filename}");
}) rawPolicies);
}