diff --git a/library/common-test/tests/ingress/homepage_test.yaml b/library/common-test/tests/ingress/homepage_test.yaml index 70783705..c27a92d3 100644 --- a/library/common-test/tests/ingress/homepage_test.yaml +++ b/library/common-test/tests/ingress/homepage_test.yaml @@ -91,6 +91,25 @@ tests: - host: "{{ .Values.someHost }}" paths: - path: "{{ .Values.somePath }}" + my-ingress4: + enabled: true + hosts: *hosts + integrations: + traefik: *traefik + homepage: + enabled: true + widget: + enabled: false + url: some-url-4 + type: some-type-4 + 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 asserts: - documentIndex: &ingressDoc 2 isKind: @@ -165,6 +184,18 @@ tests: equal: path: metadata.namespace value: test-release-namespace + - documentIndex: &fourthIngressDoc 5 + isKind: + of: Ingress + - documentIndex: *fourthIngressDoc + equal: + path: metadata.annotations + value: + gethomepage.dev/enabled: "true" + gethomepage.dev/name: TestReleaseName + gethomepage.dev/description: Helper chart to test different use cases of the common library + gethomepage.dev/href: https://test-host/test-path + gethomepage.dev/icon: https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png # Failures - it: should fail with podSelector not a slice diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index eb587661..cd8eaac2 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.23 +version: 16.2.24 diff --git a/library/common/templates/lib/ingress/integrations/_homepage.tpl b/library/common/templates/lib/ingress/integrations/_homepage.tpl index 6b2393a5..7769ec89 100644 --- a/library/common/templates/lib/ingress/integrations/_homepage.tpl +++ b/library/common/templates/lib/ingress/integrations/_homepage.tpl @@ -8,6 +8,11 @@ {{- $_ := set $objectData.integrations.homepage "widget" dict -}} {{- end -}} + {{- $widEnabled := true -}} + {{- if and (hasKey $homepage.widget "enabled") (kindIs "bool" $homepage.widget.enabled) -}} + {{- $widEnabled = $homepage.widget.enabled -}} + {{- end -}} + {{- include "tc.v1.common.lib.ingress.integration.homepage.validation" (dict "objectData" $objectData) -}} {{- $name := $homepage.name | default ($rootCtx.Release.Name | camelcase) -}} @@ -43,7 +48,6 @@ {{- $_ := set $objectData.annotations "gethomepage.dev/href" (tpl $href $rootCtx) -}} {{- $_ := set $objectData.annotations "gethomepage.dev/description" (tpl $desc $rootCtx) -}} {{- $_ := set $objectData.annotations "gethomepage.dev/icon" (tpl $icon $rootCtx) -}} - {{- $_ := set $objectData.annotations "gethomepage.dev/widget.type" (tpl $type $rootCtx) -}} {{- with $homepage.group -}} {{- $_ := set $objectData.annotations "gethomepage.dev/group" (tpl . $rootCtx) -}} {{- end -}} @@ -51,25 +55,29 @@ {{- with $homepage.weight -}} {{- $_ := set $objectData.annotations "gethomepage.dev/weight" (. | toString) -}} {{- end -}} - - {{- with $url -}} - {{- $_ := set $objectData.annotations "gethomepage.dev/widget.url" (tpl $url $rootCtx) -}} - {{- end -}} - - {{- if $homepage.widget.custom -}} - {{- 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 -}} {{- $selector := (printf "pod.name in (%s)" (join "," .)) -}} {{- $_ := set $objectData.annotations "gethomepage.dev/pod-selector" $selector -}} {{- end -}} + {{- if $widEnabled -}} + {{- $_ := set $objectData.annotations "gethomepage.dev/widget.type" (tpl $type $rootCtx) -}} + + {{- with $url -}} + {{- $_ := set $objectData.annotations "gethomepage.dev/widget.url" (tpl $url $rootCtx) -}} + {{- end -}} + + {{- if $homepage.widget.custom -}} + {{- 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 -}} + + {{- end -}} + {{- end -}} {{- end -}}