Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigDir() (string, error)
- func ConfigFile() (string, error)
- func ConfigTmpDir() (string, error)
- type Artifact
- type BasicProgressBar
- type BasicUi
- type Build
- type Builder
- type BuilderFunc
- type Cache
- type CheckpointTelemetry
- type ColoredUi
- type Communicator
- type ComponentFinder
- type Core
- type CoreConfig
- type DebuggedProvisioner
- type DispatchHook
- type FileCache
- type Hook
- type HookFunc
- type HookedProvisioner
- type MachineReadableUi
- func (u *MachineReadableUi) Ask(query string) (string, error)
- func (u *MachineReadableUi) Error(message string)
- func (u *MachineReadableUi) Machine(category string, args ...string)
- func (u *MachineReadableUi) Message(message string)
- func (u *MachineReadableUi) ProgressBar() ProgressBar
- func (u *MachineReadableUi) Say(message string)
- type MockArtifact
- type MockBuilder
- type MockCommunicator
- func (c *MockCommunicator) Download(path string, w io.Writer) error
- func (c *MockCommunicator) DownloadDir(src string, dst string, excl []string) error
- func (c *MockCommunicator) Start(rc *RemoteCmd) error
- func (c *MockCommunicator) Upload(path string, r io.Reader, fi *os.FileInfo) error
- func (c *MockCommunicator) UploadDir(dst string, src string, excl []string) error
- type MockHook
- type MockPostProcessor
- type MockProvisioner
- type MultiError
- type NoopProgressBar
- type NoopUi
- type PackerReport
- type PausedProvisioner
- type PostProcessor
- type PostProcessorFunc
- type ProgressBar
- type ProvisionHook
- type Provisioner
- type ProvisionerFunc
- type ProxyReader
- type RemoteCmd
- type StackableProgressBar
- type TargetedUI
- type TelemetrySpan
- type TimestampedUi
- func (u *TimestampedUi) Ask(query string) (string, error)
- func (u *TimestampedUi) Error(message string)
- func (u *TimestampedUi) Machine(message string, args ...string)
- func (u *TimestampedUi) Message(message string)
- func (u *TimestampedUi) ProgressBar() ProgressBar
- func (u *TimestampedUi) Say(message string)
- type Ui
- type UiColor
Constants ¶
const ( // This is the key in configurations that is set to the name of the // build. BuildNameConfigKey = "packer_build_name" // This is the key in the configuration that is set to the type // of the builder that is run. This is useful for provisioners and // such who want to make use of this. BuilderTypeConfigKey = "packer_builder_type" // This is the key in configurations that is set to "true" when Packer // debugging is enabled. DebugConfigKey = "packer_debug" // This is the key in configurations that is set to "true" when Packer // force build is enabled. ForceConfigKey = "packer_force" // This key determines what to do when a normal multistep step fails // - "cleanup" - run cleanup steps // - "abort" - exit without cleanup // - "ask" - ask the user OnErrorConfigKey = "packer_on_error" // TemplatePathKey is the path to the template that configured this build TemplatePathKey = "packer_template_path" // This key contains a map[string]string of the user variables for // template processing. UserVariablesConfigKey = "packer_user_variables" )
const ( UiColorRed UiColor = 31 UiColorGreen = 32 UiColorYellow = 33 UiColorBlue = 34 UiColorMagenta = 35 UiColorCyan = 36 )
const CmdDisconnect int = 2300218
CmdDisconnect is a sentinel value to indicate a RemoteCmd exited because the remote side disconnected us.
const HookProvision = "packer_provision"
This is the hook that should be fired for provisioners to run.
const TelemetryPanicVersion string = "beta/packer_panic/4"
const TelemetryVersion string = "beta/packer/5"
Variables ¶
var LogSecretFilter secretFilter
Functions ¶
func ConfigFile ¶
ConfigFile returns the default path to the configuration file. On Unix-like systems this is the ".packerconfig" file in the home directory. On Windows, this is the "packer.config" file in the application data directory.
func ConfigTmpDir ¶
ConfigTmpDir returns the configuration tmp directory for Packer
Types ¶
type Artifact ¶
type Artifact interface { // Returns the ID of the builder that was used to create this artifact. // This is the internal ID of the builder and should be unique to every // builder. This can be used to identify what the contents of the // artifact actually are. BuilderId() string // Returns the set of files that comprise this artifact. If an // artifact is not made up of files, then this will be empty. Files() []string // The ID for the artifact, if it has one. This is not guaranteed to // be unique every run (like a GUID), but simply provide an identifier // for the artifact that may be meaningful in some way. For example, // for Amazon EC2, this value might be the AMI ID. Id() string // Returns human-readable output that describes the artifact created. // This is used for UI output. It can be multiple lines. String() string // State allows the caller to ask for builder specific state information // relating to the artifact instance. State(name string) interface{} // Destroy deletes the artifact. Packer calls this for various reasons, // such as if a post-processor has processed this artifact and it is // no longer needed. Destroy() error }
An Artifact is the result of a build, and is the metadata that documents what a builder actually created. The exact meaning of the contents is specific to each builder, but this interface is used to communicate back to the user the result of a build.
type BasicProgressBar ¶
type BasicProgressBar struct {
*pb.ProgressBar
}
BasicProgressBar is packer's basic progress bar. Current implementation will always try to keep itself at the bottom of a terminal.
func (*BasicProgressBar) Add ¶
func (bpb *BasicProgressBar) Add(current int64)
func (*BasicProgressBar) NewProxyReadCloser ¶
func (bpb *BasicProgressBar) NewProxyReadCloser(r io.ReadCloser) io.ReadCloser
func (*BasicProgressBar) NewProxyReader ¶
func (bpb *BasicProgressBar) NewProxyReader(r io.Reader) io.Reader
func (*BasicProgressBar) Start ¶
func (bpb *BasicProgressBar) Start(total int64)
type BasicUi ¶
type BasicUi struct { Reader io.Reader Writer io.Writer ErrorWriter io.Writer StackableProgressBar // contains filtered or unexported fields }
The BasicUI is a UI that reads and writes from a standard Go reader and writer. It is safe to be called from multiple goroutines. Machine readable output is simply logged for this UI.
func (*BasicUi) ProgressBar ¶
func (bu *BasicUi) ProgressBar() ProgressBar
type Build ¶
type Build interface { // Name is the name of the build. This is unique across a single template, // but not absolutely unique. This is meant more to describe to the user // what is being built rather than being a unique identifier. Name() string // Prepare configures the various components of this build and reports // any errors in doing so (such as syntax errors, validation errors, etc.). // It also reports any warnings. Prepare() ([]string, error) // Run runs the actual builder, returning an artifact implementation // of what is built. If anything goes wrong, an error is returned. Run(Ui, Cache) ([]Artifact, error) // Cancel will cancel a running build. This will block until the build // is actually completely canceled. Cancel() // SetDebug will enable/disable debug mode. Debug mode is always // enabled by adding the additional key "packer_debug" to boolean // true in the configuration of the various components. This must // be called prior to Prepare. // // When SetDebug is set to true, parallelism between builds is // strictly prohibited. SetDebug(bool) // SetForce will enable/disable forcing a build when artifacts exist. // // When SetForce is set to true, existing artifacts from the build are // deleted prior to the build. SetForce(bool) // SetOnError will determine what to do when a normal multistep step fails // - "cleanup" - run cleanup steps // - "abort" - exit without cleanup // - "ask" - ask the user SetOnError(string) }
A Build represents a single job within Packer that is responsible for building some machine image artifact. Builds are meant to be parallelized.
type Builder ¶
type Builder interface { // Prepare is responsible for configuring the builder and validating // that configuration. Any setup should be done in this method. Note that // NO side effects should take place in prepare, it is meant as a state // setup only. Calling Prepare is not necessarily followed by a Run. // // The parameters to Prepare are a set of interface{} values of the // configuration. These are almost always `map[string]interface{}` // parsed from a template, but no guarantee is made. // // Each of the configuration values should merge into the final // configuration. // // Prepare should return a list of warnings along with any errors // that occurred while preparing. Prepare(...interface{}) ([]string, error) // Run is where the actual build should take place. It takes a Build and a Ui. Run(ui Ui, hook Hook, cache Cache) (Artifact, error) // Cancel cancels a possibly running Builder. This should block until // the builder actually cancels and cleans up after itself. Cancel() }
Implementers of Builder are responsible for actually building images on some platform given some configuration.
In addition to the documentation on Prepare above: Prepare is sometimes configured with a `map[string]interface{}` that has a key "packer_debug". This is a boolean value. If it is set to true, then the builder should enable a debug mode which allows builder developers and advanced users to introspect what is going on during a build. During debug builds, parallelism is strictly disabled, so it is safe to request input from stdin and so on.
type BuilderFunc ¶
The function type used to lookup Builder implementations.
type Cache ¶
type Cache interface { // Lock takes a key and returns the path where the file can be written to. // Packer guarantees that no other process will write to this file while // the lock is held. // // If the key has an extension (e.g., file.ext), the resulting path // will have that extension as well. // // The cache will block and wait for the lock. Lock(string) string // Unlock will unlock a certain cache key. Be very careful that this // is only called once per lock obtained. Unlock(string) // RLock returns the path to a key in the cache and locks it for reading. // The second return parameter is whether the key existed or not. // This will block if any locks are held for writing. No lock will be // held if the key doesn't exist. RLock(string) (string, bool) // RUnlock will unlock a key for reading. RUnlock(string) }
Cache implements a caching interface where files can be stored for re-use between multiple runs.
type CheckpointTelemetry ¶
type CheckpointTelemetry struct {
// contains filtered or unexported fields
}
var CheckpointReporter *CheckpointTelemetry
func NewCheckpointReporter ¶
func NewCheckpointReporter(disableSignature bool) *CheckpointTelemetry
func (*CheckpointTelemetry) AddSpan ¶
func (c *CheckpointTelemetry) AddSpan(name, pluginType string, options interface{}) *TelemetrySpan
func (*CheckpointTelemetry) Finalize ¶
func (c *CheckpointTelemetry) Finalize(command string, errCode int, err error) error
func (*CheckpointTelemetry) ReportPanic ¶
func (c *CheckpointTelemetry) ReportPanic(m string) error
type ColoredUi ¶
ColoredUi is a UI that is colored using terminal colors.
func (*ColoredUi) ProgressBar ¶
func (u *ColoredUi) ProgressBar() ProgressBar
type Communicator ¶
type Communicator interface { // Start takes a RemoteCmd and starts it. The RemoteCmd must not be // modified after being used with Start, and it must not be used with // Start again. The Start method returns immediately once the command // is started. It does not wait for the command to complete. The // RemoteCmd.Exited field should be used for this. Start(*RemoteCmd) error // Upload uploads a file to the machine to the given path with the // contents coming from the given reader. This method will block until // it completes. Upload(string, io.Reader, *os.FileInfo) error // UploadDir uploads the contents of a directory recursively to // the remote path. It also takes an optional slice of paths to // ignore when uploading. // // The folder name of the source folder should be created unless there // is a trailing slash on the source "/". For example: "/tmp/src" as // the source will create a "src" directory in the destination unless // a trailing slash is added. This is identical behavior to rsync(1). UploadDir(dst string, src string, exclude []string) error // Download downloads a file from the machine from the given remote path // with the contents writing to the given writer. This method will // block until it completes. Download(string, io.Writer) error DownloadDir(src string, dst string, exclude []string) error }
A Communicator is the interface used to communicate with the machine that exists that will eventually be packaged into an image. Communicators allow you to execute remote commands, upload files, etc.
Communicators must be safe for concurrency, meaning multiple calls to Start or any other method may be called at the same time.
type ComponentFinder ¶
type ComponentFinder struct { Builder BuilderFunc Hook HookFunc PostProcessor PostProcessorFunc Provisioner ProvisionerFunc }
ComponentFinder is a struct that contains the various function pointers necessary to look up components of Packer such as builders, commands, etc.
type Core ¶
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 (*Core) BuildNames ¶
BuildNames returns the builds that are available in this configured core.
func (*Core) Context ¶
func (c *Core) Context() *interpolate.Context
Context returns an interpolation context.
type CoreConfig ¶
type CoreConfig struct { Components ComponentFinder Template *template.Template Variables map[string]string SensitiveVariables []string Version 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 ¶
func TestCoreConfig(t *testing.T) *CoreConfig
type DebuggedProvisioner ¶
type DebuggedProvisioner struct { Provisioner 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) Cancel ¶
func (p *DebuggedProvisioner) Cancel()
func (*DebuggedProvisioner) Prepare ¶
func (p *DebuggedProvisioner) Prepare(raws ...interface{}) error
func (*DebuggedProvisioner) Provision ¶
func (p *DebuggedProvisioner) Provision(ui Ui, comm Communicator) error
type DispatchHook ¶
A Hook implementation that dispatches based on an internal mapping.
func (*DispatchHook) Cancel ¶
func (h *DispatchHook) Cancel()
Cancels all the hooks that are currently in-flight, if any. This will block until the hooks are all cancelled.
func (*DispatchHook) Run ¶
func (h *DispatchHook) Run(name string, ui Ui, comm Communicator, data interface{}) error
Runs the hook with the given name by dispatching it to the proper hooks if a mapping exists. If a mapping doesn't exist, then nothing happens.
type FileCache ¶
type FileCache struct { CacheDir string // contains filtered or unexported fields }
FileCache implements a Cache by caching the data directly to a cache directory.
type Hook ¶
type Hook interface { Run(string, Ui, Communicator, interface{}) error Cancel() }
A Hook is used to hook into an arbitrarily named location in a build, allowing custom behavior to run at certain points along a build.
Run is called when the hook is called, with the name of the hook and arbitrary data associated with it. To know what format the data is in, you must reference the documentation for the specific hook you're interested in. In addition to that, the Hook is given access to a UI so that it can output things to the user.
Cancel is called when the hook needs to be cancelled. This will usually be called when Run is still in progress so the mechanism that handles this must be race-free. Cancel should attempt to cancel the hook in the quickest, safest way possible.
type HookedProvisioner ¶
type HookedProvisioner struct { Provisioner Provisioner Config interface{} TypeName string }
A HookedProvisioner represents a provisioner and information describing it
type MachineReadableUi ¶
MachineReadableUi is a UI that only outputs machine-readable output to the given Writer.
func (*MachineReadableUi) Error ¶
func (u *MachineReadableUi) Error(message string)
func (*MachineReadableUi) Machine ¶
func (u *MachineReadableUi) Machine(category string, args ...string)
func (*MachineReadableUi) Message ¶
func (u *MachineReadableUi) Message(message string)
func (*MachineReadableUi) ProgressBar ¶
func (u *MachineReadableUi) ProgressBar() ProgressBar
func (*MachineReadableUi) Say ¶
func (u *MachineReadableUi) Say(message string)
type MockArtifact ¶
type MockArtifact struct { BuilderIdValue string FilesValue []string IdValue string StateValues map[string]interface{} DestroyCalled bool StringValue string }
MockArtifact is an implementation of Artifact that can be used for tests.
func (*MockArtifact) BuilderId ¶
func (a *MockArtifact) BuilderId() string
func (*MockArtifact) Destroy ¶
func (a *MockArtifact) Destroy() error
func (*MockArtifact) Files ¶
func (a *MockArtifact) Files() []string
func (*MockArtifact) Id ¶
func (a *MockArtifact) Id() string
func (*MockArtifact) State ¶
func (a *MockArtifact) State(name string) interface{}
func (*MockArtifact) String ¶
func (a *MockArtifact) String() string
type MockBuilder ¶
type MockBuilder struct { ArtifactId string PrepareWarnings []string RunErrResult bool RunNilResult bool PrepareCalled bool PrepareConfig []interface{} RunCalled bool RunCache Cache RunHook Hook RunUi Ui CancelCalled bool }
MockBuilder is an implementation of Builder that can be used for tests. You can set some fake return values and you can keep track of what methods were called on the builder. It is fairly basic.
func TestBuilder ¶
func TestBuilder(t *testing.T, c *CoreConfig, n string) *MockBuilder
TestBuilder sets the builder with the name n to the component finder and returns the mock.
func (*MockBuilder) Cancel ¶
func (tb *MockBuilder) Cancel()
func (*MockBuilder) Prepare ¶
func (tb *MockBuilder) Prepare(config ...interface{}) ([]string, error)
type MockCommunicator ¶
type MockCommunicator struct { StartCalled bool StartCmd *RemoteCmd StartStderr string StartStdout string StartStdin string StartExitStatus int UploadCalled bool UploadPath string UploadData string UploadDirDst string UploadDirSrc string UploadDirExclude []string DownloadDirDst string DownloadDirSrc string DownloadDirExclude []string DownloadCalled bool DownloadPath string DownloadData string }
MockCommunicator is a valid Communicator implementation that can be used for tests.
func (*MockCommunicator) Download ¶
func (c *MockCommunicator) Download(path string, w io.Writer) error
func (*MockCommunicator) DownloadDir ¶
func (c *MockCommunicator) DownloadDir(src string, dst string, excl []string) error
func (*MockCommunicator) Start ¶
func (c *MockCommunicator) Start(rc *RemoteCmd) error
type MockHook ¶
type MockHook struct { RunFunc func() error RunCalled bool RunComm Communicator RunData interface{} RunName string RunUi Ui CancelCalled bool }
MockHook is an implementation of Hook that can be used for tests.
type MockPostProcessor ¶
type MockPostProcessor struct { ArtifactId string Keep bool Error error ConfigureCalled bool ConfigureConfigs []interface{} ConfigureError error PostProcessCalled bool PostProcessArtifact Artifact PostProcessUi Ui }
MockPostProcessor is an implementation of PostProcessor that can be used for tests.
func TestPostProcessor ¶
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) Configure ¶
func (t *MockPostProcessor) Configure(configs ...interface{}) error
func (*MockPostProcessor) PostProcess ¶
type MockProvisioner ¶
type MockProvisioner struct { ProvFunc func() error PrepCalled bool PrepConfigs []interface{} ProvCalled bool ProvCommunicator Communicator ProvUi Ui CancelCalled bool }
MockProvisioner is an implementation of Provisioner that can be used for tests.
func TestProvisioner ¶
func TestProvisioner(t *testing.T, c *CoreConfig, n string) *MockProvisioner
TestProvisioner sets the prov. with the name n to the component finder and returns the mock.
func (*MockProvisioner) Cancel ¶
func (t *MockProvisioner) Cancel()
func (*MockProvisioner) Prepare ¶
func (t *MockProvisioner) Prepare(configs ...interface{}) error
func (*MockProvisioner) Provision ¶
func (t *MockProvisioner) Provision(ui Ui, comm Communicator) error
type MultiError ¶
type MultiError struct {
Errors []error
}
MultiError is an error type to track multiple errors. This is used to accumulate errors in cases such as configuration parsing, and returning them as a single error.
func MultiErrorAppend ¶
func MultiErrorAppend(err error, errs ...error) *MultiError
MultiErrorAppend is a helper function that will append more errors onto a MultiError in order to create a larger multi-error. If the original error is not a MultiError, it will be turned into one.
func (*MultiError) Error ¶
func (e *MultiError) Error() string
type NoopProgressBar ¶
type NoopProgressBar struct { }
NoopProgressBar is a silent progress bar.
func (*NoopProgressBar) Add ¶
func (npb *NoopProgressBar) Add(int64)
func (*NoopProgressBar) Finish ¶
func (npb *NoopProgressBar) Finish()
func (*NoopProgressBar) NewProxyReadCloser ¶
func (npb *NoopProgressBar) NewProxyReadCloser(r io.ReadCloser) io.ReadCloser
func (*NoopProgressBar) NewProxyReader ¶
func (npb *NoopProgressBar) NewProxyReader(r io.Reader) io.Reader
func (*NoopProgressBar) Start ¶
func (npb *NoopProgressBar) Start(int64)
type NoopUi ¶
type NoopUi struct{}
func (*NoopUi) ProgressBar ¶
func (*NoopUi) ProgressBar() ProgressBar
type PackerReport ¶
type PackerReport struct { Spans []*TelemetrySpan `json:"spans"` ExitCode int `json:"exit_code"` Error string `json:"error"` Command string `json:"command"` }
type PausedProvisioner ¶
type PausedProvisioner struct { PauseBefore time.Duration Provisioner Provisioner // contains filtered or unexported fields }
PausedProvisioner is a Provisioner implementation that pauses before the provisioner is actually run.
func (*PausedProvisioner) Cancel ¶
func (p *PausedProvisioner) Cancel()
func (*PausedProvisioner) Prepare ¶
func (p *PausedProvisioner) Prepare(raws ...interface{}) error
func (*PausedProvisioner) Provision ¶
func (p *PausedProvisioner) Provision(ui Ui, comm Communicator) error
type PostProcessor ¶
type PostProcessor interface { // Configure is responsible for setting up configuration, storing // the state for later, and returning and errors, such as validation // errors. Configure(...interface{}) error // PostProcess takes a previously created Artifact and produces another // Artifact. If an error occurs, it should return that error. If `keep` // is to true, then the previous artifact is forcibly kept. PostProcess(Ui, Artifact) (a Artifact, keep bool, err error) }
A PostProcessor is responsible for taking an artifact of a build and doing some sort of post-processing to turn this into another artifact. An example of a post-processor would be something that takes the result of a build, compresses it, and returns a new artifact containing a single file of the prior artifact compressed.
type PostProcessorFunc ¶
type PostProcessorFunc func(name string) (PostProcessor, error)
The function type used to lookup PostProcessor implementations.
type ProgressBar ¶
type ProgressBar interface { Start(total int64) Add(current int64) NewProxyReader(r io.Reader) (proxy io.Reader) Finish() }
ProgressBar allows to graphically display a self refreshing progress bar.
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 // contains filtered or unexported fields }
A Hook implementation that runs the given provisioners.
func (*ProvisionHook) Cancel ¶
func (h *ProvisionHook) Cancel()
Cancels the provisioners that are still running.
func (*ProvisionHook) Run ¶
func (h *ProvisionHook) Run(name string, ui Ui, comm Communicator, data interface{}) error
Runs the provisioners in order.
type Provisioner ¶
type Provisioner interface { // Prepare is called with a set of configurations to setup the // internal state of the provisioner. The multiple configurations // should be merged in some sane way. Prepare(...interface{}) error // Provision is called to actually provision the machine. A UI is // given to communicate with the user, and a communicator is given that // is guaranteed to be connected to some machine so that provisioning // can be done. Provision(Ui, Communicator) error // Cancel is called to cancel the provisioning. This is usually called // while Provision is still being called. The Provisioner should act // to stop its execution as quickly as possible in a race-free way. Cancel() }
A provisioner is responsible for installing and configuring software on a machine prior to building the actual image.
type ProvisionerFunc ¶
type ProvisionerFunc func(name string) (Provisioner, error)
The function type used to lookup Provisioner implementations.
type ProxyReader ¶
type ProxyReader struct { io.Reader ProgressBar }
ProxyReader implements io.ReadCloser but sends count of read bytes to a progress bar
func (*ProxyReader) Close ¶
func (r *ProxyReader) Close() (err error)
Close the reader if it implements io.Closer
type RemoteCmd ¶
type RemoteCmd struct { // Command is the command to run remotely. This is executed as if // it were a shell command, so you are expected to do any shell escaping // necessary. Command string // Stdin specifies the process's standard input. If Stdin is // nil, the process reads from an empty bytes.Buffer. Stdin io.Reader // Stdout and Stderr represent the process's standard output and // error. // // If either is nil, it will be set to ioutil.Discard. Stdout io.Writer Stderr io.Writer // This will be set to true when the remote command has exited. It // shouldn't be set manually by the user, but there is no harm in // doing so. Exited bool // Once Exited is true, this will contain the exit code of the process. ExitStatus int // This thing is a mutex, lock when making modifications concurrently sync.Mutex // contains filtered or unexported fields }
RemoteCmd represents a remote command being prepared or run.
func (*RemoteCmd) SetExited ¶
SetExited is a helper for setting that this process is exited. This should be called by communicators who are running a remote command in order to set that the command is done.
func (*RemoteCmd) StartWithUi ¶
func (r *RemoteCmd) StartWithUi(c Communicator, ui Ui) error
StartWithUi runs the remote command and streams the output to any configured Writers for stdout/stderr, while also writing each line as it comes to a Ui.
type StackableProgressBar ¶
type StackableProgressBar struct { Bar BasicProgressBar ConfigProgressbarFN func(*pb.ProgressBar) // contains filtered or unexported fields }
StackableProgressBar is a progress bar that allows to track multiple downloads at once. Every call to Start increments a counter that will display the number of current loadings. Every call to Start will add total to an internal total that is the total displayed. First call to Start will start a goroutine that is waiting for every download to be finished. Last call to Finish triggers a cleanup. When all active downloads are finished StackableProgressBar will clean itself to a default state.
func (*StackableProgressBar) Add ¶
func (spb *StackableProgressBar) Add(total int64)
func (*StackableProgressBar) Finish ¶
func (spb *StackableProgressBar) Finish()
func (*StackableProgressBar) NewProxyReader ¶
func (spb *StackableProgressBar) NewProxyReader(r io.Reader) io.Reader
func (*StackableProgressBar) Start ¶
func (spb *StackableProgressBar) Start(total int64)
type TargetedUI ¶
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) Error ¶
func (u *TargetedUI) Error(message string)
func (*TargetedUI) Machine ¶
func (u *TargetedUI) Machine(t string, args ...string)
func (*TargetedUI) Message ¶
func (u *TargetedUI) Message(message string)
func (*TargetedUI) ProgressBar ¶
func (u *TargetedUI) ProgressBar() ProgressBar
func (*TargetedUI) Say ¶
func (u *TargetedUI) Say(message string)
type TelemetrySpan ¶
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 ¶
func (s *TelemetrySpan) End(err error)
type TimestampedUi ¶
type TimestampedUi struct {
Ui Ui
}
TimestampedUi is a UI that wraps another UI implementation and prefixes prefixes each message with an RFC3339 timestamp
func (*TimestampedUi) Error ¶
func (u *TimestampedUi) Error(message string)
func (*TimestampedUi) Machine ¶
func (u *TimestampedUi) Machine(message string, args ...string)
func (*TimestampedUi) Message ¶
func (u *TimestampedUi) Message(message string)
func (*TimestampedUi) ProgressBar ¶
func (u *TimestampedUi) ProgressBar() ProgressBar
func (*TimestampedUi) Say ¶
func (u *TimestampedUi) Say(message string)
type Ui ¶
type Ui interface { Ask(string) (string, error) Say(string) Message(string) Error(string) Machine(string, ...string) ProgressBar() ProgressBar }
The Ui interface handles all communication for Packer with the outside world. This sort of control allows us to strictly control how output is formatted and various levels of output.
Source Files ¶
- artifact.go
- artifact_mock.go
- build.go
- builder.go
- builder_mock.go
- cache.go
- communicator.go
- communicator_mock.go
- config_file.go
- config_file_unix.go
- core.go
- hook.go
- hook_mock.go
- logs.go
- multi_error.go
- post_processor.go
- post_processor_mock.go
- progressbar.go
- provisioner.go
- provisioner_mock.go
- telemetry.go
- testing.go
- ui.go
Directories ¶
Path | Synopsis |
---|---|
The plugin package provides the functionality to both expose a Packer plugin binary and to connect to an existing Packer plugin binary.
|
The plugin package provides the functionality to both expose a Packer plugin binary and to connect to an existing Packer plugin binary. |