Skip to content

Commit

Permalink
Allow templating webserver ingress hostnames (apache#33142)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimminw00 authored Aug 14, 2023
1 parent 72c489d commit 2976a56
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chart/templates/webserver/webserver-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ spec:
{{- $hostname = .name -}}
{{- end }}
{{- if $hostname }}
host: {{ $hostname | quote }}
host: {{ include "common.tplvalues.render" ( dict "value" $hostname "context" $ ) | quote }}
{{- end }}
{{- end }}
{{- if .Values.ingress.web.ingressClassName }}
Expand Down
1 change: 1 addition & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ ingress:

# The hostnames or hosts configuration for the web Ingress
hosts: []
# # The hostname for the web Ingress (can be templated)
# - name: ""
# # configs for web Ingress TLS
# tls:
Expand Down
33 changes: 33 additions & 0 deletions helm_tests/webserver/test_ingress_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,36 @@ def test_should_add_component_specific_labels(self):
)
assert "test_label" in jmespath.search("metadata.labels", docs[0])
assert jmespath.search("metadata.labels", docs[0])["test_label"] == "test_label_value"

def test_can_ingress_hosts_be_templated(self):
docs = render_chart(
values={
"testValues": {
"scalar": "aa",
"list": ["bb", "cc"],
"dict": {
"key": "dd",
},
},
"ingress": {
"web": {
"enabled": True,
"hosts": [
{"name": "*.{{ .Release.Namespace }}.example.com"},
{"name": "{{ .Values.testValues.scalar }}.example.com"},
{"name": "{{ index .Values.testValues.list 1 }}.example.com"},
{"name": "{{ .Values.testValues.dict.key }}.example.com"},
],
},
},
},
show_only=["templates/webserver/webserver-ingress.yaml"],
namespace="airflow",
)

assert [
"*.airflow.example.com",
"aa.example.com",
"cc.example.com",
"dd.example.com",
] == jmespath.search("spec.rules[*].host", docs[0])

0 comments on commit 2976a56

Please sign in to comment.