# Integrations Defaults
#
# Default values for runtime abstraction and GitOps configurations.

let contracts = import "contracts.ncl" in

{
  # Default runtime configuration
  default_runtime_config | contracts.RuntimeConfig = {
    preferred = "docker",
    check_order = [
      "docker",
      "podman",
      "orbstack",
      "colima",
      "nerdctl",
    ],
    timeout_secs = 5,
    enable_cache = true,
  },

  # Default compose adapter config
  default_compose_config | contracts.ComposeAdapterConfig = {
    runtime = "docker",
    compose_file = "docker-compose.yml",
    environment = "dev",
  },

  # Default GitOps configuration
  default_gitops_config | contracts.GitOpsConfig = {
    rules = [],
    webhooks = [],
    scheduled = [],
    health_checks = [],
    default_strategy = "rolling",
    dry_run_by_default = false,
    enable_audit_log = true,
  },

  # Helper: Create default GitOps rule
  default_gitops_rule | not_exported = fun name repository command => {
    name = name,
    provider = "github",
    repository = repository,
    branch = "main",
    events = ["push"],
    targets = ["dev"],
    command = command,
    require_approval = false,
    concurrency_limit = 1,
  } | contracts.GitOpsRule,

  # Helper: Create default webhook config
  default_webhook | not_exported = fun provider => {
    provider = provider,
    port = 8080,
    allowed_events = ["push", "pull-request"],
  } | contracts.WebhookConfig,

  # Helper: Create default scheduled trigger
  default_scheduled_trigger | not_exported = fun name cron rule => {
    name = name,
    cron = cron,
    rule = rule,
    environment = "dev",
  } | contracts.ScheduledTrigger,

  # Helper: Create default health check trigger
  default_health_check | not_exported = fun name endpoint action => {
    name = name,
    endpoint = endpoint,
    interval_secs = 60,
    failure_threshold = 3,
    on_failure_action = action,
  } | contracts.HealthCheckTrigger,
}
