# Installer Configuration - Nickel Format
# Auto-generated by provisioning TypeDialog
# Edit via: nu provisioning/.typedialog/provisioning/platform/scripts/configure.nu installer {mode}

let installer_schema = import "../schemas/installer.ncl" in

{
  installer | installer_schema.InstallerConfig = {
    # Workspace Configuration
    workspace = {
      {%- if workspace_name %}
      name = "{{ workspace_name }}",
      {%- endif %}
      {%- if workspace_path %}
      path = "{{ workspace_path }}",
      {%- endif %}
      {%- if workspace_enabled is defined %}
      enabled = {{ workspace_enabled | lower }},
      {%- endif %}
      {%- if multi_workspace_mode is defined %}
      multi_workspace = {{ multi_workspace_mode | lower }},
      {%- endif %}
    },

    # Installation Target Configuration
    target = {
      {%- if target_type %}
      target_type = "{{ target_type }}",
      {%- endif %}
      {%- if target_cloud_provider %}
      cloud_provider = "{{ target_cloud_provider }}",
      {%- endif %}
      {%- if target_region %}
      region = "{{ target_region }}",
      {%- endif %}
      {%- if target_host %}
      host = "{{ target_host }}",
      {%- endif %}
      {%- if target_ssh_key %}
      ssh_key = "{{ target_ssh_key }}",
      {%- endif %}
      {%- if target_ssh_user %}
      ssh_user = "{{ target_ssh_user }}",
      {%- endif %}
      {%- if target_ssh_port %}
      ssh_port = {{ target_ssh_port }},
      {%- endif %}
    },

    # Pre-flight Checks Configuration
    preflight = {
      {%- if preflight_enabled is defined %}
      enabled = {{ preflight_enabled | lower }},
      {%- endif %}
      {%- if preflight_check_disk_space is defined %}
      check_disk_space = {{ preflight_check_disk_space | lower }},
      {%- endif %}
      {%- if preflight_min_disk_gb %}
      min_disk_gb = {{ preflight_min_disk_gb }},
      {%- endif %}
      {%- if preflight_check_memory is defined %}
      check_memory = {{ preflight_check_memory | lower }},
      {%- endif %}
      {%- if preflight_min_memory_gb %}
      min_memory_gb = {{ preflight_min_memory_gb }},
      {%- endif %}
      {%- if preflight_check_cpu is defined %}
      check_cpu = {{ preflight_check_cpu | lower }},
      {%- endif %}
      {%- if preflight_min_cpu_cores %}
      min_cpu_cores = {{ preflight_min_cpu_cores }},
      {%- endif %}
      {%- if preflight_check_network is defined %}
      check_network = {{ preflight_check_network | lower }},
      {%- endif %}
      {%- if preflight_check_dependencies is defined %}
      check_dependencies = {{ preflight_check_dependencies | lower }},
      {%- endif %}
      {%- if preflight_check_ports is defined %}
      check_ports = {{ preflight_check_ports | lower }},
      {%- endif %}
    },

    # Installation Configuration
    installation = {
      {%- if installation_parallel_services %}
      parallel_services = {{ installation_parallel_services }},
      {%- endif %}
      {%- if installation_timeout_minutes %}
      timeout_minutes = {{ installation_timeout_minutes }},
      {%- endif %}
      {%- if installation_rollback_on_failure is defined %}
      rollback_on_failure = {{ installation_rollback_on_failure | lower }},
      {%- endif %}
      {%- if installation_keep_artifacts is defined %}
      keep_artifacts = {{ installation_keep_artifacts | lower }},
      {%- endif %}
    },

    # Service Selection
    services = {
      {%- if services_orchestrator is defined %}
      orchestrator = {{ services_orchestrator | lower }},
      {%- endif %}
      {%- if services_control_center is defined %}
      control_center = {{ services_control_center | lower }},
      {%- endif %}
      {%- if services_mcp_server is defined %}
      mcp_server = {{ services_mcp_server | lower }},
      {%- endif %}
    },

    # Database Configuration
    database = {
      {%- if database_auto_init is defined %}
      auto_init = {{ database_auto_init | lower }},
      {%- endif %}
      {%- if database_migrations_enabled is defined %}
      migrations = {
        enabled = {{ database_migrations_enabled | lower }},
        {%- if database_migrations_path %}
        path = "{{ database_migrations_path }}",
        {%- endif %}
      },
      {%- endif %}
      {%- if database_backup_before_upgrade is defined %}
      backup_before_upgrade = {{ database_backup_before_upgrade | lower }},
      {%- endif %}
    },

    # Storage Configuration
    storage = {
      {%- if storage_location %}
      location = "{{ storage_location }}",
      {%- endif %}
      {%- if storage_size_gb %}
      size_gb = {{ storage_size_gb }},
      {%- endif %}
      {%- if storage_compression is defined %}
      compression = {{ storage_compression | lower }},
      {%- endif %}
      {%- if storage_replication is defined %}
      replication = {{ storage_replication | lower }},
      {%- endif %}
    },

    # Networking Configuration
    networking = {
      {%- if networking_ports_orchestrator %}
      ports = {
        orchestrator = {{ networking_ports_orchestrator }},
        {%- if networking_ports_control_center %}
        control_center = {{ networking_ports_control_center }},
        {%- endif %}
        {%- if networking_ports_mcp_server %}
        mcp_server = {{ networking_ports_mcp_server }},
        {%- endif %}
      },
      {%- endif %}
      {%- if networking_load_balancer_enabled is defined %}
      load_balancer = {
        enabled = {{ networking_load_balancer_enabled | lower }},
        {%- if networking_load_balancer_type %}
        type = "{{ networking_load_balancer_type }}",
        {%- endif %}
      },
      {%- endif %}
      {%- if networking_ingress_enabled is defined %}
      ingress = {
        enabled = {{ networking_ingress_enabled | lower }},
        {%- if networking_ingress_hostname %}
        hostname = "{{ networking_ingress_hostname }}",
        {%- endif %}
        {%- if networking_ingress_tls is defined %}
        tls = {{ networking_ingress_tls | lower }},
        {%- endif %}
      },
      {%- endif %}
    },

    # High Availability Configuration
    {%- if ha_enabled is defined %}
    high_availability = {
      enabled = {{ ha_enabled | lower }},
      {%- if ha_replicas %}
      replicas = {{ ha_replicas }},
      {%- endif %}
      {%- if ha_health_checks_enabled is defined %}
      health_checks = {
        enabled = {{ ha_health_checks_enabled | lower }},
        {%- if ha_health_checks_interval %}
        interval_seconds = {{ ha_health_checks_interval }},
        {%- endif %}
      },
      {%- endif %}
      {%- if ha_auto_healing is defined %}
      auto_healing = {{ ha_auto_healing | lower }},
      {%- endif %}
      {%- if ha_backup_enabled is defined %}
      backup = {
        enabled = {{ ha_backup_enabled | lower }},
        {%- if ha_backup_interval %}
        interval_hours = {{ ha_backup_interval }},
        {%- endif %}
        {%- if ha_backup_retention %}
        retention_days = {{ ha_backup_retention }},
        {%- endif %}
      },
      {%- endif %}
    },
    {%- endif %}

    # Post-Installation Configuration
    {%- if post_install_enabled is defined %}
    post_install = {
      enabled = {{ post_install_enabled | lower }},
      {%- if post_install_verify_enabled is defined %}
      verify = {
        enabled = {{ post_install_verify_enabled | lower }},
        {%- if post_install_verify_timeout %}
        timeout_minutes = {{ post_install_verify_timeout }},
        {%- endif %}
      },
      {%- endif %}
      {%- if post_install_notify is defined %}
      notify = {{ post_install_notify | lower }},
      {%- endif %}
      {%- if post_install_notification_webhook %}
      notification_webhook = "{{ post_install_notification_webhook }}",
      {%- endif %}
    },
    {%- endif %}

    # Upgrade Configuration
    {%- if upgrades_auto_upgrade is defined %}
    upgrades = {
      auto_upgrade = {{ upgrades_auto_upgrade | lower }},
    },
    {%- endif %}

    # Monitoring Configuration (optional)
    {%- if monitoring_enabled is defined %}
    monitoring = {
      enabled = {{ monitoring_enabled | lower }},
    },
    {%- endif %}

    # Logging Configuration (optional)
    {%- if logging_level %}
    logging = {
      level = "{{ logging_level }}",
      {%- if logging_format %}
      format = "{{ logging_format }}",
      {%- endif %}
    },
    {%- endif %}
  },
}
