apiVersion: v1
kind: ConfigMap
metadata:
  name: "{{ template "airflow.fullname" . }}-env"
  labels:
    app: {{ template "airflow.name" . }}
    chart: {{ template "airflow.chart" . }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
data:
  ## Force UTC timezone
  TZ: Etc/UTC
  ## Postgres DB configuration
  POSTGRES_HOST: "{{ template "airflow.postgresql.fullname" . }}"
  POSTGRES_PORT: "{{ .Values.postgresql.service.port }}"
  POSTGRES_DB: "{{ .Values.postgresql.postgresDatabase }}"
  ## Redis DB configuration
  REDIS_HOST: "{{ template "airflow.redis.fullname" . }}"
  REDIS_PORT: "{{ .Values.redis.master.port }}"
  ## Flower PORT
  FLOWER_PORT: "5555"
  # Configure puckel's docker-airflow entrypoint
  EXECUTOR: "{{ .Values.airflow.executor }}"
  FERNET_KEY: "{{ .Values.airflow.fernetKey }}"
  DO_WAIT_INITDB: "false"
  ## Custom Airflow settings
  AIRFLOW__CORE__DONOT_PICKLE: "{{ .Values.dags.doNotPickle }}"
  AIRFLOW__CELERY__FLOWER_URL_PREFIX: "{{ .Values.ingress.flower.path }}"
  AIRFLOW__CELERY__WORKER_CONCURRENCY: "{{ .Values.workers.celery.instances }}"
  AIRFLOW__CORE__DAGS_FOLDER: "{{ .Values.dags.path }}"
  AIRFLOW__WEBSERVER__BASE_URL: "http://localhost:8080{{ .Values.ingress.web.path }}"
  # Disabling XCom pickling for forward compatibility
  AIRFLOW__CODE__ENABLE_XCOM_PICKLING: "false"
  # For backwards compat with AF < 1.10, CELERY_CONCURRENCY got renamed to WORKER_CONCURRENCY
  AIRFLOW__CELERY__CELERY_CONCURRENCY: "{{ .Values.workers.celery.instances }}"
  # Note: changing `Values.airflow.config` won't change the configmap checksum and so won't make
  # the pods to restart
  {{- range $setting, $option := .Values.airflow.config }}
  {{ $setting }}: "{{ $option }}"
  {{- end }}
