packer

package
v1.6.6-winrm Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2021 License: MPL-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Code generated by "mapstructure-to-hcl2 -type MockPostProcessor"; DO NOT EDIT.

Index

Constants

View Source
const (
	UiColorRed     UiColor = 31
	UiColorGreen           = 32
	UiColorYellow          = 33
	UiColorBlue            = 34
	UiColorMagenta         = 35
	UiColorCyan            = 36
)
View Source
const TelemetryPanicVersion string = "beta/packer_panic/4"
View Source
const TelemetryVersion string = "beta/packer/5"

Variables

View Source
var BuilderDataCommonKeys = []string{
	"ID",

	"Host",
	"Port",
	"User",
	"Password",
	"ConnType",
	"PackerRunUUID",
	"PackerHTTPPort",
	"PackerHTTPIP",
	"PackerHTTPAddr",
	"SSHPublicKey",
	"SSHPrivateKey",
	"WinRMPassword",
}

BuilderDataCommonKeys is the list of common keys that all builder will return

View Source
var ConsoleHelp = strings.TrimSpace(`
Packer console JSON Mode.
The Packer console allows you to experiment with Packer interpolations.
You may access variables in the Packer config you called the console with.

Type in the interpolation to test and hit <enter> to see the result.

"variables" will dump all available variables and their values.

"{{timestamp}}" will output the timestamp, for example "1559855090".

To exit the console, type "exit" and hit <enter>, or use Control-C.

/!\ If you would like to start console in hcl2 mode without a config you can
use the --config-type=hcl2 option.
`)
View Source
var ErrInterrupted = errors.New("interrupted")

Functions

func BasicPlaceholderData

func BasicPlaceholderData() map[string]string

Provisioners interpolate most of their fields in the prepare stage; this placeholder map helps keep fields that are only generated at build time from accidentally being interpolated into empty strings at prepare time. This helper function generates the most basic placeholder data which should be accessible to the provisioners. It is used to initialize provisioners, to force validation using the `generated` template function. In the future, custom generated data could be passed into provisioners from builders to enable specialized builder-specific (but still validated!!) access to builder data.

func CastDataToMap

func CastDataToMap(data interface{}) map[string]interface{}

func ProgressBarConfig

func ProgressBarConfig(bar *pb.ProgressBar, prefix string)

func TestBuilder added in v0.8.0

func TestBuilder(t *testing.T, c *CoreConfig, n string) *packersdk.MockBuilder

TestBuilder sets the builder with the name n to the component finder and returns the mock.

func TestProvisioner added in v0.8.0

func TestProvisioner(t *testing.T, c *CoreConfig, n string) *packersdk.MockProvisioner

TestProvisioner sets the prov. with the name n to the component finder and returns the mock.

func TestUi added in v0.8.0

func TestUi(t *testing.T) packersdk.Ui

Types

type BasicStore

type BasicStore interface {
	Has(name string) bool
	List() (names []string)
}

type BuildGetter

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 BuilderFunc

type BuilderFunc func(name string) (packersdk.Builder, error)

The function type used to lookup Builder implementations.

type BuilderStore

type BuilderStore interface {
	BasicStore
	Start(name string) (packersdk.Builder, error)
}

type CheckpointTelemetry added in v1.0.1

type CheckpointTelemetry struct {
	// contains filtered or unexported fields
}
var CheckpointReporter *CheckpointTelemetry

func NewCheckpointReporter added in v1.1.1

func NewCheckpointReporter(disableSignature bool) *CheckpointTelemetry

func (*CheckpointTelemetry) AddSpan added in v1.0.1

func (c *CheckpointTelemetry) AddSpan(name, pluginType string, options interface{}) *TelemetrySpan

func (*CheckpointTelemetry) Finalize added in v1.0.1

func (c *CheckpointTelemetry) Finalize(command string, errCode int, err error) error

func (*CheckpointTelemetry) ReportPanic added in v1.0.1

func (c *CheckpointTelemetry) ReportPanic(m string) error

type ColoredUi

type ColoredUi struct {
	Color      UiColor
	ErrorColor UiColor
	Ui         packersdk.Ui
	PB         getter.ProgressTracker
}

