Handle edge case of empty values converting to nil (#1114)

This commit is contained in:
Stavros Kois authored and GitHub committed 2023-04-12 15:55:57 +03:00
1 parent 42ea4d99ed
commit 48c5adcfd1
3 files changed
+10 -2

No files matched your search

@@ -65,6 +65,7 @@ tests:
fieldRef: fieldRef:
fieldPath: metadata.name fieldPath: metadata.name
VAR8: "" VAR8: ""
VAR9: false
asserts: asserts:
- documentIndex: &deploymentDoc 2 - documentIndex: &deploymentDoc 2
isKind: isKind:
@@ -134,6 +135,12 @@ tests:
content: content:
name: VAR8 name: VAR8
value: "" value: ""
- documentIndex: *deploymentDoc
contains:
path: spec.template.spec.containers[0].env
content:
name: VAR9
value: "false"
# Failures # Failures
- it: it should fail invalid ref - it: it should fail invalid ref
+1 -1
View File
@@ -2,7 +2,7 @@ apiVersion: v2
name: common name: common
description: A library chart for iX Official Catalog description: A library chart for iX Official Catalog
type: library type: library
version: 1.0.4 version: 1.0.5
appVersion: v1 appVersion: v1
annotations: annotations:
title: Common Library Chart title: Common Library Chart
@@ -13,7 +13,8 @@ objectData: The object data to be used to render the container.
- name: {{ $k | quote }} - name: {{ $k | quote }}
{{- if not (kindIs "map" $v) -}} {{- if not (kindIs "map" $v) -}}
{{- $value := "" -}} {{- $value := "" -}}
{{- if $v -}} {{/* Only tpl non-empty values */}} {{/* Only tpl valid values, there are cases that empty values after merges can be "<nil>" */}}
{{- if not (kindIs "invalid" $v) -}}
{{- $value = tpl (toString $v) $rootCtx -}} {{- $value = tpl (toString $v) $rootCtx -}}
{{- end }} {{- end }}
value: {{ $value | quote }} value: {{ $value | quote }}