diff --git a/library/common-test/tests/ingress/homepage_test.yaml b/library/common-test/tests/ingress/homepage_test.yaml index 2db526b8..9f4aaeaa 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,45 @@ 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] + + - 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/Chart.yaml b/library/common/Chart.yaml index 538a0a48..44fa72cb 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 16.2.10 +version: 16.2.11 diff --git a/library/common/templates/lib/ingress/integrations/_homepage.tpl b/library/common/templates/lib/ingress/integrations/_homepage.tpl index 94863efb..33d2177e 100644 --- a/library/common/templates/lib/ingress/integrations/_homepage.tpl +++ b/library/common/templates/lib/ingress/integrations/_homepage.tpl @@ -46,6 +46,9 @@ {{- range $k, $v := $homepage.widget.custom -}} {{- $_ := set $objectData.annotations (printf "gethomepage.dev/widget.%s" $k) (tpl $v $rootCtx | toString) -}} {{- end -}} + {{- range $homepage.widget.customkv -}} + {{- $_ := set $objectData.annotations (printf "gethomepage.dev/widget.%s" .key ) (tpl .value $rootCtx | toString) -}} + {{- end -}} {{- end -}} {{- with $homepage.podSelector -}} @@ -72,4 +75,15 @@ {{- 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 -}} + {{- range $item := $homepage.widget.customkv -}} + {{- if not $item.key -}} + {{- fail "Ingress - Expected non-empty [key] in [integrations.homepage.widget.customkv]" -}} + {{- end -}} + {{- end -}} + {{- end -}} {{- end -}} diff --git a/library/common/values.yaml b/library/common/values.yaml index e530872b..33ec0c78 100644 --- a/library/common/values.yaml +++ b/library/common/values.yaml @@ -621,7 +621,10 @@ ingress: # Default to ingress host 0 url: "" custom: - # - somesetting: some value + # somesetting: some value + customkv: + # - key: some key + # value: some value certificate: {} # main: