{{- if empty .Values.auth.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "pgadmin4.fullname" . }}
  {{- with .Values.commonLabels }}
  labels: {{ . | toYaml | nindent 4 }}
  {{- end }}
  {{- with .Values.commonAnnotations }}
  annotations: {{ . | toYaml | nindent 4 }}
  {{- end }}
type: Opaque
stringData:
  {{ .Values.auth.passwordKey }}: {{ coalesce .Values.auth.password (dig "data" .Values.auth.passwordKey "" (lookup "v1" "Secret" .Release.Namespace (include "pgadmin4.fullname" .)) | b64dec) (randAlphaNum 12) | quote }}
{{- end }}