Update error messaging for HCP incompatible plugin builds (#12800)

* Update error messaging for HCP incompatible plugin builds

* Update command/build.go

Co-authored-by: Lucas Bajolet <105649352+lbajolet-hashicorp@users.noreply.github.com>

---------

Co-authored-by: Lucas Bajolet <105649352+lbajolet-hashicorp@users.noreply.github.com>
pull/12803/head
Wilken Rivera 2 years ago committed by GitHub
parent 3fa637c608
commit 12b8c885a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -25,6 +25,10 @@ import (
"github.com/posener/complete"
)
const (
hcpReadyIntegrationURL = "https://developer.hashicorp.com/packer/integrations?flags=hcp-ready"
)
type BuildCommand struct {
Meta
}
@ -202,6 +206,8 @@ func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int
m map[string]error
}{m: make(map[string]error)}
limitParallel := semaphore.NewWeighted(cla.ParallelBuilds)
var hasPossibleIncompatibleHCPIntegration bool
for i := range builds {
if err := buildCtx.Err(); err != nil {
log.Println("Interrupted, not going to start any more builds.")
@ -267,12 +273,13 @@ func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int
writeDiags(c.Ui, nil, hcl.Diagnostics{
&hcl.Diagnostic{
Summary: fmt.Sprintf(
"failed to complete HCP-enabled build %q",
"publishing build metadata to HCP Packer for %q failed",
name),
Severity: hcl.DiagError,
Detail: hcperr.Error(),
},
})
hasPossibleIncompatibleHCPIntegration = true
}
if err != nil {
@ -384,6 +391,15 @@ func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int
c.Ui.Say("\n==> Builds finished but no artifacts were created.")
}
if hasPossibleIncompatibleHCPIntegration {
msg := fmt.Sprintf(`
It looks like one or more plugins in your build may be incompatible with HCP Packer.
Check that you are using an HCP Ready integration before trying again:
%s`, hcpReadyIntegrationURL)
c.Ui.Error(msg)
}
if len(errs.m) > 0 {
// If any errors occurred, exit with a non-zero exit status
ret = 1

@ -641,7 +641,7 @@ func (bucket *Bucket) completeBuild(
err = decoder.Decode(state)
if err != nil {
return packerSDKArtifacts, fmt.Errorf(
"failed to obtain HCP Packer artifact from post-processor artifact: %w",
"failed to obtain HCP Packer compliant artifact: %w",
err)
}
log.Printf("[TRACE] updating artifacts for build %q", buildName)

@ -164,7 +164,7 @@ func (version *Version) statusSummary(ui sdkpacker.Ui) {
buf := &strings.Builder{}
buf.WriteString(fmt.Sprintf(
"\nVersion %q is not complete, the following builds are not done:\n\n",
"\nVersion %q is incomplete, the following builds are missing artifact metadata:\n\n",
version.Fingerprint))
for _, b := range rem {
buf.WriteString(fmt.Sprintf("* %q: %s\n", b.ComponentType, b.Status))

Loading…
Cancel
Save