feat(lib): add toYAML method

This commit is contained in:
Jaka Hudoklin 2017-12-01 12:40:28 +01:00
parent 663138ae4c
commit 16647cc5ef
2 changed files with 7 additions and 1 deletions

View file

@ -14,7 +14,7 @@ let
args = {
inherit pkgs;
name = "default";
k8s = { inherit loadJSON loadYAML toBase64 octalToDecimal mkValueOrSecretOption; };
k8s = { inherit loadJSON loadYAML toYAML toBase64 octalToDecimal mkValueOrSecretOption; };
};
};

View file

@ -26,6 +26,12 @@ rec {
loadYAML = path: loadJSON (pkgs.runCommand "yaml-to-json" {
} "${pkgs.remarshal}/bin/remarshal -i ${path} -if yaml -of json > $out");
toYAML = config: builtins.readFile (pkgs.runCommand "to-yaml" {
buildInputs = [pkgs.remarshal];
} ''
remarshal -i ${pkgs.writeText "to-json" (builtins.toJSON config)} -if json -of yaml > $out
'');
toBase64 = value:
builtins.readFile
(pkgs.runCommand "value-to-b64" {} "echo '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $out");