mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-21 07:21:40 -04: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 <[email protected]> Co-authored-by: Sylvia Moss <[email protected]>
94 lines
2.9 KiB
Go
94 lines
2.9 KiB
Go
package packer
|
|
|
|
import (
|
|
"github.com/hashicorp/hcl/v2"
|
|
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
|
packerregistry "github.com/hashicorp/packer/internal/packer_registry"
|
|
plugingetter "github.com/hashicorp/packer/packer/plugin-getter"
|
|
)
|
|
|
|
type GetBuildsOptions struct {
|
|
// Get builds except the ones that match with except and with only the ones
|
|
// that match with Only. When those are empty everything matches.
|
|
Except, Only []string
|
|
Debug, Force bool
|
|
OnError string
|
|
|
|
// count only/except match count; so say something when nothing matched.
|
|
ExceptMatches, OnlyMatches int
|
|
}
|
|
|
|
type BuildGetter interface {
|
|
// GetBuilds return all possible builds for a config. It also starts all
|
|
// builders.
|
|
// TODO(azr): rename to builder starter ?
|
|
GetBuilds(GetBuildsOptions) ([]packersdk.Build, hcl.Diagnostics)
|
|
}
|
|
|
|
type Evaluator interface {
|
|
// EvaluateExpression is meant to be used in the `packer console` command.
|
|
// It parses the input string and returns what needs to be displayed. In
|
|
// case of an error the error should be displayed.
|
|
EvaluateExpression(expr string) (output string, exit bool, diags hcl.Diagnostics)
|
|
}
|
|
|
|
type InitializeOptions struct {
|
|
// When set, the execution of datasources will be skipped and the datasource will provide
|
|
// an output spec that will be used for validation only.
|
|
SkipDatasourcesExecution bool
|
|
}
|
|
|
|
// The Handler handles all Packer things. This interface reflects the Packer
|
|
// commands, ex: init, console ( evaluate ), fix config, inspect config, etc. To
|
|
// run a build we will start the builds and then the core of Packer handles
|
|
// execution.
|
|
type Handler interface {
|
|
Initialize(InitializeOptions) hcl.Diagnostics
|
|
// PluginRequirements returns the list of plugin Requirements from the
|
|
// config file.
|
|
PluginRequirements() (plugingetter.Requirements, hcl.Diagnostics)
|
|
Evaluator
|
|
BuildGetter
|
|
ConfigFixer
|
|
ConfigInspector
|
|
HCPHandler
|
|
}
|
|
|
|
// The HCPHandler handles Packer things needed for communicating with a HCP Packer Registry.
|
|
type HCPHandler interface {
|
|
// ConfiguredArtifactMetadataPublisher returns a configured Bucket that can be used to publish
|
|
// build artifacts to the said image bucket.
|
|
ConfiguredArtifactMetadataPublisher() (*packerregistry.Bucket, hcl.Diagnostics)
|
|
}
|
|
|
|
//go:generate enumer -type FixConfigMode
|
|
type FixConfigMode int
|
|
|
|
const (
|
|
// Stdout will make FixConfig simply print what the config should be; it
|
|
// will only work when a single file is passed.
|
|
Stdout FixConfigMode = iota
|
|
// Inplace fixes your files on the spot.
|
|
Inplace
|
|
// Diff shows a full diff.
|
|
Diff
|
|
)
|
|
|
|
type FixConfigOptions struct {
|
|
Mode FixConfigMode
|
|
}
|
|
|
|
type ConfigFixer interface {
|
|
// FixConfig will output the config in a fixed manner.
|
|
FixConfig(FixConfigOptions) hcl.Diagnostics
|
|
}
|
|
|
|
type InspectConfigOptions struct {
|
|
packersdk.Ui
|
|
}
|
|
|
|
type ConfigInspector interface {
|
|
// Inspect will output self inspection for a configuration
|
|
InspectConfig(InspectConfigOptions) (ret int)
|
|
}
|