apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Release.Name }}-config
  labels:
    {{- include "switchboard.labels" . | nindent 4 }}
data:
  PORT: {{ .Values.backend.port | quote }}
  BASE_PATH: {{ .Values.basePath | quote }}
  ENVIRONMENT: {{ .Values.environment | quote }}
  DB_DRIVER: {{ .Values.database.driver | quote }}
  AUTH_MODE: {{ .Values.auth.mode | quote }}
  STORAGE_BACKEND: {{ .Values.storage.backend | quote }}
  STORAGE_PATH: {{ .Values.storage.path | quote }}
  SESSION_EXPIRY_DAYS: {{ .Values.sessionExpiryDays | quote }}
  WORKFLOW_STALE_HOURS: {{ .Values.workflowStaleHours | quote }}
  PROVIDER_AUTO_DISABLE_THRESHOLD: {{ .Values.providerAutoDisableThreshold | quote }}
  EXTRACTION_MODE: {{ .Values.extraction.mode | quote }}
  EXTRACTION_CONCURRENCY: {{ .Values.extraction.concurrency | quote }}
  WORKSPACE_INDEXING_ENABLED: {{ .Values.workspace.indexingEnabled | quote }}
  WORKSPACE_INDEX_CONCURRENCY: {{ .Values.workspace.indexConcurrency | quote }}
  LOG_FORMAT: {{ .Values.logging.format | default "text" | quote }}
  LOG_LEVEL: {{ .Values.logging.level | default "info" | quote }}
  CORS_ALLOWED_ORIGINS: {{ .Values.corsAllowedOrigins | quote }}
  {{- if .Values.storage.s3.endpoint }}
  S3_ENDPOINT: {{ .Values.storage.s3.endpoint | quote }}
  S3_BUCKET: {{ .Values.storage.s3.bucket | quote }}
  S3_REGION: {{ .Values.storage.s3.region | quote }}
  S3_PREFIX: {{ .Values.storage.s3.prefix | quote }}
  S3_FORCE_PATH_STYLE: {{ .Values.storage.s3.forcePathStyle | quote }}
  {{- end }}
  {{- if eq .Values.auth.mode "oidc" }}
  OIDC_ISSUER_URL: {{ .Values.auth.oidc.issuerURL | quote }}
  OIDC_EXTERNAL_ISSUER_URL: {{ .Values.auth.oidc.externalIssuerURL | quote }}
  OIDC_CLIENT_ID: {{ .Values.auth.oidc.clientID | quote }}
  OIDC_REDIRECT_URL: {{ .Values.auth.oidc.redirectURL | quote }}
  OIDC_AUTO_ACTIVATE: {{ .Values.auth.oidc.autoActivate | quote }}
  OIDC_DEFAULT_TEAM: {{ .Values.auth.oidc.defaultTeam | quote }}
  OIDC_DEFAULT_ROLE: {{ .Values.auth.oidc.defaultRole | quote }}
  OIDC_ROLES_CLAIM: {{ .Values.auth.oidc.rolesClaim | quote }}
  OIDC_GROUPS_CLAIM: {{ .Values.auth.oidc.groupsClaim | quote }}
  OIDC_ADMIN_ROLE: {{ .Values.auth.oidc.adminRole | quote }}
  {{- end }}
  {{- if eq .Values.auth.mode "mtls" }}
  MTLS_HEADER_DN: {{ .Values.auth.mtls.headerDN | quote }}
  MTLS_HEADER_VERIFY: {{ .Values.auth.mtls.headerVerify | quote }}
  MTLS_HEADER_FINGERPRINT: {{ .Values.auth.mtls.headerFingerprint | quote }}
  MTLS_AUTO_ACTIVATE: {{ .Values.auth.mtls.autoActivate | quote }}
  MTLS_DEFAULT_TEAM: {{ .Values.auth.mtls.defaultTeam | quote }}
  MTLS_DEFAULT_ROLE: {{ .Values.auth.mtls.defaultRole | quote }}
  {{- end }}
