{"modulePath":"github.com/stackpointcloud/packer","version":"v0.10.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package common\n\n## Functions\n\n```go\nfunc ChooseString(vals ...string) string\n```\nChooseString returns the first non-empty value.\n\n```go\nfunc DownloadableURL(original string) (string, error)\n```\nDownloadableURL processes a URL that may also be a file path and returns a completely valid URL. For example, the original URL might be \"local/file.iso\" which isn't a valid URL. DownloadableURL will return \"file:///local/file.iso\"\n\n```go\nfunc HashForType(t string) hash.Hash\n```\nHashForType returns the Hash implementation for the given string type, or nil if the type is not supported.\n\n```go\nfunc MultistepDebugFn(ui packer.Ui) multistep.DebugPauseFn\n```\nMultistepDebugFn will return a proper multistep.DebugPauseFn to use for debugging if you're using multistep in your builder.\n\n```go\nfunc ScrubConfig(target interface{}, values ...string) string\n```\nScrubConfig is a helper that returns a string representation of any struct with the given values stripped out.\n\n## Types\n\n```go\ntype DownloadClient struct {\n\t// contains filtered or unexported fields\n}\n```\nA DownloadClient helps download, verify checksums, etc.\n\n```go\nfunc NewDownloadClient(c *DownloadConfig) *DownloadClient\n```\nNewDownloadClient returns a new DownloadClient for the given configuration.\n\n```go\nfunc (d *DownloadClient) Cancel()\n```\n\n```go\nfunc (d *DownloadClient) Get() (string, error)\n```\n\n```go\nfunc (d *DownloadClient) PercentProgress() int\n```\nPercentProgress returns the download progress as a percentage.\n\n```go\nfunc (d *DownloadClient) VerifyChecksum(path string) (bool, error)\n```\nVerifyChecksum tests that the path matches the checksum for the download.\n\n```go\ntype DownloadConfig struct {\n\t// The source URL in the form of a string.\n\tUrl string\n\n\t// This is the path to download the file to.\n\tTargetPath string\n\n\t// DownloaderMap maps a schema to a Download.\n\tDownloaderMap map[string]Downloader\n\n\t// If true, this will copy even a local file to the target\n\t// location. If false, then it will \"download\" the file by just\n\t// returning the local path to the file.\n\tCopyFile bool\n\n\t// The hashing implementation to use to checksum the downloaded file.\n\tHash hash.Hash\n\n\t// The checksum for the downloaded file. The hash implementation configuration\n\t// for the downloader will be used to verify with this checksum after\n\t// it is downloaded.\n\tChecksum []byte\n\n\t// What to use for the user agent for HTTP requests. If set to \"\", use the\n\t// default user agent provided by Go.\n\tUserAgent string\n}\n```\nDownloadConfig 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.\n\n```go\ntype Downloader interface {\n\tCancel()\n\tDownload(*os.File, *url.URL) error\n\tProgress() uint\n\tTotal() uint\n}\n```\nA downloader is responsible for actually taking a remote URL and downloading it.\n\n```go\ntype HTTPConfig struct {\n\tHTTPDir     string `mapstructure:\"http_directory\"`\n\tHTTPPortMin uint   `mapstructure:\"http_port_min\"`\n\tHTTPPortMax uint   `mapstructure:\"http_port_max\"`\n}\n```\nHTTPConfig contains configuration for the local HTTP Server\n\n```go\nfunc (c *HTTPConfig) Prepare(ctx *interpolate.Context) []error\n```\n\n```go\ntype HTTPDownloader struct {\n\t// contains filtered or unexported fields\n}\n```\nHTTPDownloader is an implementation of Downloader that downloads files over HTTP.\n\n```go\nfunc (*HTTPDownloader) Cancel()\n```\n\n```go\nfunc (d *HTTPDownloader) Download(dst *os.File, src *url.URL) error\n```\n\n```go\nfunc (d *HTTPDownloader) Progress() uint\n```\n\n```go\nfunc (d *HTTPDownloader) Total() uint\n```\n\n```go\ntype ISOConfig struct {\n\tISOChecksum     string   `mapstructure:\"iso_checksum\"`\n\tISOChecksumURL  string   `mapstructure:\"iso_checksum_url\"`\n\tISOChecksumType string   `mapstructure:\"iso_checksum_type\"`\n\tISOUrls         []string `mapstructure:\"iso_urls\"`\n\tTargetPath      string   `mapstructure:\"iso_target_path\"`\n\tRawSingleISOUrl string   `mapstructure:\"iso_url\"`\n}\n```\nISOConfig contains configuration for downloading ISO images.\n\n```go\nfunc (c *ISOConfig) Prepare(ctx *interpolate.Context) ([]string, []error)\n```\n\n```go\ntype PackerConfig struct {\n\tPackerBuildName   string            `mapstructure:\"packer_build_name\"`\n\tPackerBuilderType string            `mapstructure:\"packer_builder_type\"`\n\tPackerDebug       bool              `mapstructure:\"packer_debug\"`\n\tPackerForce       bool              `mapstructure:\"packer_force\"`\n\tPackerUserVars    map[string]string `mapstructure:\"packer_user_variables\"`\n}\n```\nPackerConfig 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.\n\n```go\ntype StepCreateFloppy struct {\n\tFiles []string\n\n\tFilesAdded map[string]bool\n\t// contains filtered or unexported fields\n}\n```\nStepCreateFloppy will create a floppy disk with the given files. The floppy disk doesn't support sub-directories. Only files at the root level are supported.\n\n```go\nfunc (s *StepCreateFloppy) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepCreateFloppy) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepDownload struct {\n\t// The checksum and the type of the checksum for the download\n\tChecksum     string\n\tChecksumType string\n\n\t// A short description of the type of download being done. Example:\n\t// \"ISO\" or \"Guest Additions\"\n\tDescription string\n\n\t// The name of the key where the final path of the ISO will be put\n\t// into the state.\n\tResultKey string\n\n\t// The path where the result should go, otherwise it goes to the\n\t// cache directory.\n\tTargetPath string\n\n\t// A list of URLs to attempt to download this thing.\n\tUrl []string\n\n\t// Extension is the extension to force for the file that is downloaded.\n\t// Some systems require a certain extension. If this isn't set, the\n\t// extension on the URL is used. Otherwise, this will be forced\n\t// on the downloaded file for every URL.\n\tExtension string\n}\n```\nStepDownload downloads a remote file using the download client within this package. This step handles setting up the download configuration, progress reporting, interrupt handling, etc.\n\nUses:\n\n\tcache packer.Cache\n\tui    packer.Ui\n\n```go\nfunc (s *StepDownload) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepDownload) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepHTTPServer struct {\n\tHTTPDir     string\n\tHTTPPortMin uint\n\tHTTPPortMax uint\n\t// contains filtered or unexported fields\n}\n```\nThis step creates and runs the HTTP server that is serving files from the directory specified by the 'http\\_directory\\` configuration parameter in the template.\n\nUses:\n\n\tui     packer.Ui\n\nProduces:\n\n\thttp_port int - The port the HTTP server started on.\n\n```go\nfunc (s *StepHTTPServer) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepHTTPServer) Run(state multistep.StateBag) multistep.StepAction\n```\n\n```go\ntype StepProvision struct {\n\tComm packer.Communicator\n}\n```\nStepProvision runs the provisioners.\n\nUses:\n\n\tcommunicator packer.Communicator\n\thook         packer.Hook\n\tui           packer.Ui\n\nProduces:\n\n\t\u003cnothing\u003e\n\n```go\nfunc (*StepProvision) Cleanup(multistep.StateBag)\n```\n\n```go\nfunc (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction\n```\n\n","path":"github.com/stackpointcloud/packer/common","name":"common","synopsis":"","isRedistributable":true}
