Introduce functions to generate yaml.
The toYAML function is just an alias to toJSON which is technically fine since YAML is a superset of JSON, but these new functions will generate actual YAML.
This commit is contained in:
parent
dcfbc0864e
commit
2c5acd15df
@ -9,12 +9,28 @@
|
|||||||
# distPhase
|
# distPhase
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
stdenv,
|
stdenv,
|
||||||
runCommand,
|
runCommand,
|
||||||
writeText,
|
writeText,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
to_yaml_file =
|
||||||
|
file_name: contents:
|
||||||
|
let
|
||||||
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
|
yaml_file = settingsFormat.generate file_name contents;
|
||||||
|
in
|
||||||
|
yaml_file;
|
||||||
|
to_yaml =
|
||||||
|
file_name: contents:
|
||||||
|
let
|
||||||
|
settingsFormat = pkgs.formats.yaml { };
|
||||||
|
yaml_file = settingsFormat.generate file_name contents;
|
||||||
|
yaml_content = builtins.readFile yaml_file;
|
||||||
|
in
|
||||||
|
yaml_content;
|
||||||
kube_encryption_key = runCommand "kube_encryption_key" { } ''
|
kube_encryption_key = runCommand "kube_encryption_key" { } ''
|
||||||
head -c 32 /dev/urandom | base64 | tee $out
|
head -c 32 /dev/urandom | base64 | tee $out
|
||||||
'';
|
'';
|
||||||
@ -40,9 +56,7 @@ let
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
kube_encryption_config_yaml = (
|
kube_encryption_config_yaml = (to_yaml_file "encryption-config.yaml" kube_encryption_config);
|
||||||
writeText "encryption-config.yaml" (lib.generators.toYAML { } kube_encryption_config)
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
name = "k8s-encryption-key";
|
name = "k8s-encryption-key";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user