build: don't suggest lack of HCP support on fail #12835
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When running a build with HCP Packer enabled, Packer attempts to push the build status to HCP.
If the build fails, we update the status to BUILD_FAILED, and that's the end of it.
If however the build succeeds, Packer attempts to get the HCP artifact from the builder, which will only succeed if the builder supports it. Otherwise, we'll get either nil, or an artifact type that is not compatible with what is expected for HCP support.
When either of those happens, we warn that the builder may not support HCP Packer at all, so users are aware of the problem.
However, when the error was introduced, it only looked at the fact that an error was produced, independently of the type of error. This caused legitimate errors while building to be reported as potential incompatibility between the builder and HCP, which was confusing to users.
This commit changes this by introducing a new error type, only produced when the artifact either is nil, or failed to be deserialised into a HCP artifact, which lets us produce the incompatibility warning with more accuracy.