ColoredUi is a UI that is colored using terminal colors.

func (*ColoredUi) Ask

func (u *ColoredUi) Ask(query string) (string, error)

func (*ColoredUi) Error

func (u *ColoredUi) Error(message string)

func (*ColoredUi) Machine added in v0.3.0

func (u *ColoredUi) Machine(t string, args ...string)

func (*ColoredUi) Message

func (u *ColoredUi) Message(message string)

func (*ColoredUi) Say

func (u *ColoredUi) Say(message string)

func (*ColoredUi) TrackProgress

func (u *ColoredUi) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser

type ComponentFinder

type ComponentFinder struct {
	Hook HookFunc

	// For HCL2
	BuilderStore       BuilderStore
	ProvisionerStore   ProvisionerStore
	PostProcessorStore PostProcessorStore
}

ComponentFinder is a struct that contains the various function pointers necessary to look up components of Packer such as builders, commands, etc.

type ConfigFixer

type ConfigFixer interface {
	// FixConfig will output the config in a fixed manner.
	FixConfig(FixConfigOptions) hcl.Diagnostics
}

type ConfigInspector

type ConfigInspector interface {
	// Inspect will output self inspection for a configuration
	InspectConfig(InspectConfigOptions) (ret int)
}

type Core added in v0.8.0

type Core struct {
	Template *template.Template
	// contains filtered or unexported fields
}

Core is the main executor of Packer. If Packer is being used as a library, this is the struct you'll want to instantiate to get anything done.

func NewCore added in v0.8.0

func NewCore(c *CoreConfig) *Core

NewCore creates a new Core.

func TestCore added in v0.8.0

func TestCore(t *testing.T, c *CoreConfig) *Core

func (*Core) Build added in v0.8.0

func (c *Core) Build(n string) (packersdk.Build, error)

Build returns the Build object for the given name.

func (*Core) BuildNames added in v0.8.0

func (c *Core) BuildNames(only, except []string) []string

BuildNames returns the builds that are available in this configured core.

func (*Core) Context added in v0.8.0

func (c *Core) Context() *interpolate.Context

Context returns an interpolation context.

func (*Core) EvaluateExpression

func (c *Core) EvaluateExpression(line string) (string, bool, hcl.Diagnostics)

func (*Core) FixConfig

func (c *Core) FixConfig(opts FixConfigOptions) hcl.Diagnostics

func (*Core) GetBuilds

func (c *Core) GetBuilds(opts GetBuildsOptions) ([]packersdk.Build, hcl.Diagnostics)

This is used for json templates to launch the build plugins. They will be prepared via b.Prepare() later.

func (*Core) Initialize

func (core *Core) Initialize() error

func (*Core) InspectConfig

func (c *Core) InspectConfig(opts InspectConfigOptions) int

type CoreBuild

type CoreBuild struct {
	BuildName     string
	Type          string
	Builder       packersdk.Builder
	BuilderConfig interface{}
	BuilderType   string

	Provisioners       []CoreBuildProvisioner
	PostProcessors     [][]CoreBuildPostProcessor
	CleanupProvisioner CoreBuildProvisioner
	TemplatePath       string
	Variables          map[string]string

	// Indicates whether the build is already initialized before calling Prepare(..)
	Prepared bool
	// contains filtered or unexported fields
}

A CoreBuild struct represents a single build job, the result of which should be a single machine image artifact. This artifact may be comprised of multiple files, of course, but it should be for only a single provider (such as VirtualBox, EC2, etc.).

func (*CoreBuild) Name

func (b *CoreBuild) Name() string

Returns the name of the build.

func (*CoreBuild) Prepare

func (b *CoreBuild) Prepare() (warn []string, err error)

Prepare prepares the build by doing some initialization for the builder and any hooks. This _must_ be called prior to Run. The parameter is the overrides for the variables within the template (if any).

func (*CoreBuild) Run

func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packersdk.Artifact, error)

Runs the actual build. Prepare must be called prior to running this.

func (*CoreBuild) SetDebug

