apiVersion: v1
kind: Secret
metadata:
  name: {{ template "common.names.fullname" . }}
  namespace: {{ .Release.Namespace | quote }}
  labels: {{- include "common.labels.standard" . | nindent 4 }}
    {{- if .Values.commonLabels }}
    {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
    {{- end }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: Opaque
data:
{{- if not .Values.mysql.enabled }}
{{- range $key, $value := .Values.mysql.external }}
  {{ $key }}: {{ $value | b64enc | quote }}
{{- end }}
{{- else }}
  mysqlMasterHost: {{ (include "nacos.mysql.primaryHost" .) | b64enc | quote }}
  mysqlDatabase: {{ .Values.mysql.auth.database | b64enc | quote }}
  mysqlMasterPort: {{ "3306" | b64enc }}
  mysqlMasterUser: {{ .Values.mysql.auth.username | b64enc | quote }}
  mysqlMasterPassword: {{ .Values.mysql.auth.password | b64enc | quote }}
  mysqlSlaveHost: {{ (include "nacos.mysql.secondaryHost" .) | b64enc | quote }}
  mysqlSlavePort: {{ "3306" | b64enc }}
{{- end }}
{{- if .Values.secret.enabled }}
{{- range $key, $value := .Values.secret.data }}
  {{ $key }}: {{ $value | b64enc | quote }}
{{- end }}
{{- end }}
