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 658f406 Chart: Fix extra secrets/configmaps labels (#20464)
658f406 is described below
commit 658f4060788f405cab86e57a98925dc69760a4dd
Author: Aakcht <[email protected]>
AuthorDate: Wed Dec 22 21:34:15 2021 +0300
Chart: Fix extra secrets/configmaps labels (#20464)
---
chart/templates/configmaps/extra-configmaps.yaml | 6 +++---
chart/templates/secrets/extra-secrets.yaml | 6 +++---
chart/tests/test_extra_configmaps_secrets.py | 21 +++++++++++++++++++++
3 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/chart/templates/configmaps/extra-configmaps.yaml
b/chart/templates/configmaps/extra-configmaps.yaml
index a186aba..5daac57 100644
--- a/chart/templates/configmaps/extra-configmaps.yaml
+++ b/chart/templates/configmaps/extra-configmaps.yaml
@@ -29,13 +29,13 @@ metadata:
release: {{ $Global.Release.Name }}
chart: "{{ $Global.Chart.Name }}-{{ $Global.Chart.Version }}"
heritage: {{ $Global.Release.Service }}
+{{- with $Global.Values.labels }}
+{{ toYaml . | indent 4 }}
+{{- end }}
annotations:
"helm.sh/hook": "pre-install,pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
"helm.sh/hook-weight": "0"
-{{- with $Global.Values.labels }}
-{{ toYaml . | indent 4 }}
-{{- end }}
{{- if $configMapContent.data }}
data:
{{- with $configMapContent.data }}
diff --git a/chart/templates/secrets/extra-secrets.yaml
b/chart/templates/secrets/extra-secrets.yaml
index 1326aa2..9137a0e 100644
--- a/chart/templates/secrets/extra-secrets.yaml
+++ b/chart/templates/secrets/extra-secrets.yaml
@@ -29,13 +29,13 @@ metadata:
release: {{ $Global.Release.Name }}
chart: "{{ $Global.Chart.Name }}-{{ $Global.Chart.Version }}"
heritage: {{ $Global.Release.Service }}
+{{- with $Global.Values.labels }}
+{{ toYaml . | indent 4 }}
+{{- end }}
annotations:
"helm.sh/hook": "pre-install,pre-upgrade"
"helm.sh/hook-delete-policy": "before-hook-creation"
"helm.sh/hook-weight": "0"
-{{- with $Global.Values.labels }}
-{{ toYaml . | indent 4 }}
-{{- end }}
{{- if $secretContent.data }}
data:
{{- with $secretContent.data }}
diff --git a/chart/tests/test_extra_configmaps_secrets.py
b/chart/tests/test_extra_configmaps_secrets.py
index 88fb77a..3943990 100644
--- a/chart/tests/test_extra_configmaps_secrets.py
+++ b/chart/tests/test_extra_configmaps_secrets.py
@@ -18,6 +18,7 @@
import textwrap
import unittest
from base64 import b64encode
+from unittest import mock
import yaml
@@ -108,3 +109,23 @@ class ExtraConfigMapsSecretsTest(unittest.TestCase):
configmap_obj = k8s_objects_by_key[expected_key]
assert configmap_obj["data"] == expected_data
assert configmap_obj["stringData"] == expected_string_data
+
+ def test_extra_configmaps_secrets_labels(self):
+ k8s_objects = render_chart(
+ name=RELEASE_NAME,
+ values={
+ "labels": {"label1": "value1", "label2": "value2"},
+ "extraSecrets": {"{{ .Release.Name }}-extra-secret-1":
{"stringData": "data: secretData"}},
+ "extraConfigMaps": {"{{ .Release.Name }}-extra-configmap-1":
{"data": "data: configData"}},
+ },
+ show_only=["templates/configmaps/extra-configmaps.yaml",
"templates/secrets/extra-secrets.yaml"],
+ )
+ expected_labels = {
+ "label1": "value1",
+ "label2": "value2",
+ "release": RELEASE_NAME,
+ "heritage": "Helm",
+ "chart": mock.ANY,
+ }
+ for k8s_object in k8s_objects:
+ assert k8s_object['metadata']['labels'] == expected_labels