# helm_source_secrets.yaml
{{- if (not .Values.rootUser.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "mariadb.fullname" . }}
  labels:
    app: "{{ template "mariadb.name" . }}"
    chart: {{ template "mariadb.chart" . }}
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
type: Opaque
data:
  {{- if .Values.rootUser.password }}
  mariadb-root-password: "{{ .Values.rootUser.password | b64enc }}"
  {{- else if (not .Values.rootUser.forcePassword) }}
  mariadb-root-password: "{{ randAlphaNum 10 | b64enc }}"
  {{ else }}
  mariadb-root-password: {{ required "A MariaDB Root Password is required!" .Values.rootUser.password }}
  {{- end }}
  {{- if .Values.db.user }}
  {{- if .Values.db.password }}
  mariadb-password: "{{ .Values.db.password | b64enc }}"
  {{- else if (not .Values.db.forcePassword) }}
  mariadb-password: "{{ randAlphaNum 10 | b64enc }}"
  {{- else }}
  mariadb-password: {{ required "A MariaDB Database Password is required!" .Values.db.password }}
  {{- end }}
  {{- end }}
  {{- if .Values.replication.enabled }}
  {{- if .Values.replication.password }}
  mariadb-replication-password: "{{ .Values.replication.password | b64enc }}"
  {{- else if (not .Values.replication.forcePassword) }}
  mariadb-replication-password: "{{ randAlphaNum 10 | b64enc }}"
  {{- else }}
  mariadb-replication-password: {{ required "A MariaDB Replication Password is required!" .Values.replication.password }}
  {{- end }}
  {{- end }}
{{- end }}