5454 {{ if .Values.runtimeClassName -}}
5555 runtimeClassName : {{ .Values.runtimeClassName }}
5656 {{ end -}}
57- {{ if len .Values.imagePullSecrets -}}
58- imagePullSecrets : {{ toYaml .Values.imagePullSecrets | trimSuffix "\n" | nindent 6 }}
59- {{ end -}}
57+
58+ {{- /* Combine global and exporter-specific imagePullSecrets */}}
59+ {{- $allPullSecrets := .Values.imagePullSecrets | default list -}}
60+ {{- if and .Values.pgbouncerExporter.enabled .Values.pgbouncerExporter.imagePullSecrets -}}
61+ {{- $exporterPullSecrets := .Values.pgbouncerExporter.imagePullSecrets | default list -}}
62+ {{- $allPullSecrets = concat $allPullSecrets $exporterPullSecrets -}}
63+ {{- end -}}
64+
65+ {{- /* De-duplicate secrets by name */}}
66+ {{- $uniquePullSecrets := list -}}
67+ {{- $seenSecretNames := dict -}}
68+ {{- range $allPullSecrets -}}
69+ {{- if .name -}} {{/* Ensure item is a map with a 'name' key to avoid errors with malformed entries */}}
70+ {{- if not (hasKey $seenSecretNames .name) -}}
71+ {{- $uniquePullSecrets = append $uniquePullSecrets . -}}
72+ {{- $_ := set $seenSecretNames .name true -}}
73+ {{- end -}}
74+ {{- end -}}
75+ {{- end -}}
76+
77+ {{- if $uniquePullSecrets }}
78+ imagePullSecrets : {{- toYaml $uniquePullSecrets | nindent 8 }}
79+ {{- end }}
80+
6081 {{ if .Values.extraInitContainers -}}
6182 initContainers : {{ toYaml .Values.extraInitContainers | trimSuffix "\n" | nindent 6 }}
6283 {{ end -}}
@@ -156,4 +177,4 @@ spec:
156177 {{- if .Values.extraVolumes -}}
157178 {{ toYaml .Values.extraVolumes | trimSuffix "\n" | nindent 6 }}
158179 {{ end -}}
159- {{- end }}
180+ {{- end }}
0 commit comments