{{- if eq .Values.global.deploymentMode "development" }}
{{- $secret := (lookup "v1" "Secret" .Values.namespace .Values.redash.existingSecretAdmin ) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Values.redash.existingSecretAdmin }}
type: Opaque
data:
{{- if not $secret }}
  secretKey: {{ randAlphaNum 64 | b64enc | quote }}
  cookieSecret: {{ randAlphaNum 64 | b64enc | quote }}
  postgresqlPassword: {{ randAlphaNum 32 | b64enc | quote }}
  googleClientSecret: "bm90c2V0"
  ldapBindDnPassword: "bm90c2V0"
  mailPassword: "bm90c2V0"
{{- else }}
  secretKey: {{ $secret.data.secretKey }}
  cookieSecret: {{ $secret.data.cookieSecret }}
  postgresqlPassword: {{ $secret.data.postgresqlPassword }}
  googleClientSecret: {{ $secret.data.googleClientSecret }}
  ldapBindDnPassword: {{ $secret.data.ldapBindDnPassword }}
  mailPassword: {{ $secret.data.mailPassword }}
{{- end }}
{{- end }}
