{{- if .Values.dataintegration.enabled }}
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ template "cmem.name-di" . }}
  labels:
    {{- include "cmem.labels-di" . | nindent 4 }}
data:
  SERVER_CONTEXTPATH: "{{ .Values.dataintegration.config.contextPath }}/"
  SERVER_PORT: {{ .Values.dataintegration.service.port | quote }}
  SERVER_REQUEST_TIMEOUT: {{ .Values.dataintegration.config.requestTimeout | quote }}
  SERVER_IDLE_TIMEOUT: {{ .Values.dataintegration.config.idleTimeout | quote }}
  JAVA_TOOL_OPTIONS: "{{ .Values.dataintegration.config.javaToolOptions }} -XX:MaxMetaspaceSize=512M -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djava.io.tmpdir={{ .Values.dataintegration.cache.cacheBasePath }} "
  MAX_UPLOAD_FILE_SIZE: {{ .Values.dataintegration.config.maxUploadFileSize | quote }}
  DEPLOY_HOSTNAME: {{ .Values.global.hostname }}
  DEPLOY_PROTOCOL: {{ .Values.global.protocol }}
  DEPLOY_BASE_URL: {{ .Values.global.protocol }}://{{ .Values.global.hostname }}
  EXPLORE_BACKEND_URL: {{ .Values.dataintegration.config.exploreBackendUrl | default (printf "http://%s.%s:%s%s" .Values.explore.service.name .Release.Namespace (.Values.explore.service.port | toString ) .Values.explore.config.backendContextPath ) | quote }}
  EXPLORE_FRONTEND_URL: {{ .Values.global.protocol }}://{{ .Values.global.hostname }}
  OAUTH_AUTHORIZATION_URL: {{ print .Values.global.keycloakIssuerUrl "/protocol/openid-connect/auth" | quote }}
  OAUTH_LOGOUT_URL: {{ tpl .Values.global.keycloakLogoutURL . }}
  OAUTH_LOGOUT_REDIRECT_URL: {{ tpl .Values.global.validPostLogoutRedirectUri . }}
  OAUTH_TOKEN_URL: {{ print .Values.global.keycloakIssuerUrl "/protocol/openid-connect/token" | quote }}
  OAUTH_CLIENT_ID: {{ .Values.global.oauthClientId | quote }}
  DATAINTEGRATION_EXECUTOR: {{ .Values.dataintegration.config.executor | quote }}
  PRODUCTION_CONFIG_FILE: /opt/cmem/eccenca-DataIntegration/dist/etc/dataintegration/conf/dataintegration.conf
  COM_ECCENCA_DI_GEO_URL: {{ .Values.dataintegration.config.geoUrl | default "https://photon.komoot.de/api" | quote }}
  DATAINTEGRATION_PLUGIN_FOLDER: {{ .Values.dataintegration.config.pluginFolder | quote }}
  DATA_HOME: {{ .Values.dataintegration.config.home | quote }}
  PYTHONPATH: {{ .Values.dataintegration.config.pythonPluginFolder | quote }}
  LC_ALL: C.UTF-8
  LANG: C.UTF-8
  DATAINTEGRATION_SECURE_COOKIE: {{ .Values.dataintegration.config.secureCookie | quote }}
  {{- if and .Values.dataintegration.initContainer.enabled .Values.global.customCACerts .Values.dataintegration.initContainer.customCACerts.enabled }}
  REQUESTS_CA_BUNDLE: /cacerts/pythoncacerts
  {{- end }}
  CERTIFICATE_DIRECTORY: /cacerts
  DATAINTEGRATION_AI_USE_EXPLORE_GATEWAY: {{ .Values.dataintegration.config.mappingCreator.useDataPlatformGateway | quote }}
  {{- if not .Values.dataintegration.config.mappingCreator.useDataPlatformGateway }}
  DATAINTEGRATION_AI_ORGID: {{ .Values.dataintegration.config.mappingCreator.AiOrgId | quote }}
  DATAINTEGRATION_AI_MODEL: {{ .Values.dataintegration.config.mappingCreator.AiModel | quote }}
  DATAINTEGRATION_AI_COREURL: {{ .Values.dataintegration.config.mappingCreator.AiCoreUrl | quote }}
  DATAINTEGRATION_AI_REASONINGEFFORT: {{ .Values.dataintegration.config.mappingCreator.AiReasoningEffort | quote }}
  {{- end }}
  DATAINTEGRATION_AI_LOGQUERIES: {{ .Values.dataintegration.config.mappingCreator.AiLogQueries | quote }}
  {{- if .Values.dataintegration.config.additionalEnvVars }}
  {{- .Values.dataintegration.config.additionalEnvVars | toYaml | nindent 2 }}
  {{- end }}
{{- end }}
