Skip to content

Commit

Permalink
chore: change snapshot detection to prefix detection
Browse files Browse the repository at this point in the history
If the provided checksum does not have a prefix, we assume it is user-provided,
and should be treated as a snapshot.
  • Loading branch information
neezer committed Aug 27, 2024
1 parent e195f91 commit e7ec338
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions openbsd.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ variable "readonly_boot_media" {
locals {
image_architecture = var.architecture == "x86-64" ? "amd64" : var.architecture
image = "miniroot${replace(var.os_version, ".", "")}.img"
has_checksum_prefix = substr(var.checksum, 0, 7) == "sha256:"

image_full_remote_path = (
length(var.checksum) != 0
? "snapshots/${local.image_architecture}/${local.image}"
: "${var.os_version}/${local.image_architecture}/${local.image}"
has_checksum_prefix
? "${var.os_version}/${local.image_architecture}/${local.image}"
: "snapshots/${local.image_architecture}/${local.image}"
)

checksum = substr(var.checksum, 0, 7) == "sha256:" ? var.checksum : join(":", ["sha256", var.checksum])
checksum = has_checksum_prefix ? var.checksum : join(":", ["sha256", var.checksum])
vm_name = "openbsd-${var.os_version}-${var.architecture}.qcow2"

iso_target_extension = "img"
Expand Down

0 comments on commit e7ec338

Please sign in to comment.