-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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-packer-image: add support for channel #11865
Conversation
d73699c
to
bff441f
Compare
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.
Looks good so far! Docs are not being rendered because the new file is not mentioned in the data source documentation. Anyways, I left a comment about making both fields required so they appear under the required fields in the documentation. Let me know what you think about it.
datasource/hcp-packer-image/data.go
Outdated
if d.config.Channel != "" && | ||
d.config.IterationID != "" { | ||
errs = packersdk.MultiErrorAppend(errs, errors.New( | ||
"`iteration_id` and `channel` cannot both be specified")) |
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.
"`iteration_id` and `channel` cannot both be specified")) | |
"`iteration_id` and `channel` cannot both be specified.")) |
datasource/hcp-packer-image/data.go
Outdated
if d.config.Channel == "" && | ||
d.config.IterationID == "" { | ||
errs = packersdk.MultiErrorAppend(errs, errors.New( | ||
"The `iteration_id` or `channel` must be specified")) |
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.
"The `iteration_id` or `channel` must be specified")) | |
"The `iteration_id` or `channel` must be specified.")) |
@@ -0,0 +1,19 @@ | |||
<!-- Code generated from the comments of the Config struct in datasource/hcp-packer-image/data.go; DO NOT EDIT MANUALLY --> |
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 a new file that has to be included in the data source main mdx
file to appear in the docs.
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'll keep that in mind for future changes, though with your next comment, this will remove this file from the commit :)
datasource/hcp-packer-image/data.go
Outdated
// Either this or `iteration_id` MUST be set. | ||
// | ||
// Mutually exclusive with `iteration_id` | ||
Channel string `mapstructure:"channel" required:"false"` |
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.
Packer let's you set these two as required and at the same time let them not be set. The validation of those required fields is just the one you implemented. I've seen other plugins with mutually exclusive configs that were required.
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.
That's good to know, I thought the HCL2 parser would check this, if that's not the case then perfect, it will be clearer if we include them in the required block, with a note stating they're mutually exclusive.
bff441f
to
63c5604
Compare
datasource/hcp-packer-image/data.go
Outdated
// The name of the channel to use when retrieving your image. | ||
// | ||
// If using several images from a single iteration, you may prefer | ||
// sourcing an iteration first, and referencing it for subsequent uses, | ||
// as getting the iteration induces a potentially billable request. | ||
// | ||
// Either this or `iteration_id` MUST be set. | ||
// | ||
// Mutually exclusive with `iteration_id` | ||
Channel string `mapstructure:"channel" required:"true"` | ||
// The ID of the iteration to use when retrieving your image | ||
// | ||
// Either this or `channel` MUST be set. | ||
// | ||
// Mutually exclusive with `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.
The doc looks a bit weird with the spaces
https://packer-2v4m5mwco-hashicorp.vercel.app/docs/datasources/hcp/hcp-packer-image#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.
Very true. I'll get that more consistent before we merge this.
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.
🎉 👍🏼
63c5604
to
c98dffd
Compare
c98dffd
to
c259839
Compare
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.
LGTM, I think you should consider my docs nit change though, let me know what you think!
website/content/partials/datasource/hcp-packer-image/Config-required.mdx
Outdated
Show resolved
Hide resolved
website/content/partials/datasource/hcp-packer-image/Config-required.mdx
Outdated
Show resolved
Hide resolved
website/content/partials/datasource/hcp-packer-image/Config-required.mdx
Outdated
Show resolved
Hide resolved
In addition to the current way of specifying an image based on an iteration on HCP Packer, which requires first declaring an iteration, and then referencing it from the image to build, we add the capacity of specifying a channel. This alternative will get the iteration linked to the channel, and is essentially a more convenient way to get an image's metadata from HCP Packer. This commit is essentially a backport from the Terraform HCP provider, for consistency between the two tools.
The comment was mentioning the name of an iteration Id, which is conflicting. This commit rephrases the comment to directly specify the ID of the iteration.
c259839
to
b29be57
Compare
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
In addition to the current way of specifying an image based on an
iteration on HCP Packer, which requires first declaring an iteration,
and then referencing it from the image to build, we add the capacity of
specifying a channel.
This alternative will get the iteration linked to the channel, and is
essentially a more convenient way to get an image's metadata from HCP
Packer.
This commit is essentially a backport from the Terraform HCP provider,
for consistency between the two tools.