Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hcp: give a proper error when using conflicting build name #13300

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mogrogan
Copy link
Contributor

@mogrogan mogrogan commented Feb 17, 2025

It was possible to put the same source 2 times in the build and when using HCP, it would error eventually since they are considered the samebuild from HCP side

Test

packer {
  required_plugins {
    docker = {
      version = ">= 1.0.8"
      source = "github.com/hashicorp/docker"
    }
  }
}

source "docker" "ubuntu-jammy" {
  image  = "ubuntu:jammy"
  commit = true
}

source "docker" "ubuntu-focal" {
  image  = "ubuntu:focal"
  commit = true
}

build {
  name = "jammy-build-block"

  hcp_packer_registry {
    bucket_name = "test-root"
    description = "hcp test with root"
  }
  sources = [
    "source.docker.ubuntu-jammy",
    "source.docker.ubuntu-jammy",
  ]
}

This would give this error:

$ packer build .
Error: Build name conflicts

When using HCP registry, build names are used as identifier. In this case, there
is 2 or more build called jammy-build-block.docker.ubuntu-jammy

@mogrogan mogrogan requested a review from a team as a code owner February 17, 2025 21:23
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good to me, I think it maintains existing compatibility, but to be sure, have you run HPATS on those?
I left a couple comments, but nothing blocking, I'll let you address those and come back for another round of review later.

@mogrogan mogrogan force-pushed the prevent-name-conflicts-hcp branch 3 times, most recently from 1688277 to 2d88abf Compare February 20, 2025 20:27
@mogrogan mogrogan force-pushed the prevent-name-conflicts-hcp branch 4 times, most recently from cc744bb to 626f1c8 Compare February 25, 2025 18:49
It was possible to put the same source 2 times in the build and when
using HCP, it would error eventually since they are considered the same
build from HCP side
@mogrogan mogrogan force-pushed the prevent-name-conflicts-hcp branch from 626f1c8 to a98e2d4 Compare February 25, 2025 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants