Skip to content

Commit 750f66f

Browse files
authored
Merge pull request #21 from arnarg/fix/from-yaml
Fix implementation of fromYAML
2 parents 1b6e64e + fc9a71f commit 750f66f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/kube.nix

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
{
22
lib,
3-
klib,
3+
pkgs,
44
...
55
}: {
66
/*
77
Parses a YAML document string into a list of attribute sets.
88
9-
> This is re-exported directly from [farcaller/nix-kube-generators](https://github.com/farcaller/nix-kube-generators).
10-
119
Type:
1210
fromYAML :: String -> [AttrSet]
1311
@@ -39,7 +37,18 @@
3937
fromYAML =
4038
# String with a yaml document.
4139
yaml:
42-
klib.fromYAML yaml;
40+
lib.pipe yaml [
41+
(yaml: (pkgs.stdenv.mkDerivation {
42+
inherit yaml;
43+
passAsFile = "yaml";
44+
name = "fromYAML";
45+
phases = ["buildPhase"];
46+
buildPhase = "${pkgs.yq}/bin/yq -Ms . $yamlPath > $out";
47+
}))
48+
builtins.readFile
49+
builtins.fromJSON
50+
(builtins.filter (v: v != null))
51+
];
4352

4453
/*
4554
Parse an octal representation of a number and convert into a decimal number. This can be useful when having to represent permission bits in a resource as nix has no support for representing octal numbers.

0 commit comments

Comments
 (0)