func (b *CoreBuild) SetDebug(val bool)

func (*CoreBuild) SetForce

func (b *CoreBuild) SetForce(val bool)

func (*CoreBuild) SetOnError

func (b *CoreBuild) SetOnError(val string)

type CoreBuildPostProcessor

type CoreBuildPostProcessor struct {
	PostProcessor packersdk.PostProcessor
	PType         string
	PName         string

	KeepInputArtifact *bool
	// contains filtered or unexported fields
}

CoreBuildPostProcessor Keeps track of the post-processor and the configuration of the post-processor used within a build.

type CoreBuildProvisioner

type CoreBuildProvisioner struct {
	PType       string
	PName       string
	Provisioner packersdk.Provisioner
	// contains filtered or unexported fields
}

CoreBuildProvisioner keeps track of the provisioner and the configuration of the provisioner within the build.

type CoreConfig added in v0.8.0

type CoreConfig struct {
	Components         ComponentFinder
	Template           *template.Template
	Variables          map[string]string
	SensitiveVariables []string
	Version            string

	// These are set by command-line flags
	Except []string
	Only   []string
}

CoreConfig is the structure for initializing a new Core. Once a CoreConfig is used to initialize a Core, it shouldn't be re-used or modified again.

func TestCoreConfig added in v0.8.0

func TestCoreConfig(t *testing.T) *CoreConfig

type DebuggedProvisioner added in v1.2.5

type DebuggedProvisioner struct {
	Provisioner packersdk.Provisioner
	// contains filtered or unexported fields
}

DebuggedProvisioner is a Provisioner implementation that waits until a key press before the provisioner is actually run.

func (*DebuggedProvisioner) ConfigSpec

func (p *DebuggedProvisioner) ConfigSpec() hcldec.ObjectSpec

func (*DebuggedProvisioner) FlatConfig

func (p *DebuggedProvisioner) FlatConfig() interface{}

func (*DebuggedProvisioner) Prepare added in v1.2.5

func (p *DebuggedProvisioner) Prepare(raws ...interface{}) error

func (*DebuggedProvisioner) Provision added in v1.2.5

func (p *DebuggedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error

type Evaluator

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 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
)

func FixConfigModeString

func FixConfigModeString(s string) (FixConfigMode, error)

FixConfigModeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func FixConfigModeValues

func FixConfigModeValues() []FixConfigMode

FixConfigModeValues returns all values of the enum

func (FixConfigMode) IsAFixConfigMode

func (i FixConfigMode) IsAFixConfigMode() bool

IsAFixConfigMode returns "true" if the value is listed in the enum definition. "false" otherwise

func (FixConfigMode) String

func (i FixConfigMode) String() string

type FixConfigOptions

type FixConfigOptions struct {
	Mode FixConfigMode
}

type FlatMockPostProcessor

type FlatMockPostProcessor struct {
	ArtifactId          *string         `cty:"artifact_id" hcl:"artifact_id"`
	Keep                *bool           `cty:"keep" hcl:"keep"`
	ForceOverride       *bool           `cty:"force_override" hcl:"force_override"`
	Error               error           `cty:"error" hcl:"error"`
	ConfigureCalled     *bool           `cty:"configure_called" hcl:"configure_called"`
	ConfigureConfigs    []interface{}   `cty:"configure_configs" hcl:"configure_configs"`
	ConfigureError      error           `cty:"configure_error" hcl:"configure_error"`
	PostProcessCalled   *bool           `cty:"post_process_called" hcl:"post_process_called"`
	PostProcessArtifact packer.Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"`
	PostProcessUi       packer.Ui       `cty:"post_process_ui" hcl:"post_process_ui"`
}

FlatMockPostProcessor is an auto-generated flat version of MockPostProcessor. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatMockPostProcessor) HCL2Spec

func (*FlatMockPostProcessor) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a MockPostProcessor. This spec is used by HCL to read the fields of MockPostProcessor. The decoded values from this spec will then be applied to a FlatMockPostProcessor.

type GetBuildsOptions

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
}

type Handler

