-
Notifications
You must be signed in to change notification settings - Fork 330
HCP Packer Config Sourcer plugin #4251
HCP Packer Config Sourcer plugin #4251
Conversation
The HCP Packer plugin enables users to source a machine image ID from an HCP Packer registry by using a bucket name, channel name, region name, and cloud provider information to retrieve the HCP Packer bucket iteration assigned to a channel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job on this one! I've got a few minor code comments, but this looks great and will be an interesting addition to the Waypoint plugin collection! ✨
builtin/packer/config_sourcer.go
Outdated
return nil, err | ||
} | ||
|
||
doc.Description("Read machine image information from HCP Packer.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably have a bit more information here, like for example that only container images are valid, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitant to point out that only container images will work, since Packer supports more than just containers. Our plugins do work almost exclusively with containers, but since plugins don't have to, and since we have the EC2 plugin, I think it's okay to leave it at "image". However, I will at least add some color to this description! 😃
iteration := channel.Payload.Channel.Iteration | ||
|
||
// An iteration can have multiple builds, so we check for the first build | ||
// with the matching cloud provider and region. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting - is there a chance that we could unintentionally be picking the wrong build here? Or is "first" build essentially latest
build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With one packer build
operation, I have never tried to push more than one image of the same cloud provider and region to the same bucket in an HCP Packer registry. 🤔 I don't know for certain if it's possible or not, but maybe we could add more specific input parameters here in a follow up PR if it seems useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - totally fine to fix this up in a follow-up PR! Make an issue so we don't lose track 👍🏻
@paladin-devops is attempting to deploy a commit to the HashiCorp Team on Vercel. A member of the Team first needs to authorize it. |
The HCP Packer plugin added in this PR enables users to source a machine image ID from an HCP Packer channel. The user-configured bucket is checked for the specified channel. Within the channel, if the latest machine image iteration has a build that matches the desired cloud provider and region, it is returned to Waypoint. Below is an example of this being used to source the desired Nginx base image for a ReactJS app build, where the sourced machine image is templated into the Dockerfile.
Configuration source settings
waypoint.hcl
Dockerfile