Skip to content

Commit

Permalink
[jjo] fix: let env_ null values stay as so (vs string-ifying it) (b…
Browse files Browse the repository at this point in the history
  • Loading branch information
jjo authored and groodt committed May 26, 2020
1 parent 025ad99 commit 18be246
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
10 changes: 9 additions & 1 deletion kube.libsonnet
Expand Up @@ -223,7 +223,15 @@
imagePullPolicy: if std.endsWith(self.image, ":latest") then "Always" else "IfNotPresent",

envList(map):: [
if std.type(map[x]) == "object" then { name: x, valueFrom: map[x] } else { name: x, value: std.toString(map[x]) }
if std.type(map[x]) == "object"
then {
name: x,
valueFrom: map[x],
} else {
// Let `null` value stay as such (vs string-ified)
name: x,
value: if map[x] == null then null else std.toString(map[x]),
}
for x in std.objectFields(map)
],

Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Expand Up @@ -4,7 +4,7 @@ K3S_V1_14=v0.8.0
K3S_V1_15=v0.9.0
K3S_V1_16=v1.0.1
K3S_V1_17=v1.17.2-k3s1
K3S_V1_18=v1.18.2-rc4-k3s1
K3S_V1_18=v1.18.2-k3s1
#
# Since https://github.com/bitnami-labs/kube-libsonnet/issues/32 we support
# kubernetes v1.14+ (Ingress apiVersion deprecated in v1.18, available since v1.14).
Expand Down
16 changes: 16 additions & 0 deletions tests/golden/test-simple-validate.pass.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/test-simple-validate.pass.jsonnet
Expand Up @@ -66,6 +66,7 @@ local stack = {
image: "nginx:1.12",
env_+: {
my_secret: kube.SecretKeyRef($.secret, "sec_key"),
other_key: null,
},
ports_+: {
http: { containerPort: 80 },
Expand Down
Empty file.

0 comments on commit 18be246

Please sign in to comment.