{{- if (not .Values.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "redmine.fullname" . }}
  labels: {{- include "redmine.labels" . | nindent 4 }}
type: Opaque
data:
  {{- if .Values.redminePassword }}
  redmine-password: {{ default "" .Values.redminePassword | b64enc | quote }}
  {{- else }}
  redmine-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  smtp-password: {{ default "" .Values.smtpPassword | b64enc | quote }}
  {{- if or (and (eq .Values.databaseType "mariadb") (not .Values.mariadb.enabled)) (and (eq .Values.databaseType "postgresql") (not .Values.postgresql.enabled)) }}
  {{- if .Values.externalDatabase.password }}
  external-db-password: {{ default "" .Values.externalDatabase.password | b64enc | quote }}
  {{- else }}
  external-db-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- end }}
  {{- if and .Values.mailReceiver.enabled .Values.mailReceiver.password }}
  mail-receiver-password: {{ default "" .Values.mailReceiver.password | b64enc | quote }}
  {{- end }}
{{- end }}
