{{- if not .Values.nextcloud.existingSecret.enabled }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "nextcloud.fullname" . }}
  labels:
    {{- include "nextcloud.labels"  ( dict "rootContext" $ ) | nindent 4 }}
type: Opaque
data:
  nextcloud-username: {{ .Values.nextcloud.username | b64enc | quote }}
  {{- with .Values.nextcloud.password }}
  nextcloud-password: {{ . | b64enc | quote }}
  {{- else }}
  nextcloud-password: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- if and .Values.metrics.enabled .Values.metrics.token }}
  nextcloud-token: {{ .Values.metrics.token | b64enc | quote }}
  {{- else if and .Values.metrics.enabled (not .Values.metrics.token) }}
  nextcloud-token: {{ randAlphaNum 10 | b64enc | quote }}
  {{- end }}
  {{- if .Values.nextcloud.mail.enabled }}
  smtp-username: {{ .Values.nextcloud.mail.smtp.name | default "" | b64enc | quote }}
  smtp-password: {{ .Values.nextcloud.mail.smtp.password | default "" | b64enc | quote }}
  smtp-host: {{ .Values.nextcloud.mail.smtp.host | default "" | b64enc | quote }}
  {{- end }}
{{- end }}
