apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ include "eddi.fullname" . }}-config
  labels:
    {{- include "eddi.labels" . | nindent 4 }}
data:
  EDDI_DATASTORE_TYPE: {{ .Values.eddi.datastoreType | quote }}
  {{- if .Values.mongodb.enabled }}
  MONGODB_CONNECTIONSTRING: "mongodb://{{ include "eddi.fullname" . }}-mongodb:27017/eddi?retryWrites=true&w=majority&connectTimeoutMS=10000&socketTimeoutMS=30000"
  {{- end }}
  {{- if .Values.postgres.enabled }}
  QUARKUS_PROFILE: "postgres"
  QUARKUS_DATASOURCE_JDBC_URL: "jdbc:postgresql://{{ include "eddi.fullname" . }}-postgres:5432/{{ .Values.postgres.database }}"
  {{- end }}
  EDDI_MESSAGING_TYPE: {{ .Values.eddi.messagingType | quote }}
  {{- if .Values.nats.enabled }}
  EDDI_NATS_URL: "nats://{{ include "eddi.fullname" . }}-nats:4222"
  {{- end }}
  QUARKUS_HTTP_CORS_ORIGINS: {{ .Values.eddi.corsOrigins | quote }}
  QUARKUS_OIDC_TENANT_ENABLED: {{ .Values.eddi.oidc.enabled | quote }}
  {{- if .Values.eddi.oidc.enabled }}
  {{- if .Values.keycloak.enabled }}
  QUARKUS_OIDC_AUTH_SERVER_URL: "http://{{ include "eddi.fullname" . }}-keycloak:8080/realms/eddi"
  {{- else }}
  QUARKUS_OIDC_AUTH_SERVER_URL: {{ .Values.eddi.oidc.authServerUrl | quote }}
  {{- end }}
  QUARKUS_OIDC_CLIENT_ID: {{ .Values.eddi.oidc.clientId | quote }}
  {{- end }}
