{{/* Generate the complete node affinity configuration */}} {{- define "node-thp-config.nodeAffinity" -}} nodeAffinity: requiredDuringSchedulingIgnoredDuringExecution: nodeSelectorTerms: {{- if .Values.baseMatchExpressions }} - matchExpressions: {{- include "node-thp-config.baseMatchExpressions" . | nindent 6 }} {{- end }} {{- if and .Values.addExtraMatchExpressions .Values.additionalMatchExpressions }} - matchExpressions: {{- include "node-thp-config.additionalMatchExpressions" . | nindent 6 }} {{- end }} {{- end }} {{/* Generate the base matchExpressions (always included) */}} {{- define "node-thp-config.baseMatchExpressions" -}} {{- range .Values.baseMatchExpressions }} - key: {{ .key }} operator: {{ .operator }} values: {{- range .values }} - {{ . | quote }} {{- end }} {{- end }} {{- end }} {{/* Generate additional matchExpressions if enabled */}} {{- define "node-thp-config.additionalMatchExpressions" -}} {{- if and .Values.addExtraMatchExpressions .Values.additionalMatchExpressions }} {{- range .Values.additionalMatchExpressions }} - key: {{ .key }} operator: {{ .operator }} values: {{- range .values }} - {{ . | quote }} {{- end }} {{- end }} {{- end }} {{- end }}