type Handler interface {
	Initialize() hcl.Diagnostics
	Evaluator
	BuildGetter
	ConfigFixer
	ConfigInspector
}

The packer.Handler handles all Packer things.

type HookFunc

type HookFunc func(name string) (packersdk.Hook, error)

The function type used to lookup Hook implementations.

type HookedProvisioner added in v1.1.2

type HookedProvisioner struct {
	Provisioner packersdk.Provisioner
	Config      interface{}
	TypeName    string
}

A HookedProvisioner represents a provisioner and information describing it

type InspectConfigOptions

type InspectConfigOptions struct {
	packersdk.Ui
}

type MachineReadableUi added in v0.3.0

type MachineReadableUi struct {
	Writer io.Writer
	PB     packersdk.NoopProgressTracker
}

MachineReadableUi is a UI that only outputs machine-readable output to the given Writer.

func (*MachineReadableUi) Ask added in v0.3.0

func (u *MachineReadableUi) Ask(query string) (string, error)

func (*MachineReadableUi) Error added in v0.3.0

func (u *MachineReadableUi) Error(message string)

func (*MachineReadableUi) Machine added in v0.3.0

func (u *MachineReadableUi) Machine(category string, args ...string)

func (*MachineReadableUi) Message added in v0.3.0

func (u *MachineReadableUi) Message(message string)

func (*MachineReadableUi) Say added in v0.3.0

func (u *MachineReadableUi) Say(message string)

func (*MachineReadableUi) TrackProgress

func (u *MachineReadableUi) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser)

type MockPostProcessor added in v0.8.0

type MockPostProcessor struct {
	ArtifactId    string
	Keep          bool
	ForceOverride bool
	Error         error

	ConfigureCalled  bool
	ConfigureConfigs []interface{}
	ConfigureError   error

	PostProcessCalled   bool
	PostProcessArtifact packersdk.Artifact
	PostProcessUi       packersdk.Ui
}

MockPostProcessor is an implementation of PostProcessor that can be used for tests.

func TestPostProcessor added in v0.8.0

func TestPostProcessor(t *testing.T, c *CoreConfig, n string) *MockPostProcessor

TestPostProcessor sets the prov. with the name n to the component finder and returns the mock.

func (*MockPostProcessor) ConfigSpec

func (t *MockPostProcessor) ConfigSpec() hcldec.ObjectSpec

func (*MockPostProcessor) Configure added in v0.8.0

func (t *MockPostProcessor) Configure(configs ...interface{}) error

func (*MockPostProcessor) FlatMapstructure

func (*MockPostProcessor) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatMockPostProcessor. FlatMockPostProcessor is an auto-generated flat version of MockPostProcessor. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*MockPostProcessor) PostProcess added in v0.8.0

type PackerReport added in v1.0.1

type PackerReport struct {
	Spans    []*TelemetrySpan `json:"spans"`
	ExitCode int              `json:"exit_code"`
	Error    string           `json:"error"`
	Command  string           `json:"command"`
}

type PausedProvisioner added in v0.5.0

type PausedProvisioner struct {
	PauseBefore time.Duration
	Provisioner packersdk.Provisioner
}

PausedProvisioner is a Provisioner implementation that pauses before the provisioner is actually run.

func (*PausedProvisioner) ConfigSpec

func (p *PausedProvisioner) ConfigSpec() hcldec.ObjectSpec

func (*PausedProvisioner) FlatConfig

func (p *PausedProvisioner) FlatConfig() interface{}

func (*PausedProvisioner) Prepare added in v0.5.0

func (p *PausedProvisioner) Prepare(raws ...interface{}) error

func (*PausedProvisioner) Provision added in v0.5.0

func (p *PausedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error

type PostProcessorFunc

type PostProcessorFunc func(name string) (packersdk.PostProcessor, error)

The function type used to lookup PostProcessor implementations.

type PostProcessorStore

type PostProcessorStore interface {
	BasicStore
	Start(name string) (packersdk.PostProcessor, error)
}

type ProvisionHook

type ProvisionHook struct {
	// The provisioners to run as part of the hook. These should already
	// be prepared (by calling Prepare) at some earlier stage.
	Provisioners []*HookedProvisioner
}

A Hook implementation that runs the given provisioners.

func (*ProvisionHook) Run

func (h *ProvisionHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packersdk.Communicator, data interface{}) error

Runs the provisioners in order.

type ProvisionerFunc

type ProvisionerFunc func(name string) (packersdk.Provisioner, error)

The function type used to lookup Provisioner implementations.

type ProvisionerStore

type ProvisionerStore interface {
	BasicStore
	Start(name string) (packersdk.Provisioner, error)
}

type RetriedProvisioner

type RetriedProvisioner struct {
	MaxRetries  int
	Provisioner packersdk.Provisioner
}

RetriedProvisioner is a Provisioner implementation that retries the provisioner whenever there's an error.

func (*RetriedProvisioner) ConfigSpec

func (r *RetriedProvisioner) ConfigSpec() hcldec.ObjectSpec

func (*RetriedProvisioner) FlatConfig

func (r *RetriedProvisioner) FlatConfig() interface{}

func (*RetriedProvisioner) Prepare

func (r *RetriedProvisioner) Prepare(raws ...interface{}) error

func (*RetriedProvisioner) Provision

func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error

type TargetedUI added in v1.0.0

type TargetedUI struct {
	Target string
	Ui     packersdk.Ui
}

TargetedUI is a UI that wraps another UI implementation and modifies the output to indicate a specific target. Specifically, all Say output is prefixed with the target name. Message output is not prefixed but is offset by the length of the target so that output is lined up properly with Say output. Machine-readable output has the proper target set.

func (*TargetedUI) Ask added in v1.0.0

func (u *TargetedUI) Ask(query string) (string, error)

func (*TargetedUI) Error added in v1.0.0

func (u *TargetedUI) Error(message string)

func (*TargetedUI) Machine added in v1.0.0

func (u *TargetedUI) Machine(t string, args ...string)

func (*TargetedUI) Message added in v1.0.0

func (u *TargetedUI) Message(message string)

func (*TargetedUI) Say added in v1.0.0

func (u *TargetedUI) Say(message string)

func (*TargetedUI) TrackProgress

func (u *TargetedUI) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser

type TelemetrySpan added in v1.0.1

type TelemetrySpan struct {
	EndTime   time.Time `json:"end_time"`
	Error     string    `json:"error"`
	Name      string    `json:"name"`
	Options   []string  `json:"options"`
	StartTime time.Time `json:"start_time"`
	Type      string    `json:"type"`
}

func (*TelemetrySpan) End added in v1.0.1

func (s *TelemetrySpan) End(err error)

type TimeoutProvisioner

type TimeoutProvisioner struct {
	packersdk.Provisioner
	Timeout time.Duration
}

TimeoutProvisioner is a Provisioner implementation that can timeout after a duration

func (*TimeoutProvisioner) Provision

func (p *TimeoutProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error

type TimestampedUi added in v1.3.2

type TimestampedUi struct {
	Ui packersdk.Ui
	PB getter.ProgressTracker
}

TimestampedUi is a UI that wraps another UI implementation and prefixes each message with an RFC3339 timestamp

func (*TimestampedUi) Ask added in v1.3.2

func (u *TimestampedUi) Ask(query string) (string, error)

func (*TimestampedUi) Error added in v1.3.2

func (u *TimestampedUi) Error(message string)

func (*TimestampedUi) Machine added in v1.3.2

func (u *TimestampedUi) Machine(message string, args ...string)

func (*TimestampedUi) Message added in v1.3.2

func (u *TimestampedUi) Message(message string)

func (*TimestampedUi) Say added in v1.3.2

func (u *TimestampedUi) Say(message string)

func (*TimestampedUi) TrackProgress

func (u *TimestampedUi) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) (body io.ReadCloser)

type UiColor

type UiColor uint

type UiProgressBar

type UiProgressBar struct {
	// contains filtered or unexported fields
}

UiProgressBar is a progress bar compatible with go-getter used in our UI structs.

func (*UiProgressBar) TrackProgress

func (p *UiProgressBar) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL