apiVersion: v1
kind: Secret
metadata:
  name: {{ template "fullname" . }}
  labels:
    app: {{ template "fullname" . }}
    chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    release: "{{ .Release.Name }}"
    heritage: "{{ .Release.Service }}"
type: Opaque
data:
  {{ if .Values.sentrySecret }}
  sentry-secret: {{ .Values.sentrySecret | b64enc | quote }}
  {{ else }}
  sentry-secret: {{ randAlphaNum 40 | b64enc | quote }}
  {{ end }}
  {{- if not .Values.email.existingSecret }}
  smtp-password: {{ default "" .Values.email.password | b64enc | quote }}
  {{ end }}
  {{ if .Values.user.password }}
  user-password: {{ .Values.user.password | b64enc | quote }}
  {{ else }}
  user-password: {{ randAlphaNum 16 | b64enc | quote }}
  {{ end }}
  {{ if not .Values.postgresql.enabled }}
  postgres-password: {{ .Values.postgresql.postgresPassword | default "" | b64enc | quote }}
  {{ end }}
  {{ if and (not .Values.redis.enabled) (.Values.redis.password) }}
  redis-password: {{ .Values.redis.password | default "" | b64enc | quote }}
  {{ end }}
