# Generic HCL2 image-build definition. Not tied to any one tool: the point is the HCL2 grammar
# (blocks with labels, heredocs, interpolation, functions), not a vendor's schema.
variable "version_tag" {
  type    = string
  default = "1.4.0"
}

variable "channels" {
  type    = list(string)
  default = ["stable", "edge"]
}

locals {
  build_name = "novus-${var.version_tag}"
  timestamp  = "2026-01-15T09:30:00Z"
}

source "example-builder" "base" {
  image_family  = "example-linux-1"
  machine_type  = "example-medium"
  disk_size_gb  = 20
  ssh_username  = "builder"

  labels = {
    name    = local.build_name
    channel = var.channels[0]
  }
}

build {
  name    = local.build_name
  sources = ["source.example-builder.base"]

  provisioner "inline-notes" {
    notes = <<-EOT
      This heredoc is indented content with the leading whitespace stripped by <<-.
      It exists so an HCL parser has a real multi-line string to handle,
      including an interpolated value: ${local.build_name}.
    EOT
  }

  provisioner "file-list" {
    files = [
      for channel in var.channels : "manifests/${channel}.json"
    ]
  }

  post-processor "manifest" {
    output     = "manifest.json"
    strip_path = true
  }
}
