{{- if or (not .Values.global.excludePortals) (not (has "citizen" .Values.global.excludePortals)) }}
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Chart.Name }}
data:
  application.yaml: |-
    server:
      max-http-header-size: 32KB
    {{- if eq .Values.deployProfile "dev" }}
    management.endpoints.web.exposure.include: '*'
    {{- else }}
    management.endpoints.web.exposure.include: 'health, prometheus'
    {{- end }}
    data-platform:
      kafka:
        bootstrap: {{ .Values.kafka.service }}
        topic-properties:
          creation:
            num-partitions: {{ .Values.kafka.numPartitions }}
            replication-factor: {{ .Values.global.kafkaOperator.replicationFactor }}
        ssl:
          enabled: {{ .Values.kafka.sslEnabled }}
          keystore-certificate: {{ .Values.kafka.sslUserCertificate }}
          keystore-key: {{ .Values.kafka.sslUserKey }}
          truststore-certificate: {{ .Values.kafka.sslClusterCertificate }}
          keystore-type: {{ .Values.kafka.sslCertType }}
          truststore-type: {{ .Values.kafka.sslCertType }}
      datasource:
        url: jdbc:postgresql://{{.Values.db.url}}:{{.Values.db.port}}/{{.Values.db.name}}?ApplicationName={{ .Chart.Name }}
        connection-timeout: {{.Values.db.connectionTimeout}}

    keycloak:
      url: {{ template "keycloak.url" . }}
      citizen-user:
        realm: {{ template "keycloak.citizenTargetRealm" . }}
        client-id: {{ .Values.keycloak.citizenClient.clientName }}
      officer-user:
        realm: {{ template "keycloak.officerTargetRealm" . }}
        client-id: {{ .Values.keycloak.officerClient.clientName }}

    user-settings-service:
      url: {{ .Values.userSettingsService.url }}

    audit:
      kafka:
        bootstrap: {{ .Values.kafka.service }}
        topic: {{ .Values.audit.kafka.topic }}
        schema-registry-url: {{ .Values.audit.kafka.schemaRegistryUrl }}
        ssl:
          enabled: {{ .Values.kafka.sslEnabled }}
          keystore-certificate: {{ .Values.kafka.sslUserCertificate }}
          keystore-key: {{ .Values.kafka.sslUserKey }}
          truststore-certificate: {{ .Values.kafka.sslClusterCertificate }}

    spring:
      mail:
        host: ${notifications.email.host:localhost}
        port: ${notifications.email.port:3025}
        protocol: ${notifications.email.properties.mail.transport.protocol:smtp}
        properties:
          mail:
            smtp:
              auth: ${notifications.email.properties.mail.smtp.auth:true}
              starttls:
                enable: ${notifications.email.properties.mail.smtp.starttls.enable:true}
{{- end }}