---
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: backend
  namespace: django
spec:
  values:
    services:
      backend:
        envs:
          - name: ALLOWED_HOSTS
            value:
              _default: "*"
          - name: SERVER_USE_CHANGELOG
            value:
              _default: "0"
          - name: SERVER_ZITADEL_ENABLED
            value:
              _default: "True"
          - name: DJANGO_SETTINGS_MODULE
            value:
              _default: config.settings.production
          - name: CELERY_REDIS_HOST
            value:
              _default: redis
          - name: CELERY_REDIS_PORT
            value:
              _default: "6379"
          - name: DJANGO_REDIS_HOST
            value:
              _default: redis
          - name: SERVER_EXTERNAL_FIND_BY_USERNAME_ENABLED
            value:
              _default: "True"
          - name: SERVER_EXTERNAL_FIND_BY_EMAIL_ENABLED
            value:
              _default: "True"
          - name: DJANGO_REDIS_PORT
            value:
              _default: "6379"
          - name: BIMV2_INTERNAL_HOST
            value:
              _default: http://bim-backend-v2-service.bim-api
          - name: BIMV2_TIMEOUT
            value:
              _default: "60"
          - name: JWT_KID
            value:
              _default: "1"
          - name: PDM_SYNC
            value:
              _default: "1"
          - name: KC_SYNC_ENABLE
            value:
              _default: "0"
          - name: MEASUREMENTS_HOST
            value:
              _default: http://measurements-service.measurements.svc.cluster.local:8000/api
          - name: MEASUREMENTS_USE_MEASUREMENTS
            value:
              _default: "1"
          - name: SERVER_API_HOST
            value:
              _default: https://sarex.uralmine.com
          - name: SERVER_HOST
            value:
              _default: https://sarex.uralmine.com
          - name: WORKFLOWS_HOST
            value:
              _default: http://backend-svc.processing.svc.cluster.local:80
          - name: WORKFLOWS_BASE_HOST
            value:
              _default: http://backend-svc.django.svc.cluster.local:80
          - name: WORKFLOWS_PREFIX
            value:
              _default: /internal/v1
          - name: WORKFLOWS_USE
            value:
              _default: "1"
          - name: SERVER_S3_STREAM_IMPORT
            value:
              _default: "1"
          - name: SERVER_SAVE_DIFF_DEM
            value:
              _default: "1"
          - name: SERVER_USE_CLICKHOUSE
            value:
              _default: "0"
          - name: SERVER_USE_CREATE_COMPARED_GEOTIFF_TASK
            value:
              _default: "0"
          - name: SERVER_USE_DJANGO_STORAGE
            value:
              _default: "1"
          - name: SERVER_USE_METASHAPE
            value:
              _default: "0"
          - name: SERVER_CHANGELOG_MODE_SYSTEM_LOG
            value:
              _default: "1"
          - name: SERVER_CHANGELOG_MODE
            value:
              _default: "0"
          - name: SERVER_DJANGO_URLS
            value:
              _default: "1"
          - name: CHECK_IMPORT_HASH
            value:
              _default: "1"
          - name: EAV_ENABLE
            value:
              _default: "1"
          - name: SERVER_CHECK_IMPORT_HASH
            value:
              _default: "1"
          - name: SERVER_CHUNKED_PATH
            value:
              _default: /tmp/chunked_uploads/%Y/%m/%d
          - name: SERVER_HIDE_USER_SCROLL_PERMISSIONS
            value:
              _default: "0"
          - name: SERVER_USE_WRORKFLOW_STATUS
            value:
              _default: "1"
          - name: ZITADEL_HOST
            value:
              _default: https://sarex-login.uralmine.com
          # Включено вместе с message-hub: он консьюмер топика message-hub-stage
          # (SETTINGS_TOPICS в apps/message-hub/d8-ugmk-prod/message-hub.yaml),
          # а писать в этот топик должен django. Vault-шаблон django-kafka
          # и KAFKA_SSL_CAFILE уже есть в base — здесь только флаг.
          - name: SERVER_KAFKA_ENABLED
            value:
              _default: "True"
          - name: KAFKA_TOPICS
            value:
              _default: '{"planning": "message-hub-stage", "ams-sync": "ams-sync"}'
          - name: KAFKA_SSL_CAFILE
            value:
              _default: /usr/local/share/ca-certificates/kafka.crt
          - name: KC_USE_REDIRECT_LOGOUT
            value:
              _default: "False"
        podAnnotations:
          _default:
            vault.hashicorp.com/agent-inject-template-django-s3: |-
              {{- with secret "secrets/data/minio/apps/django" }}
              AWS_S3_ENDPOINT_URL=https://s3.uralmine.com
              S3_HOST=https://s3.uralmine.com
              {{- $buckets := index .Data.data "buckets" }}
              S3_BUCKET={{ if gt (len $buckets) 0 }}{{ index (index $buckets 0) "name" }}{{ else }}django{{ end }}
              S3_LOGIN={{ index .Data.data "access_key" }}
              S3_PASSWORD={{ index .Data.data "secret_key" }}
              AWS_S3_ACCESS_KEY_ID={{ index .Data.data "access_key" }}
              AWS_S3_SECRET_ACCESS_KEY={{ index .Data.data "secret_key" }}
              AWS_STORAGE_BUCKET_NAME={{ if gt (len $buckets) 0 }}{{ index (index $buckets 0) "name" }}{{ else }}django{{ end }}
              {{- end }}
