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 054d4ea816 Including env variables for statsd container (#33175)
054d4ea816 is described below

commit 054d4ea816aec1d585085fa11fdff63d7dac4259
Author: Amogh Desai <[email protected]>
AuthorDate: Mon Aug 7 23:49:34 2023 +0530

    Including env variables for statsd container (#33175)
---
 chart/templates/statsd/statsd-deployment.yaml |  7 +++++++
 chart/values.schema.json                      | 21 +++++++++++++++++++++
 chart/values.yaml                             |  1 +
 helm_tests/other/test_statsd.py               | 15 +++++++++++++++
 4 files changed, 44 insertions(+)

diff --git a/chart/templates/statsd/statsd-deployment.yaml 
b/chart/templates/statsd/statsd-deployment.yaml
index 06f034506c..583151331a 100644
--- a/chart/templates/statsd/statsd-deployment.yaml
+++ b/chart/templates/statsd/statsd-deployment.yaml
@@ -97,6 +97,13 @@ spec:
             - "--statsd.mapping-config=/etc/statsd-exporter/mappings.yml"
           {{- end }}
           resources: {{- toYaml .Values.statsd.resources | nindent 12 }}
+          {{- if .Values.statsd.env }}
+          env:
+            {{- range $i, $config := .Values.statsd.env }}
+            - value: {{ $config.value | quote }}
+              name: {{ $config.name | quote }}
+            {{- end }}
+          {{- end }}
           ports:
             - name: statsd-ingest
               protocol: UDP
diff --git a/chart/values.schema.json b/chart/values.schema.json
index d182ad3ecc..f56f47053d 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -4967,6 +4967,27 @@
                     "default": [
                         
"--statsd.mapping-config=/etc/statsd-exporter/mappings.yml"
                     ]
+                },
+                "env": {
+                    "description": "Add additional env vars to statsd 
container.",
+                    "type": "array",
+                    "default": [],
+                    "items": {
+                        "type": "object",
+                        "properties": {
+                            "name": {
+                                "type": "string"
+                            },
+                            "value": {
+                                "type": "string"
+                            }
+                        },
+                        "required": [
+                            "name",
+                            "value"
+                        ],
+                        "additionalProperties": false
+                    }
                 }
             }
         },
diff --git a/chart/values.yaml b/chart/values.yaml
index 8fc8053f96..0b4ce06edc 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -1727,6 +1727,7 @@ statsd:
   overrideMappings: []
 
   podAnnotations: {}
+  env: []
 
 # PgBouncer settings
 pgbouncer:
diff --git a/helm_tests/other/test_statsd.py b/helm_tests/other/test_statsd.py
index c383cd99d3..bc5b5b0785 100644
--- a/helm_tests/other/test_statsd.py
+++ b/helm_tests/other/test_statsd.py
@@ -296,6 +296,21 @@ class TestStatsd:
             == "test_pod_annotation_value"
         )
 
+    def test_should_add_custom_env_variables(self):
+        env1 = {"name": "TEST_ENV_1", "value": "test_env_1"}
+
+        docs = render_chart(
+            values={
+                "statsd": {
+                    "enabled": True,
+                    "env": [env1],
+                },
+            },
+            show_only=["templates/statsd/statsd-deployment.yaml"],
+        )[0]
+
+        assert jmespath.search("spec.template.spec.containers[0].env", docs) 
== [env1]
+
 
 class TestStatsdServiceAccount:
     """Tests statsd service account."""

Reply via email to