apiVersion: v1
kind: ConfigMap
metadata:
  name: vapora-config
  namespace: vapora
  labels:
    app: vapora
    deployment-mode: {{ deployment_mode }}
data:
  deployment-mode: "{{ deployment_mode }}"
  workspace-name: "{{ workspace_name }}"

  # Backend Configuration
  backend-host: "{{ backend.host }}"
  backend-port: "{{ backend.port }}"
  backend-workers: "{{ backend.workers }}"
  backend-request-timeout: "{{ backend.request_timeout }}"
  backend-max-connections: "{{ backend.max_connections }}"
  backend-database-url: "{{ backend.database.url }}"
  backend-database-pool-size: "{{ backend.database.pool_size }}"
  backend-storage-path: "{{ backend.storage.path }}"
  backend-cache-ttl: "{{ backend.cache.ttl }}"
  backend-cache-max-size: "{{ backend.cache.max_size }}"

  # Frontend Configuration
  frontend-host: "{{ frontend.host }}"
  frontend-port: "{{ frontend.port }}"
  frontend-api-url: "{{ frontend.api_url }}"
  frontend-enable-wasm: "{{ frontend.enable_wasm }}"

  # Database Configuration
  database-url: "{{ database.url }}"
  database-name: "{{ database.database }}"
  database-pool-size: "{{ database.pool_size }}"

  # NATS Configuration
  nats-enabled: "{{ nats.enabled }}"
  nats-url: "{{ nats.url }}"
  nats-timeout: "{{ nats.timeout }}"

  # Agents Configuration
  agents-host: "{{ agents.host }}"
  agents-port: "{{ agents.port }}"
  agents-max-instances: "{{ agents.max_instances }}"
  agents-heartbeat-interval: "{{ agents.heartbeat_interval }}"
  agents-learning-enabled: "{{ agents.learning.enabled }}"
  agents-learning-recency-window-days: "{{ agents.learning.recency_window_days }}"
  agents-knowledge-graph-retention-days: "{{ agents.knowledge_graph.retention_days }}"
  agents-nats-enabled: "{{ agents.nats.enabled }}"

  # LLM Router Configuration
  llm-router-host: "{{ llm_router.host }}"
  llm-router-port: "{{ llm_router.port }}"
  llm-router-cost-tracking-enabled: "{{ llm_router.cost_tracking.enabled }}"
  llm-router-budget-enforcement-enabled: "{{ llm_router.budget_enforcement.enabled }}"
  llm-router-budget-window: "{{ llm_router.budget_enforcement.window }}"
  llm-router-claude-enabled: "{{ llm_router.providers.claude_enabled }}"
  llm-router-openai-enabled: "{{ llm_router.providers.openai_enabled }}"
  llm-router-gemini-enabled: "{{ llm_router.providers.gemini_enabled }}"
  llm-router-ollama-enabled: "{{ llm_router.providers.ollama_enabled }}"
  llm-router-ollama-url: "{{ llm_router.providers.ollama_url }}"
  llm-router-strategy: "{{ llm_router.routing.strategy }}"

  # Monitoring Configuration
  monitoring-prometheus-enabled: "{{ monitoring.prometheus_enabled }}"
  monitoring-log-level: "{{ monitoring.log_level }}"
  monitoring-tracing-enabled: "{{ monitoring.tracing_enabled }}"

  # Security Configuration
  security-tls-enabled: "{{ security.tls_enabled }}"
  security-tls-cert-path: "{{ security.tls_cert_path }}"
  security-tls-key-path: "{{ security.tls_key_path }}"

  # Storage Configuration
  storage-base-path: "{{ storage.base_path }}"
  storage-backup-enabled: "{{ storage.backup_enabled }}"
  storage-backup-interval: "{{ storage.backup_interval }}"

  # Full configuration as JSON for applications that need it
  config.json: |
    {
      "deployment_mode": "{{ deployment_mode }}",
      "workspace_name": "{{ workspace_name }}",
      "backend": {
        "host": "{{ backend.host }}",
        "port": {{ backend.port }},
        "workers": {{ backend.workers }},
        "request_timeout": {{ backend.request_timeout }},
        "max_connections": {{ backend.max_connections }},
        "database": {
          "url": "{{ backend.database.url }}",
          "pool_size": {{ backend.database.pool_size }}
        },
        "storage": {
          "path": "{{ backend.storage.path }}"
        }
      },
      "agents": {
        "host": "{{ agents.host }}",
        "port": {{ agents.port }},
        "max_instances": {{ agents.max_instances }},
        "learning": {
          "enabled": {{ agents.learning.enabled|lower }},
          "recency_window_days": {{ agents.learning.recency_window_days }}
        }
      },
      "llm_router": {
        "providers": {
          "claude_enabled": {{ llm_router.providers.claude_enabled|lower }},
          "openai_enabled": {{ llm_router.providers.openai_enabled|lower }},
          "gemini_enabled": {{ llm_router.providers.gemini_enabled|lower }},
          "ollama_enabled": {{ llm_router.providers.ollama_enabled|lower }}
        }
      }
    }
