From e5ec0a18005e8a4ceac25936057fb098d137d181 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Sun, 10 Mar 2024 15:03:08 +0200 Subject: [PATCH] chore(enabled): make sure the key always exist --- library/common/Chart.yaml | 2 +- library/common/templates/lib/util/_enabled.tpl | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 478e71b0..22b192c1 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,7 +15,7 @@ maintainers: name: common sources: null type: library -version: 19.1.1 +version: 19.1.2 annotations: artifacthub.io/category: "integration-delivery" artifacthub.io/license: "BUSL-1.1" diff --git a/library/common/templates/lib/util/_enabled.tpl b/library/common/templates/lib/util/_enabled.tpl index ce739cdc..fa67d79b 100644 --- a/library/common/templates/lib/util/_enabled.tpl +++ b/library/common/templates/lib/util/_enabled.tpl @@ -6,12 +6,14 @@ {{- $caller := .caller -}} {{- $enabled := false -}} - {{- if hasKey $objectData "enabled" -}} - {{- if not (kindIs "invalid" $objectData.enabled) -}} - {{- $enabled = $objectData.enabled -}} - {{- else -}} - {{- fail (printf "%s - Expected the defined key [enabled] in [%s.%s] to not be empty" $caller $key $name) -}} - {{- end -}} + {{- if not (hasKey $objectData "enabled") -}} + {{- fail (printf "%s - Expected the key [enabled] in [%s.%s] to exist" $caller $key $name) -}} + {{- end -}} + + {{- if not (kindIs "invalid" $objectData.enabled) -}} + {{- $enabled = $objectData.enabled -}} + {{- else -}} + {{- fail (printf "%s - Expected the defined key [enabled] in [%s.%s] to not be empty" $caller $key $name) -}} {{- end -}} {{- if kindIs "string" $enabled -}}