Documentation ¶
Index ¶
- Constants
- Variables
- func ChooseString(vals ...string) string
- func DownloadableURL(original string) (string, error)
- func FileExistsLocally(original string) bool
- func GetHTTPAddr() string
- func GetTerminalDimensions() (width, height int, err error)
- func HashForType(t string) hash.Hash
- func MultistepDebugFn(ui packer.Ui) multistep.DebugPauseFn
- func NewRunner(steps []multistep.Step, config PackerConfig, ui packer.Ui) multistep.Runner
- func NewRunnerWithPauseFn(steps []multistep.Step, config PackerConfig, ui packer.Ui, ...) multistep.Runner
- func Retry(initialInterval float64, maxInterval float64, numTries uint, ...) error
- func SetHTTPIP(ip string) error
- func SetHTTPPort(port string) error
- func SupportedProtocol(u *url.URL) bool
- func ValidatedURL(original string) (string, error)
- type DownloadClient
- type DownloadConfig
- type Downloader
- type FileDownloader
- type FloppyConfig
- type HTTPConfig
- type HTTPDownloader
- type ISOConfig
- type LocalDownloader
- type PackerConfig
- type RemoteDownloader
- type RetryableFunc
- type SMBDownloader
- type StepCleanupTempKeys
- type StepCreateFloppy
- type StepDownload
- type StepHTTPServer
- type StepProvision
Constants ¶
const PackerKeyDefault = 100 * time.Millisecond
PackerKeyDefault 100ms is appropriate for shared build infrastructure while a shorter delay (e.g. 10ms) can be used on a workstation. See PackerKeyEnv.
const PackerKeyEnv = "PACKER_KEY_INTERVAL"
PackerKeyEnv is used to specify the key interval (delay) between keystrokes sent to the VM, typically in boot commands. This is to prevent host CPU utilization from causing key presses to be skipped or repeated incorrectly.
Variables ¶
var RetryExhaustedError error = fmt.Errorf("Function never succeeded in Retry")
Functions ¶
func ChooseString ¶ added in v0.6.0
ChooseString returns the first non-empty value.
func DownloadableURL ¶
DownloadableURL processes a URL that may also be a file path and returns a completely valid URL representing the requested file. For example, the original URL might be "local/file.iso" which isn't a valid URL, and so DownloadableURL will return "file://local/file.iso" No other transformations are done to the path.
func FileExistsLocally ¶ added in v1.2.0
func GetHTTPAddr ¶ added in v0.12.2
func GetHTTPAddr() string
func GetTerminalDimensions ¶ added in v1.3.0
call into one of the platform-specific implementations to get the current terminal dimensions
func HashForType ¶
HashForType returns the Hash implementation for the given string type, or nil if the type is not supported.
func MultistepDebugFn ¶
func MultistepDebugFn(ui packer.Ui) multistep.DebugPauseFn
MultistepDebugFn will return a proper multistep.DebugPauseFn to use for debugging if you're using multistep in your builder.
func NewRunner ¶ added in v0.11.0
NewRunner returns a multistep.Runner that runs steps augmented with support for -debug and -on-error command line arguments.
func NewRunnerWithPauseFn ¶ added in v0.11.0
func NewRunnerWithPauseFn(steps []multistep.Step, config PackerConfig, ui packer.Ui, state multistep.StateBag) multistep.Runner
NewRunnerWithPauseFn returns a multistep.Runner that runs steps augmented with support for -debug and -on-error command line arguments. With -debug it puts the multistep.DebugPauseFn that will pause execution between steps into the state under the key "pauseFn".
func Retry ¶ added in v0.11.0
func Retry(initialInterval float64, maxInterval float64, numTries uint, function RetryableFunc) error
Retry retries a function up to numTries times with exponential backoff. If numTries == 0, retry indefinitely. If interval == 0, Retry will not delay retrying and there will be no exponential backoff. If maxInterval == 0, maxInterval is set to +Infinity. Intervals are in seconds. Returns an error if initial > max intervals, if retries are exhausted, or if the passed function returns an error.
func SetHTTPPort ¶ added in v0.12.2
func SupportedProtocol ¶ added in v1.2.0
SupportedProtocol verifies that the url passed is actually supported or not This will also validate that the protocol is one that's actually implemented.
func ValidatedURL ¶ added in v1.2.0
Force the parameter into a url. This will transform the parameter into a proper url, removing slashes, adding the proper prefix, etc.
Types ¶
type DownloadClient ¶
type DownloadClient struct {
// contains filtered or unexported fields
}
A DownloadClient helps download, verify checksums, etc.
func NewDownloadClient ¶
func NewDownloadClient(c *DownloadConfig, ui packer.Ui) *DownloadClient
NewDownloadClient returns a new DownloadClient for the given configuration.
func (*DownloadClient) Cancel ¶
func (d *DownloadClient) Cancel()
func (*DownloadClient) Get ¶
func (d *DownloadClient) Get() (string, error)
func (*DownloadClient) VerifyChecksum ¶
func (d *DownloadClient) VerifyChecksum(path string) (bool, error)
VerifyChecksum tests that the path matches the checksum for the download.
type DownloadConfig ¶
type DownloadConfig struct { // The source URL in the form of a string. Url string // This is the path to download the file to. TargetPath string // DownloaderMap maps a schema to a Download. DownloaderMap map[string]Downloader // If true, this will copy even a local file to the target // location. If false, then it will "download" the file by just // returning the local path to the file. CopyFile bool // The hashing implementation to use to checksum the downloaded file. Hash hash.Hash // The checksum for the downloaded file. The hash implementation configuration // for the downloader will be used to verify with this checksum after // it is downloaded. Checksum []byte // What to use for the user agent for HTTP requests. If set to "", use the // default user agent provided by Go. UserAgent string }
DownloadConfig is the configuration given to instantiate a new download instance. Once a configuration is used to instantiate a download client, it must not be modified.
type Downloader ¶
type Downloader interface { Resume() Cancel() ProgressBar() packer.ProgressBar }
Downloader defines what capabilities a downloader should have.
type FileDownloader ¶ added in v1.2.0
FileDownloader is an implementation of Downloader that downloads files using the regular filesystem.
func (*FileDownloader) Cancel ¶ added in v1.2.0
func (d *FileDownloader) Cancel()
func (*FileDownloader) ProgressBar ¶ added in v1.3.0
func (d *FileDownloader) ProgressBar() packer.ProgressBar
func (*FileDownloader) Resume ¶ added in v1.2.0
func (d *FileDownloader) Resume()
type FloppyConfig ¶ added in v0.11.0
type FloppyConfig struct { FloppyFiles []string `mapstructure:"floppy_files"` FloppyDirectories []string `mapstructure:"floppy_dirs"` }
func (*FloppyConfig) Prepare ¶ added in v0.11.0
func (c *FloppyConfig) Prepare(ctx *interpolate.Context) []error
type HTTPConfig ¶ added in v0.9.0
type HTTPConfig struct { HTTPDir string `mapstructure:"http_directory"` HTTPPortMin uint `mapstructure:"http_port_min"` HTTPPortMax uint `mapstructure:"http_port_max"` }
HTTPConfig contains configuration for the local HTTP Server
func (*HTTPConfig) Prepare ¶ added in v0.9.0
func (c *HTTPConfig) Prepare(ctx *interpolate.Context) []error
type HTTPDownloader ¶
HTTPDownloader is an implementation of Downloader that downloads files over HTTP.
func (*HTTPDownloader) Cancel ¶
func (d *HTTPDownloader) Cancel()
func (*HTTPDownloader) ProgressBar ¶ added in v1.3.0
func (d *HTTPDownloader) ProgressBar() packer.ProgressBar
func (*HTTPDownloader) Resume ¶ added in v1.2.0
func (d *HTTPDownloader) Resume()
type ISOConfig ¶ added in v0.9.0
type ISOConfig struct { ISOChecksum string `mapstructure:"iso_checksum"` ISOChecksumURL string `mapstructure:"iso_checksum_url"` ISOChecksumType string `mapstructure:"iso_checksum_type"` ISOUrls []string `mapstructure:"iso_urls"` TargetPath string `mapstructure:"iso_target_path"` TargetExtension string `mapstructure:"iso_target_extension"` RawSingleISOUrl string `mapstructure:"iso_url"` }
ISOConfig contains configuration for downloading ISO images.
type LocalDownloader ¶ added in v1.2.0
type LocalDownloader interface {
// contains filtered or unexported methods
}
A LocalDownloader is responsible for converting a uri to a local path
that the platform can open directly.
type PackerConfig ¶
type PackerConfig struct { PackerBuildName string `mapstructure:"packer_build_name"` PackerBuilderType string `mapstructure:"packer_builder_type"` PackerDebug bool `mapstructure:"packer_debug"` PackerForce bool `mapstructure:"packer_force"` PackerOnError string `mapstructure:"packer_on_error"` PackerUserVars map[string]string `mapstructure:"packer_user_variables"` PackerSensitiveVars []string `mapstructure:"packer_sensitive_variables"` }
PackerConfig is a struct that contains the configuration keys that are sent by packer, properly tagged already so mapstructure can load them. Embed this structure into your configuration class to get it.
type RemoteDownloader ¶ added in v1.2.0
A RemoteDownloader is responsible for actually taking a remote URL and
downloading it.
type RetryableFunc ¶ added in v1.0.0
RetryableFunc performs an action and returns a bool indicating whether the function is done, or if it should keep retrying, and an error which will abort the retry and be returned by the Retry function. The 0-indexed attempt is passed with each call.
type SMBDownloader ¶ added in v1.2.0
SMBDownloader is an implementation of Downloader that downloads files using the "\\" path format on Windows
func (*SMBDownloader) Cancel ¶ added in v1.2.0
func (d *SMBDownloader) Cancel()
func (*SMBDownloader) ProgressBar ¶ added in v1.3.0
func (d *SMBDownloader) ProgressBar() packer.ProgressBar
func (*SMBDownloader) Resume ¶ added in v1.2.0
func (d *SMBDownloader) Resume()
type StepCleanupTempKeys ¶ added in v1.3.1
type StepCleanupTempKeys struct {
Comm *communicator.Config
}
func (*StepCleanupTempKeys) Cleanup ¶ added in v1.3.1
func (s *StepCleanupTempKeys) Cleanup(state multistep.StateBag)
func (*StepCleanupTempKeys) Run ¶ added in v1.3.1
func (s *StepCleanupTempKeys) Run(_ context.Context, state multistep.StateBag) multistep.StepAction
type StepCreateFloppy ¶
type StepCreateFloppy struct { Files []string Directories []string FilesAdded map[string]bool // contains filtered or unexported fields }
StepCreateFloppy will create a floppy disk with the given files.
func (*StepCreateFloppy) Add ¶ added in v0.11.0
func (s *StepCreateFloppy) Add(dircache directoryCache, src string) error
func (*StepCreateFloppy) Cleanup ¶
func (s *StepCreateFloppy) Cleanup(multistep.StateBag)
func (*StepCreateFloppy) Run ¶
func (s *StepCreateFloppy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction
type StepDownload ¶ added in v0.3.2
type StepDownload struct { // The checksum and the type of the checksum for the download Checksum string ChecksumType string // A short description of the type of download being done. Example: // "ISO" or "Guest Additions" Description string // The name of the key where the final path of the ISO will be put // into the state. ResultKey string // The path where the result should go, otherwise it goes to the // cache directory. TargetPath string // A list of URLs to attempt to download this thing. Url []string // Extension is the extension to force for the file that is downloaded. // Some systems require a certain extension. If this isn't set, the // extension on the URL is used. Otherwise, this will be forced // on the downloaded file for every URL. Extension string }
StepDownload downloads a remote file using the download client within this package. This step handles setting up the download configuration, progress reporting, interrupt handling, etc.
Uses:
cache packer.Cache ui packer.Ui
func (*StepDownload) Cleanup ¶ added in v0.3.2
func (s *StepDownload) Cleanup(multistep.StateBag)
func (*StepDownload) Run ¶ added in v0.3.2
func (s *StepDownload) Run(_ context.Context, state multistep.StateBag) multistep.StepAction
type StepHTTPServer ¶ added in v0.9.0
type StepHTTPServer struct { HTTPDir string HTTPPortMin uint HTTPPortMax uint // contains filtered or unexported fields }
This step creates and runs the HTTP server that is serving files from the directory specified by the 'http_directory` configuration parameter in the template.
Uses:
ui packer.Ui
Produces:
http_port int - The port the HTTP server started on.
func (*StepHTTPServer) Cleanup ¶ added in v0.9.0
func (s *StepHTTPServer) Cleanup(multistep.StateBag)
func (*StepHTTPServer) Run ¶ added in v0.9.0
func (s *StepHTTPServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction
type StepProvision ¶
type StepProvision struct {
Comm packer.Communicator
}
StepProvision runs the provisioners.
Uses:
communicator packer.Communicator hook packer.Hook ui packer.Ui
Produces:
<nothing>
func (*StepProvision) Cleanup ¶
func (*StepProvision) Cleanup(multistep.StateBag)
func (*StepProvision) Run ¶
func (s *StepProvision) Run(_ context.Context, state multistep.StateBag) multistep.StepAction