diff --git a/terminfinder-chart/charts/terminfinder-backend/templates/_helpers.tpl b/terminfinder-chart/charts/terminfinder-backend/templates/_helpers.tpl index 3629030..f11612d 100644 --- a/terminfinder-chart/charts/terminfinder-backend/templates/_helpers.tpl +++ b/terminfinder-chart/charts/terminfinder-backend/templates/_helpers.tpl @@ -138,3 +138,21 @@ Check if external db and postgres are not used at the same time {{- fail "no database is enabled database-userPasswordKey" }} {{- end }} {{- end }} + +{{/* +Run tpl on an input value + +Takes 2 input parameters as list +Parameter 1: $ (Root context, required by tpl) +Parameter 2: Value to run tpl on +*/}} +{{- define "terminfinder-backend.value-tpl" -}} + {{- $ := index . 0 }} + {{- $tpl := index . 1 -}} + {{- /* only call tpl if there is at least one template expression */ -}} + {{- if contains "{{" $tpl -}} + {{- tpl $tpl $ }} + {{- else -}} + {{- $tpl -}} + {{- end -}} +{{- end -}} diff --git a/terminfinder-chart/charts/terminfinder-backend/templates/ingress.yaml b/terminfinder-chart/charts/terminfinder-backend/templates/ingress.yaml index d076e9c..fc91d46 100644 --- a/terminfinder-chart/charts/terminfinder-backend/templates/ingress.yaml +++ b/terminfinder-chart/charts/terminfinder-backend/templates/ingress.yaml @@ -3,7 +3,7 @@ {{- $svcPort := .Values.service.port -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} - {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className }} {{- end }} {{- end }} {{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} @@ -32,14 +32,14 @@ spec: {{- range .Values.ingress.tls }} - hosts: {{- range .hosts }} - - {{ . | quote }} + - {{ include "terminfinder-backend.value-tpl" (list $ .) | quote }} {{- end }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} + - host: {{ include "terminfinder-backend.value-tpl" (list $ .host) | quote }} http: paths: {{- range .paths }} diff --git a/terminfinder-chart/charts/terminfinder-frontend/templates/_helpers.tpl b/terminfinder-chart/charts/terminfinder-frontend/templates/_helpers.tpl index 3d02dbc..7cc09a3 100644 --- a/terminfinder-chart/charts/terminfinder-frontend/templates/_helpers.tpl +++ b/terminfinder-chart/charts/terminfinder-frontend/templates/_helpers.tpl @@ -59,4 +59,22 @@ Create the name of the service account to use {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} + +{{/* +Run tpl on an input value + +Takes 2 input parameters as list +Parameter 1: $ (Root context, required by tpl) +Parameter 2: Value to run tpl on +*/}} +{{- define "terminfinder-frontend.value-tpl" -}} + {{- $ := index . 0 }} + {{- $tpl := index . 1 -}} + {{- /* only call tpl if there is at least one template expression */ -}} + {{- if contains "{{" $tpl -}} + {{- tpl $tpl $ }} + {{- else -}} + {{- $tpl -}} + {{- end -}} +{{- end -}} diff --git a/terminfinder-chart/charts/terminfinder-frontend/templates/ingress.yaml b/terminfinder-chart/charts/terminfinder-frontend/templates/ingress.yaml index 295c3aa..f08d6c7 100644 --- a/terminfinder-chart/charts/terminfinder-frontend/templates/ingress.yaml +++ b/terminfinder-chart/charts/terminfinder-frontend/templates/ingress.yaml @@ -32,14 +32,14 @@ spec: {{- range .Values.ingress.tls }} - hosts: {{- range .hosts }} - - {{ . | quote }} + - {{ include "terminfinder-frontend.value-tpl" (list $ .) | quote }} {{- end }} secretName: {{ .secretName }} {{- end }} {{- end }} rules: {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} + - host: {{ include "terminfinder-frontend.value-tpl" (list $ .host) | quote }} http: paths: {{- range .paths }}