mirror of
https://github.com/hashicorp/packer.git
synced 2026-02-27 03:51:20 -05:00
* Add working registry pkg * Add custom error for handling the loading of PAR environment variables * Working Publish to Build, with proper error handling for bucket names * Update hcp-sdk-go to use branch instead of mod replace directive * Update Packer build status configuration * Add support for HCP_PACKER_BUILD_FINGERPRINT env * Add support for publishing one or more PARtifacts from a single build * add git shas to this branch * Add ability to set provider name if available * Add working RegistryBuilder type * Add RegistryPostProcessor as wrapper post-processor * When in PAR mode a empty RegistryPostProcessor is added to the end of the post-processor list to publish all final image data. * Add support for updating a build from PAR that is not in a DONE state * Fix a small issue with creation the initial builds for an empty iteration. * Add PAR URL to post-processor display * Implement hcp_packer_registry block (#11168) * Update vendored Amazon plugin to v1.0.1-dev * Fix panic when running a Packer registry build in a clean directory * Remove the publishing of post-processor metadata from the registry post-processor. * Remove metadata add from registry_builder * Update registry builder to skip a build that was found to be DONE Co-authored-by: Megan Marsh <megan@hashicorp.com> Co-authored-by: Sylvia Moss <moss@hashicorp.com>
68 lines
2 KiB
Go
68 lines
2 KiB
Go
package command
|
|
|
|
import (
|
|
"github.com/hashicorp/hcl/v2"
|
|
packerregistry "github.com/hashicorp/packer/internal/packer_registry"
|
|
"github.com/hashicorp/packer/packer"
|
|
plugingetter "github.com/hashicorp/packer/packer/plugin-getter"
|
|
)
|
|
|
|
// CoreWrapper wraps a packer.Core in order to have it's Initialize func return
|
|
// a diagnostic.
|
|
type CoreWrapper struct {
|
|
*packer.Core
|
|
}
|
|
|
|
func (c *CoreWrapper) Initialize(_ packer.InitializeOptions) hcl.Diagnostics {
|
|
err := c.Core.Initialize()
|
|
if err != nil {
|
|
return hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Detail: err.Error(),
|
|
Severity: hcl.DiagError,
|
|
},
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *CoreWrapper) PluginRequirements() (plugingetter.Requirements, hcl.Diagnostics) {
|
|
return nil, hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Summary: "Packer init is supported for HCL2 configuration templates only",
|
|
Detail: "Please manually install plugins or use a HCL2 configuration that will do that for you.",
|
|
Severity: hcl.DiagError,
|
|
},
|
|
}
|
|
}
|
|
|
|
// ConfiguredArtifactMetadataPublisher returns a configured image bucket that can be used for publishing
|
|
// build image artifacts to a configured Packer Registry destination.
|
|
func (c *CoreWrapper) ConfiguredArtifactMetadataPublisher() (*packerregistry.Bucket, hcl.Diagnostics) {
|
|
bucket := c.Core.GetRegistryBucket()
|
|
|
|
// If at this point the bucket is nil, it means the HCP Packer registry is not enabled
|
|
if bucket == nil {
|
|
return nil, hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Summary: "Publishing build artifacts to HCP Packer Registry not enabled",
|
|
Detail: "No Packer Registry configuration detected; skipping all publishing steps " +
|
|
"See publishing to a Packer registry for Packer configuration details",
|
|
Severity: hcl.DiagWarning,
|
|
},
|
|
}
|
|
}
|
|
|
|
err := bucket.Validate()
|
|
if err != nil {
|
|
return nil, hcl.Diagnostics{
|
|
&hcl.Diagnostic{
|
|
Summary: "Invalid HCP Packer Registry configuration",
|
|
Detail: err.Error(),
|
|
Severity: hcl.DiagError,
|
|
},
|
|
}
|
|
}
|
|
|
|
return bucket, nil
|
|
}
|