From 1b229545703c814d09ee3a127ebe3f95e25c6c05 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Wed, 5 Nov 2025 18:31:31 +0100 Subject: [PATCH] fix(deployment): avoid duplicated nodeSelector #980 --- templates/deployment.yaml | 4 ++-- unittests/helm/deployment/basic.yaml | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/templates/deployment.yaml b/templates/deployment.yaml index f8e4e6f..427ef5b 100644 --- a/templates/deployment.yaml +++ b/templates/deployment.yaml @@ -364,9 +364,9 @@ spec: hostAliases: {{- toYaml . | nindent 8 }} {{- end }} - {{- range $key, $value := .Values.nodeSelector }} + {{- with .Values.nodeSelector }} nodeSelector: - {{ $key }}: {{ $value | quote }} + {{- toYaml . | nindent 8 }} {{- end }} {{- with .Values.affinity }} affinity: diff --git a/unittests/helm/deployment/basic.yaml b/unittests/helm/deployment/basic.yaml index 9a60007..91f7573 100644 --- a/unittests/helm/deployment/basic.yaml +++ b/unittests/helm/deployment/basic.yaml @@ -29,6 +29,24 @@ tests: path: spec.template.metadata.labels content: hello: world + - it: nodeSelector is undefined + asserts: + - notExists: + path: spec.template.spec.nodeSelector + template: templates/gitea/deployment.yaml + - it: nodeSelector is defined + set: + nodeSelector: + foo: bar + bar: foo + asserts: + - isSubset: + path: spec.template.spec.nodeSelector + content: + foo: bar + bar: foo + template: templates/gitea/deployment.yaml + - it: "injects TMP_EXISTING_ENVS_FILE as environment variable to 'init-app-ini' init container" template: templates/deployment.yaml asserts: