diff --git a/library/common-test/tests/ingress/homepage_test.yaml b/library/common-test/tests/ingress/homepage_test.yaml index 2db526b8..ca8e6edf 100644 --- a/library/common-test/tests/ingress/homepage_test.yaml +++ b/library/common-test/tests/ingress/homepage_test.yaml @@ -62,6 +62,11 @@ tests: custom: some-key: some-value some-other-key: some-other-value + customkv: + - key: some-key-slice + value: some-value-slice + - key: some-other-key-slice + value: some-other-value-slice hosts: &hosts - host: test-host paths: @@ -106,6 +111,8 @@ tests: gethomepage.dev/pod-selector: pod.name in (main,other) gethomepage.dev/widget.some-key: some-value gethomepage.dev/widget.some-other-key: some-other-value + gethomepage.dev/widget.some-key-slice: some-value-slice + gethomepage.dev/widget.some-other-key-slice: some-other-value-slice - documentIndex: *otherIngressDoc equal: path: metadata.name @@ -154,3 +161,23 @@ tests: asserts: - failedTemplate: errorMessage: Ingress - Expected [integrations.homepage.widget.custom] to be a [map], but got [string] + + - it: should fail with customkv widget not a slice + set: + operator: *operator + service: *service + ingress: + my-ingress1: + enabled: true + primary: true + integrations: + traefik: + enabled: false + homepage: + enabled: true + widget: + customkv: "not a slice" + hosts: *hosts + asserts: + - failedTemplate: + errorMessage: Ingress - Expected [integrations.homepage.widget.customkv] to be a [slice], but got [string] diff --git a/library/common/templates/lib/ingress/integrations/_homepage.tpl b/library/common/templates/lib/ingress/integrations/_homepage.tpl index 60ece304..5cc89a36 100644 --- a/library/common/templates/lib/ingress/integrations/_homepage.tpl +++ b/library/common/templates/lib/ingress/integrations/_homepage.tpl @@ -75,4 +75,10 @@ {{- fail (printf "Ingress - Expected [integrations.homepage.widget.custom] to be a [map], but got [%s]" (kindOf $homepage.widget.custom)) -}} {{- end -}} {{- end -}} + + {{- if $homepage.widget.customkv -}} + {{- 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 -}} + {{- end -}} {{- end -}}