This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 4d3d4a1567 Allow templating flower ingress hostnames (#33363)
4d3d4a1567 is described below

commit 4d3d4a15671d0f543479b1ea8679bb32571d9b70
Author: Kim Minwoo <[email protected]>
AuthorDate: Mon Aug 14 08:54:02 2023 +0900

    Allow templating flower ingress hostnames (#33363)
---
 chart/templates/flower/flower-ingress.yaml  |  2 +-
 chart/values.yaml                           |  1 +
 helm_tests/webserver/test_ingress_flower.py | 34 +++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/chart/templates/flower/flower-ingress.yaml 
b/chart/templates/flower/flower-ingress.yaml
index 4cfc9b540e..165da4b246 100644
--- a/chart/templates/flower/flower-ingress.yaml
+++ b/chart/templates/flower/flower-ingress.yaml
@@ -84,7 +84,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.flower.ingressClassName }}
diff --git a/chart/values.yaml b/chart/values.yaml
index ca1a0a1424..f0edd2861b 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -183,6 +183,7 @@ ingress:
 
     # The hostnames or hosts configuration for the flower Ingress
     hosts: []
+    #   # The hostname for the flower Ingress (can be templated)
     # - name: ""
     #   tls:
     #     # Enable TLS termination for the flower Ingress
diff --git a/helm_tests/webserver/test_ingress_flower.py 
b/helm_tests/webserver/test_ingress_flower.py
index 0bd95bf8a2..e3d9ff171d 100644
--- a/helm_tests/webserver/test_ingress_flower.py
+++ b/helm_tests/webserver/test_ingress_flower.py
@@ -186,3 +186,37 @@ class TestIngressFlower:
 
         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",
+                    },
+                },
+                "flower": {"enabled": True},
+                "ingress": {
+                    "flower": {
+                        "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/flower/flower-ingress.yaml"],
+            namespace="airflow",
+        )
+
+        assert [
+            "*.airflow.example.com",
+            "aa.example.com",
+            "cc.example.com",
+            "dd.example.com",
+        ] == jmespath.search("spec.rules[*].host", docs[0])

Reply via email to