{{- if not .Values.limesurvey.admin.existingSecret }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "limesurvey.secretName" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels:
    {{- include "limesurvey.labels" . | nindent 4 }}
type: Opaque
data:
  {{- if .Values.limesurvey.admin.password }}
  limesurvey-admin-password: {{ .Values.limesurvey.admin.password | b64enc | quote }}
  {{- else }}
  limesurvey-admin-password: {{ randAlphaNum 15 | b64enc | quote }}
  {{- end }}
{{- end }}

{{- if not (or .Values.mariadb.enabled .Values.externalDatabase.existingSecret) }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "limesurvey.databaseSecretName" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels:
    {{- include "limesurvey.labels" . | nindent 4 }}
type: Opaque
data:
  mariadb-password: {{ required "externalDatabase.password is required" .Values.externalDatabase.password | b64enc | quote }}
{{- end }}
{{- if not .Values.limesurvey.smtp.existingSecret }}
---
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "limesurvey.smtpSecretName" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels:
    {{- include "limesurvey.labels" . | nindent 4 }}
type: Opaque
data:
  {{- if .Values.limesurvey.smtp.password }}
  limesurvey-smtp-password: {{ .Values.limesurvey.smtp.password | b64enc | quote }}
  {{- else }}
  limesurvey-smtp-password: {{ randAlphaNum 15 | b64enc | quote }}
  {{- end }}
{{- end }}