{{- if or .Values.mariadb.enabled .Values.externalDatabase.enabled .Values.postgresql.enabled }}
{{- if not .Values.externalDatabase.existingSecret.enabled }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ .Release.Name }}-db
  labels:
    {{- include "nextcloud.labels"  ( dict "rootContext" $ ) | nindent 4 }}
type: Opaque
data:
  {{- if .Values.mariadb.enabled }}
  db-username: {{ .Values.mariadb.auth.username | b64enc | quote }}
  db-password: {{ .Values.mariadb.auth.password | b64enc | quote }}
  {{- else if .Values.postgresql.enabled }}
  db-username: {{ .Values.postgresql.global.postgresql.auth.username | b64enc | quote }}
  db-password: {{ .Values.postgresql.global.postgresql.auth.password | b64enc | quote }}
  {{- else }}
  db-username: {{ .Values.externalDatabase.user | b64enc | quote }}
  db-password: {{ .Values.externalDatabase.password | b64enc | quote }}
  {{- end }}
{{- end }}
{{- end }}
