When an override block is either not an object, or if one of its
contents are not an object, Packer would crash trying to forcefully
cast the cty.Value to a cty.Collection.
To avoid this behaviour, we add extra checks that return hcl.Diagnostics
when they fail.
When we try to validate a build that contains references to
hcp_packer_image, the data is not fetched, and the value is therefore
unknown.
However, during the decoding phase for the build blocks, we attempt to
fetch the ancestry information for the current build, from the
information previously fetched from HCP.
Since we're validating, there's no way this is set, and attempting to
cast without checking causes Packer to crash on the conversion.
To avoid this, we only attempt this conversion if the value is known.
Closes#11870
* Add `component_type` optional field
to support specifying the exact build image when multiple images exist in the same provider and region for a given iteration
* update docs
* update docs
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.
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.
* registry: add heartbeat call for running builds
When a build is running, we send periodic heartbeats to HCP Packer's
API.
This will be used on the service side to detect if a build is stalled on
the core side because of a crash or any other malfunction that caused
Packer not to send an update on the status of a build.
* registry: only update status on status update
Prior to this commit, we'd send updates to both the labels and the
cloud-provider whenever an update to the status of a build would be
sent.
This would cause a bug in which once a build reached the post-processing
state, and its cloud-provider was set, the status could not be updated
anymore, as the cloud-provider would be set and further updates are
rejected by the platform.
To avoid this problem, we only transmit the status when doing a status
update, and no other fields along with it.
* internal: publicise CompleteBuild function
The markBuildComplete private function used to be called from a final
status update to DONE, through the UpdateBuildStatus function.
The problem being that the (now) CompleteBuild function not only updates
the status of the build, but also all its metadata.
For consistency, we remove the indirection, and explicitely call
CompleteBuild when we want to finish a build.
* internal: block status updates on DONE builds
This change brings in updates to Packer's usage of the go-getter plugin
used within the SDK for downloading ISO files. This can be a potentially
breaking change for some plugins as the update go-getter settings in the
SDK prevent reading/writing to suddir that require upload path
traversal (e.g /tmp/.../etc/hosts).
This change also includes 30 minute maximum timeouts for file
downloading to prevent resource exhaustion. This can be an issue for
very large or slow downloads if they exceed more then 30 minutes to
complete.
* Add support for data source lookup
* Update failing test
* Fix typo for HCP_PACKER_BUILD_FINGERPRINT env in test
* Add test Fingerprint where needed; failing tests were not showing
because they are properly set for acctest
* Update to use BuildContext
Packer does not require the installation of a Packer user or a service for Packer.
This change removes the preinst and postrm user scripts, and the config_dir directive for Packer rpm installations.
Closes#11828
* workflows: + automatic label/response on question
When a user asks a question through an issue on this repository, we
automatically add a comment, pointing to the forums, and add a label to
the issue so we can spot more easily which issues need to be acted on.
* .github: + link to packer community for questions
As extra to the github action, this commit adds an extra button to the
new issue template, leading directly to the discuss forums for Packer
* .github: add auto-stale-close issue action
As follow-up to the labelling of question type issues as needs-reply, we
add another action that will automatically mark an issue as stale if it
has not been updated for 3 weeks, and close the issue one week after
marking it as stale.
* Update .github/workflows/issues-opened.yml
Co-authored-by: Wilken Rivera <[email protected]>
* provisioner/shell: add support for Env variables
As mentioned in issue #11670, the Shell provider did not support Env
variable declarations in the HCL templates.
This commit adds the capability to the code.
* provisioner/powershell: add support for Env vars
* provisioner/windows-shell: support Env variables