apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "hlf-ca.fullname" . }}--db
  labels:
{{ include "labels.standard" . | indent 4 }}
data:
  DB_SSL: {{ .Values.db.ssl | quote }}
  {{- if .Values.postgresql.enabled }}
  # PostgreSQL Database
  DB_TYPE: "postgres"
  DB_HOST: {{ template "postgresql.fullname" . }}
  DB_PORT: {{ .Values.postgresql.service.port | quote }}
  DB_USERNAME: {{ .Values.postgresql.postgresqlUsername | quote }}
  DB_DATABASE: {{ .Values.postgresql.postgresqlDatabase  | quote }}
  {{- end }}
  {{- if .Values.mysql.enabled }}
  # MySQL Database
  DB_TYPE: "mysql"
  DB_HOST: {{ template "mysql.fullname" . }}
  DB_PORT: "3306"
  DB_USERNAME: {{ .Values.mysql.mysqlUser | quote }}
  DB_DATABASE: {{ .Values.mysql.mysqlDatabase  | quote }}
  {{- end }}
  {{- if .Values.externalDatabase.type }}
  # External Database
  DB_TYPE: {{ .Values.externalDatabase.type | quote }}
  DB_HOST: {{ .Values.externalDatabase.host | quote }}
  {{- if eq .Values.externalDatabase.type "mysql" }}
  DB_PORT: {{ .Values.externalDatabase.port | default "3306" | quote }}
  {{- end }}
  {{- if eq .Values.externalDatabase.type "postgres" }}
  DB_PORT: {{ .Values.externalDatabase.port | default "5432" | quote }}
  {{- end }}
  DB_USERNAME: {{ .Values.externalDatabase.username | quote }}
  DB_DATABASE: {{ .Values.externalDatabase.database  | quote }}
  {{- end }}