diff --git a/application/templates/_helpers.tpl b/application/templates/_helpers.tpl index aae9add3..76ce78ac 100644 --- a/application/templates/_helpers.tpl +++ b/application/templates/_helpers.tpl @@ -21,11 +21,14 @@ Usage: {{ include "application.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }} */}} {{- define "application.tplvalues.render" -}} - {{- if typeIs "string" .value }} - {{- tpl .value .context }} - {{- else }} - {{- tpl (.value | toYaml) .context }} - {{- end }} + {{- $value := .value -}} + {{- if or (not $value) (kindIs "invalid" $value) -}} + {{- "" -}} + {{- else if typeIs "string" $value -}} + {{- tpl $value .context -}} + {{- else -}} + {{- tpl ($value | toYaml) .context -}} + {{- end -}} {{- end -}} {{/* diff --git a/application/tests/cronjob_test.yaml b/application/tests/cronjob_test.yaml index e22fbd0d..04d7faf0 100644 --- a/application/tests/cronjob_test.yaml +++ b/application/tests/cronjob_test.yaml @@ -330,6 +330,23 @@ tests: path: spec.jobTemplate.spec.template.spec.containers[0].image value: custom-image + - it: does not render @null when digest field is omitted + set: + cronJob: + enabled: true + jobs: + example: + image: + repository: example-image + tag: example-tag + asserts: + - equal: + path: spec.jobTemplate.spec.template.spec.containers[0].image + value: example-image:example-tag + - notMatchRegex: + path: spec.jobTemplate.spec.template.spec.containers[0].image + pattern: "@null" + - it: configures automount service account token by default set: cronJob: diff --git a/application/tests/deployment_test.yaml b/application/tests/deployment_test.yaml index fb274d01..4dedd736 100644 --- a/application/tests/deployment_test.yaml +++ b/application/tests/deployment_test.yaml @@ -88,6 +88,18 @@ tests: path: spec.template.spec.containers[0].image value: example-image:example-tag@sha256:example-digest + - it: does not render @null when digest field is omitted + set: + deployment.image.repository: example-image + deployment.image.tag: example-tag + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: example-image:example-tag + - notMatchRegex: + path: spec.template.spec.containers[0].image + pattern: "@null" + - it: yields empty service account name when disabled set: rbac.serviceAccount.enabled: false diff --git a/application/tests/job_test.yaml b/application/tests/job_test.yaml index bbe144a5..107e8c92 100644 --- a/application/tests/job_test.yaml +++ b/application/tests/job_test.yaml @@ -329,6 +329,23 @@ tests: path: spec.template.spec.containers[0].image value: custom-image + - it: does not render @null when digest field is omitted + set: + job: + enabled: true + jobs: + example: + image: + repository: example-image + tag: example-tag + asserts: + - equal: + path: spec.template.spec.containers[0].image + value: example-image:example-tag + - notMatchRegex: + path: spec.template.spec.containers[0].image + pattern: "@null" + - it: configures automount service account token by default set: job: