diff --git a/library/common-test/tests/ingress/homepage_test.yaml b/library/common-test/tests/ingress/homepage_test.yaml index ca8e6edf..9f4aaeaa 100644 --- a/library/common-test/tests/ingress/homepage_test.yaml +++ b/library/common-test/tests/ingress/homepage_test.yaml @@ -181,3 +181,25 @@ tests: asserts: - failedTemplate: errorMessage: Ingress - Expected [integrations.homepage.widget.customkv] to be a [slice], but got [string] + + - it: should fail with customkv having empty key + set: + operator: *operator + service: *service + ingress: + my-ingress1: + enabled: true + primary: true + integrations: + traefik: + enabled: false + homepage: + enabled: true + widget: + customkv: + - key: "" + value: some-value + hosts: *hosts + asserts: + - failedTemplate: + errorMessage: Ingress - Expected non-empty [key] in [integrations.homepage.widget.customkv] diff --git a/library/common/templates/lib/ingress/integrations/_homepage.tpl b/library/common/templates/lib/ingress/integrations/_homepage.tpl index 5cc89a36..33d2177e 100644 --- a/library/common/templates/lib/ingress/integrations/_homepage.tpl +++ b/library/common/templates/lib/ingress/integrations/_homepage.tpl @@ -80,5 +80,10 @@ {{- if not (kindIs "slice" $homepage.widget.customkv) -}} {{- fail (printf "Ingress - Expected [integrations.homepage.widget.customkv] to be a [slice], but got [%s]" (kindOf $homepage.widget.customkv)) -}} {{- end -}} + {{- range $item := $homepage.widget.customkv -}} + {{- if not $item.key -}} + {{- fail "Ingress - Expected non-empty [key] in [integrations.homepage.widget.customkv]" -}} + {{- end -}} + {{- end -}} {{- end -}} {{- end -}}