fix(argo-cd): Make code clearer when Redis Secret is optional (#3228)

This commit is contained in:
Marco Maurer (-Kilchhofer) 2025-04-02 12:45:24 +02:00 committed by GitHub
parent eb0f0af836
commit 9365ba1dd2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 48 additions and 42 deletions

View file

@ -275,3 +275,41 @@ ipFamilyPolicy: {{ . }}
ipFamilies: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{/*
secretKeyRef of env variable REDIS_USERNAME
*/}}
{{- define "argo-cd.redisUsernameSecretRef" -}}
{{- if and .Values.externalRedis.host -}}
name: {{ default (include "argo-cd.redis.fullname" .) .Values.externalRedis.existingSecret }}
key: redis-username
optional: true
{{- else -}}
name: {{ include "argo-cd.redis.fullname" . }}
key: redis-username
optional: true
{{- end -}}
{{- end -}}
{{/*
secretKeyRef of env variable REDIS_PASSWORD
*/}}
{{- define "argo-cd.redisPasswordSecretRef" -}}
{{- if and .Values.redisSecretInit.enabled (not .Values.externalRedis.host) -}}
{{- /* Default case where Secret is generated by the Job with Helm pre-install hooks */ -}}
name: "argocd-redis" # hard-coded in Job command "argocd admin redis-initial-password"
key: auth
optional: false # Secret is not optional in this case !
{{- else if .Values.externalRedis.host -}}
{{- /* External Redis use case */ -}}
{{- /* Secret is required when specifying existingSecret, otherwise it is optional */ -}}
name: {{ default (include "argo-cd.redis.fullname" .) .Values.externalRedis.existingSecret }}
key: redis-password
optional: {{ if .Values.externalRedis.existingSecret }}false{{ else }}true{{ end }}
{{- else -}}
{{- /* All other use cases (e.g. disabled pre-install Job) */ -}}
name: {{ include "argo-cd.redis.fullname" . }}
key: redis-password
optional: true
{{- end -}}
{{- end -}}