{{- if not .Values.limesurvey.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 }}
  {{- if .Values.limesurvey.encrypt.keypair }}
  limesurvey-encrypt-keypair: {{ .Values.limesurvey.encrypt.keypair | b64enc | quote }}
  {{- end }}
  {{- if .Values.limesurvey.encrypt.publicKey }}
  limesurvey-encrypt-publickey: {{ .Values.limesurvey.encrypt.publicKey | b64enc | quote }}
  {{- end }}
  {{- if .Values.limesurvey.encrypt.secretKey }}
  limesurvey-encrypt-secretkey: {{ .Values.limesurvey.encrypt.secretKey | b64enc | quote }}
  {{- end }}
  {{- if .Values.limesurvey.encrypt.nonce }}
  limesurvey-encrypt-nonce: {{ .Values.limesurvey.encrypt.nonce | b64enc | quote }}
  {{- end }}
  {{- if .Values.limesurvey.encrypt.secretBoxKey }}
  limesurvey-encrypt-secretboxkey: {{ .Values.limesurvey.encrypt.secretBoxKey | 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:
  db-password: {{ required "externalDatabase.password is required" .Values.externalDatabase.password | b64enc | quote }}
{{- end }}
