{{- if (not .Values.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "mariadb-galera.fullname" . }}
  labels: {{- include "mariadb-galera.labels" . | nindent 4 }}
type: Opaque
data:
  mariadb-root-password: {{ ternary (randAlphaNum 10) .Values.rootUser.password (empty .Values.rootUser.password) | b64enc | quote }}
  mariadb-password: {{ ternary (randAlphaNum 10) .Values.db.password (empty .Values.db.password) | b64enc | quote }}
  mariadb-galera-mariabackup-password: {{ ternary (randAlphaNum 10) .Values.galera.mariabackup.password (empty .Values.galera.mariabackup.password) | b64enc | quote }}
  {{- if and .Values.ldap.enabled .Values.ldap.bindpw }}
  ldap-bindpw: {{ .Values.ldap.bindpw | b64enc | quote }}
  {{- end }}
{{- end }}
