Documentation
¶
Overview ¶
Package packer allows to interact with Packer.
Index ¶
- Variables
- func BuildAmi(t testing.TestingT, options *Options) stringdeprecated
- func BuildAmiE(t testing.TestingT, options *Options) (string, error)deprecated
- func BuildArtifact(t testing.TestingT, options *Options) stringdeprecated
- func BuildArtifactContext(t testing.TestingT, ctx context.Context, options *Options) string
- func BuildArtifactContextE(t testing.TestingT, ctx context.Context, options *Options) (string, error)
- func BuildArtifactE(t testing.TestingT, options *Options) (string, error)deprecated
- func BuildArtifacts(t testing.TestingT, artifactNameToOptions map[string]*Options) map[string]stringdeprecated
- func BuildArtifactsContext(t testing.TestingT, ctx context.Context, ...) map[string]string
- func BuildArtifactsContextE(t testing.TestingT, ctx context.Context, ...) (map[string]string, error)
- func BuildArtifactsE(t testing.TestingT, artifactNameToOptions map[string]*Options) (map[string]string, error)deprecated
- func ExtractArtifactID(packerLogOutput string) (string, error)
- func FormatPackerArgs(options *Options) []string
- func GetArtifactIDFromManifestBuildName(t testing.TestingT, manifestPath string, buildName string) stringdeprecated
- func GetArtifactIDFromManifestBuildNameContext(t testing.TestingT, ctx context.Context, manifestPath string, buildName string) string
- func GetArtifactIDFromManifestBuildNameContextE(t testing.TestingT, ctx context.Context, manifestPath string, buildName string) (string, error)
- func GetArtifactIDFromManifestBuildNameE(t testing.TestingT, manifestPath string, buildName string) (string, error)deprecated
- func TrimPackerVersion(versionCmdOutput string) string
- type BuildNameNotFoundError
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrArtifactIDNotFound = errors.New("could not find artifact ID pattern in packer output")
ErrArtifactIDNotFound is returned when the Packer output does not contain an artifact ID.
Functions ¶
func BuildArtifact
deprecated
added in
v0.10.0
BuildArtifact builds the given Packer template and return the generated Artifact ID.
Deprecated: Use BuildArtifactContext instead.
func BuildArtifactContext ¶ added in v1.0.0
BuildArtifactContext builds the given Packer template and return the generated Artifact ID. This function will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func BuildArtifactContextE ¶ added in v1.0.0
func BuildArtifactContextE(t testing.TestingT, ctx context.Context, options *Options) (string, error)
BuildArtifactContextE builds the given Packer template and return the generated Artifact ID. The ctx parameter supports cancellation and timeouts.
func BuildArtifactE
deprecated
added in
v0.10.0
func BuildArtifacts
deprecated
added in
v0.13.9
func BuildArtifacts(t testing.TestingT, artifactNameToOptions map[string]*Options) map[string]string
BuildArtifacts can take a map of identifierName <-> Options and then parallelize the packer builds. Once all the packer builds have completed a map of identifierName <-> generated identifier is returned. The identifierName can be anything you want, it is only used so that you can know which generated artifact is which.
Deprecated: Use BuildArtifactsContext instead.
func BuildArtifactsContext ¶ added in v1.0.0
func BuildArtifactsContext(t testing.TestingT, ctx context.Context, artifactNameToOptions map[string]*Options) map[string]string
BuildArtifactsContext can take a map of identifierName <-> Options and then parallelize the packer builds. Once all the packer builds have completed a map of identifierName <-> generated identifier is returned. The identifierName can be anything you want, it is only used so that you can know which generated artifact is which. This function will fail the test if there is an error. The ctx parameter supports cancellation and timeouts.
func BuildArtifactsContextE ¶ added in v1.0.0
func BuildArtifactsContextE(t testing.TestingT, ctx context.Context, artifactNameToOptions map[string]*Options) (map[string]string, error)
BuildArtifactsContextE can take a map of identifierName <-> Options and then parallelize the packer builds. Once all the packer builds have completed a map of identifierName <-> generated identifier is returned. If any artifact fails to build, the errors are accumulated and returned as a MultiError. The identifierName can be anything you want, it is only used so that you can know which generated artifact is which. The ctx parameter supports cancellation and timeouts.
func BuildArtifactsE
deprecated
added in
v0.13.9
func BuildArtifactsE(t testing.TestingT, artifactNameToOptions map[string]*Options) (map[string]string, error)
BuildArtifactsE can take a map of identifierName <-> Options and then parallelize the packer builds. Once all the packer builds have completed a map of identifierName <-> generated identifier is returned. If any artifact fails to build, the errors are accumulated and returned as a MultiError. The identifierName can be anything you want, it is only used so that you can know which generated artifact is which.
Deprecated: Use BuildArtifactsContextE instead.
func ExtractArtifactID ¶ added in v1.0.0
ExtractArtifactID extracts the artifact ID from Packer machine-readable log output.
The Packer machine-readable log output should contain an entry of this format:
AWS: <timestamp>,<builder>,artifact,<index>,id,<region>:<image_id> GCP: <timestamp>,<builder>,artifact,<index>,id,<image_id>
For example:
1456332887,amazon-ebs,artifact,0,id,us-east-1:ami-b481b3de 1533742764,googlecompute,artifact,0,id,terratest-packer-example-2018-08-08t15-35-19z
func FormatPackerArgs ¶ added in v1.0.0
FormatPackerArgs converts the inputs to a format palatable to packer. The build command should have the format:
packer build [OPTIONS] template
func GetArtifactIDFromManifestBuildName
deprecated
added in
v0.49.0
func GetArtifactIDFromManifestBuildName(t testing.TestingT, manifestPath string, buildName string) string
GetArtifactIDFromManifestBuildName returns the artifact id from a build name contained in the manifest file. See https://developer.hashicorp.com/packer/docs/post-processors/manifest for more info. If the build name is not found, it will fail the test.
Deprecated: Use GetArtifactIDFromManifestBuildNameContext instead.
func GetArtifactIDFromManifestBuildNameContext ¶ added in v1.0.0
func GetArtifactIDFromManifestBuildNameContext(t testing.TestingT, ctx context.Context, manifestPath string, buildName string) string
GetArtifactIDFromManifestBuildNameContext returns the artifact id from a build name contained in the manifest file. See https://developer.hashicorp.com/packer/docs/post-processors/manifest for more info. This function will fail the test if there is an error. The ctx parameter is accepted for API consistency with other Context functions.
func GetArtifactIDFromManifestBuildNameContextE ¶ added in v1.0.0
func GetArtifactIDFromManifestBuildNameContextE(t testing.TestingT, ctx context.Context, manifestPath string, buildName string) (string, error)
GetArtifactIDFromManifestBuildNameContextE returns the artifact id from a build name contained in the manifest file. See https://developer.hashicorp.com/packer/docs/post-processors/manifest for more info. The ctx parameter is accepted for API consistency with other Context functions.
func GetArtifactIDFromManifestBuildNameE
deprecated
added in
v0.49.0
func GetArtifactIDFromManifestBuildNameE(t testing.TestingT, manifestPath string, buildName string) (string, error)
GetArtifactIDFromManifestBuildNameE returns the artifact id from a build name contained in the manifest file. See https://developer.hashicorp.com/packer/docs/post-processors/manifest for more info.
Deprecated: Use GetArtifactIDFromManifestBuildNameContextE instead.
func TrimPackerVersion ¶ added in v1.0.0
TrimPackerVersion extracts the version number from packer version output. From packer 1.10 the -version command output is prefixed with "Packer v".
Types ¶
type BuildNameNotFoundError ¶ added in v1.0.0
BuildNameNotFoundError is returned when the specified build name is not found in the manifest file.
func (*BuildNameNotFoundError) Error ¶ added in v1.0.0
func (e *BuildNameNotFoundError) Error() string
Error implements the error interface for BuildNameNotFoundError.
type Options ¶
type Options struct {
Vars map[string]string // The custom vars to pass when running the build command
Env map[string]string // Custom environment variables to set when running Packer
RetryableErrors map[string]string // If packer build fails with one of these (transient) errors, retry. The keys are a regexp to match against the error and the message is what to display to a user if that error is matched.
Logger *logger.Logger // If set, use a non-default logger
Template string // The path to the Packer template
Only string // If specified, only run the build of this name
Except string // Runs the build excluding the specified builds and post-processors
WorkingDir string // The directory to run packer in
VarFiles []string // Var file paths to pass Packer using -var-file option
TimeBetweenRetries time.Duration // The amount of time to wait between retries
MaxRetries int // Maximum number of times to retry errors matching RetryableErrors
DisableTemporaryPluginPath bool // If set, do not use a temporary directory for Packer plugins.
}
Options are the options for Packer.