app

package
v0.0.0-...-bceea35 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2017 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoMatch: no match was found
	ErrNoMatch = errors.New("no matches found")
	// ErrPageEmpty: the contents of the retrieved url was empty.
	ErrPageEmpty = errors.New("page empty")
	// ErrChecksumNotFound: the checksum for the iso cannot be found.
	ErrChecksumNotFound = errors.New("checksum not found")
	// ErrChecksumTypeNotSet: the hash type of the checksum was either not set
	// or a valid value.
	ErrChecksumTypeNotSet = errors.New("checksum type not set")
	// ErrNoArch: the architecture of the iso was not set.
	ErrNoArch = errors.New("arch not set")
	// ErrNoFullVersion: the full version information was not set.
	ErrNoFullVersion = errors.New("full version not set")
	// ErrNoMajorVersion: the major version information was not set.
	ErrNoMajorVersion = errors.New("major version not set")
	// ErrNoMinorVersion: the minor version information was not set.
	ErrNoMinorVersion = errors.New("minor version not set")
	// ErrNoRelease: the release of the iso was not set.
	ErrNoRelease = errors.New("release not set")
)
View Source
var BuildDefs map[string]Builds

Defined builds

View Source
var DistroDefaults distroDefaults

Defaults for each supported distribution

View Source
var ErrBuilderNotFound = errors.New("builder not found")
View Source
var ErrEmptyParam = errors.New("received an empty parameter, expected a value")

ErrEmptyParam occurs when the received parameter was empy.

View Source
var ErrNoCommands = errors.New("no commands found")

ErrNoCommands occurs when a referenced command file doesn't have any contents.

View Source
var ErrPostProcessorNotFound = errors.New("post-processor not found")

ErrPostProcessorNotFound occurs when a post-processor with a matching ID is not found in the definition.

View Source
var ErrProvisionerNotFound = errors.New("provisioner not found")

ErrProvisionerNotFound occurs when a provisioner with a matching ID is not found in the definition.

Functions

func BuildBuilds

func BuildBuilds(buildNames ...string) (string, error)

BuildBuilds manages the process of creating Packer Build templates out of the passed build names. All builds are done concurrently. Returns either a message providing information about the processing of the requested builds or an error.

func BuildDistro

func BuildDistro() (string, error)

BuildDistro creates a build based on the target distro's defaults. The ArgsFilter contains information on the target distro and any overrides that are to be applied to the build. Returns either a processing message or an error.

func DeepCopyMapStringBuilderC

func DeepCopyMapStringBuilderC(b map[string]BuilderC) map[string]Componenter

DeepCopyMapStringBuilderC makes a deep copy of each builder passed and returns the copy map[string]builder as a map[string]Componenter{}

func DeepCopyMapStringPostProcessorC

func DeepCopyMapStringPostProcessorC(p map[string]PostProcessorC) map[string]Componenter

DeepCopyMapStringPostProcessor makes a deep copy of each builder passed and returns the copie map[string]postProcessor as a map[string]interface{} Note: This currently only supports string slices.

func DeepCopyMapStringProvisionerC

func DeepCopyMapStringProvisionerC(p map[string]ProvisionerC) map[string]Componenter

DeepCopyMapStringProvisioner makes a deep copy of each builder passed and returns the copied map[string]provisioner as a map[string]interface{}

func IsEmptyPathErr

func IsEmptyPathErr(err error) bool

IsEmptyPathERror returns if the error is an empty path

func MergeSlices

func MergeSlices(s ...[]string) []string

MergeSlices takes a variadic input of []string and returns a string slice with all of the values within the slices merged.

func NewCommunicator

func NewCommunicator(s string) (comm, error)

NewCommunicator returns the communicator for s. If the communicator is 'none', a nil is returned. If the specified communicator does not match a valid communicator, an invalidCommunicatorErr is returned.

func Run

func Run(listNames ...string) ([]string, []error)

Run takes a list of build list names and generates all of the Packer templates associated with them.

func Substring

func Substring(s string, i, l int) string

Substring returns a substring of s starting at i for a length of l chars. If the requested index + requested length is greater than the length of the string, the string contents from the index to the end of the string will be returned instead. Note this assumes UTF-8, i.e. uses rune.

Types

type Archive

type Archive struct {
	// Name is the name of the archive, w/o extensions
	Name string
	// Path to the target directory for the archive output.
	OutDir string
	// Compression type to be used.
	Type string
	// contains filtered or unexported fields
}

Archive holds information about an archive.

func NewArchive

func NewArchive(s string) *Archive

NewArchive returns an Archive, using the received string as its Name.

func (*Archive) DirWalk

func (d *Archive) DirWalk(dirPath string) error

DirWalk walks the passed path, making a list of all the files that are children of the path.

type ArchiveErr

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

ArchiveErr is generated during an archive process.

func (ArchiveErr) Error

func (e ArchiveErr) Error() string

type Build

type Build struct {
	// Targeted builders: either the ID of the builder section or the Packer
	// component type value can be used, e.g. ID: "vbox" or "virtualbox-iso".
	BuilderIDs []string `toml:"builder_ids" json:"builder_ids"`
	// A map of Builder configurations.  When using a VMWare or VirtualBox
	// builder, there is usually a 'common' builder, which has settings common
	// to both VMWare and VirtualBox.
	Builders map[string]BuilderC `toml:"builders" json:"builders"`
	// Targeted post-processors: either the ID of the post-processor or the
	// Packer component type value can be used, e.g. ID: "docker" or
	// "docker-push".
	PostProcessorIDs []string `toml:"post_processor_ids" json:"post_processor_ids"`
	// A map of Post-Processor configurations.
	PostProcessors map[string]PostProcessorC `toml:"post_processors" json:"post_processors"`
	// Targeted provisioners: either the ID of the provisioners or the Packer
	// component type value can be used, e.g. ID: "preprocess" or "shell".
	ProvisionerIDs []string `toml:"provisioner_ids" json:"provisioner_ids"`
	// A map of {rovisioner configurations.
	Provisioners map[string]ProvisionerC `toml:"provisioners" json:"provisioners"`
}

Contains most of the information for Packer templates within a Feedlot Build. The keys of the maps are the IDs

func (*Build) Copy

func (b *Build) Copy() *Build

Copy makes a deep copy of the Build and returns it.

type BuildInf

type BuildInf struct {
	// Name is the name for the build. This may be an assigned value from
	// a TOML file setting.
	Name string `toml:"name" json:"name"`
	// BuildName is the name of the build. This is either the name, as
	// specified in the build.toml file, or a generated name for -distro
	// flag based builds.
	BuildName string `toml:"build_name" json:"build_name"`
	// BaseURL is the base url for the iso.
	BaseURL string `toml:"base_url" json:"base_url"`
	// Region to use when selecting the image mirror; for use with CentOS.
	// This corresponds to the 'Region' column in the
	// https://centos.org/download/full-mirrorlist.csv file.
	//
	// If empty, no region filtering will be applied.  A pointer is used for
	// detection of set vs not set.
	Region *string `toml:"region" json:"region"`
	// Country to use when selecting the image mirror; for use with CentOS.
	// This corresponds to the 'Country' column in the
	// https://centos.org/download/full-mirrorlist.csv file.
	//
	// If empty, no country filtering will be applied.
	//
	//  For Region 'US', this is used as the state field.  A pointer is used
	// for detection of set vs not set.
	Country *string `toml:"country" json:"country"`
	// Sponsor to use when selecting the image mirror: for use with CentOS.
	// This corresponds to the 'Sponsor' column in the
	// https://centos.org/download/full-mirrorlist.csv file.
	//
	// If a value is specified, the country setting is ignored so that
	// Rackspace and Oregon State University, OSUOSL, are not filtered out.
	//
	// For Oregon State University, aside from it's name, OSUOSL and osuosl
	// are accepted values.
	//
	// If empty, no sponsor filtering will be applied.  A pointer is used for
	// detection of set vs not set.
	Sponsor *string `toml:"sponsor" json:"sponsor"`
}

BuildInf is a container for information about a specific build.

type BuildLists

type BuildLists struct {
	Lists map[string]List
}

Contains lists of builds.

func (*BuildLists) Get

func (b *BuildLists) Get(s string) (List, error)

Get returns the requested build list, or an error

func (*BuildLists) Load

func (b *BuildLists) Load(p string) error

Load loads the build lists. It accepts a path prefix; which is mainly used for testing ATM.

type Builder

type Builder int

Builder is a Packer supported builder.

const (
	UnsupportedBuilder Builder = iota
	Common
	Custom
	AmazonChroot
	AmazonEBS
	AmazonInstance
	DigitalOcean
	Docker
	GoogleCompute
	Null
	OpenStack
	ParallelsISO
	ParallelsPVM
	QEMU
	VirtualBoxISO
	VirtualBoxOVF
	VMWareISO
	VMWareVMX
)

Builder constants

func ParseBuilder

func ParseBuilder(s string) Builder

ParseBuilder returns the Builder constant for s. If no match is found, UnsupportedBuilder is returned. All incoming strings are normalized to lowercase.

func (Builder) String

func (b Builder) String() string

type BuilderC

type BuilderC struct {
	TemplateSection
}

BuilderC represents a builder component of a Packer template.

func (*BuilderC) Copy

func (b *BuilderC) Copy() BuilderC

Copy makes a deepcopy of the Builder component.

type BuilderErr

type BuilderErr struct {
	Builder
	Err error
	// contains filtered or unexported fields
}

BuilderErr is an error processing builders, its Err field may contain additional type information.

func (BuilderErr) Error

func (e BuilderErr) Error() string

type Builds

type Builds struct {
	Templates map[string]*RawTemplate
	// contains filtered or unexported fields
}

Struct to hold the builds.

func (*Builds) Load

func (b *Builds) Load(name string) error

Load the build information from the provided name.

type Communicator

type Communicator int

Communicator is a Packer supported communicator.

const (
	InvalidCommunicator Communicator = iota
	NoCommunicator
	SSHCommunicator
	WinRMCommunicator
)

Communicator constants

func ParseCommunicator

func ParseCommunicator(s string) Communicator

ParseCommunicator returns the communicator for the received s. If the value does not match a known communicator, InvalidCommunicator is returned.

func (Communicator) String

func (c Communicator) String() string

type Componenter

type Componenter interface {
	// contains filtered or unexported methods
}

Componenter is an interface for Packer components, i.e. builder, post-processor, and provisioner.

type Defaults

type Defaults struct {
	IODirInf
	PackerInf
	BuildInf
	Build
	// contains filtered or unexported fields
}

Defaults is used to store Feedlot application level defaults for Packer templates.

func (*Defaults) Load

func (d *Defaults) Load(p string) error

Load loads the default settings. If the defaults have already been loaded nothing is done.

type Distro

type Distro int

Distro is the distribution type

const (
	UnsupportedDistro Distro = iota
	CentOS
	Debian
	Ubuntu
)

supported distros

func ParseDistro

func ParseDistro(s string) Distro

ParseDistro returns the Distro constant for the passed string or unsupported.

All incoming strings are normalized to lowercase.

func (Distro) CasedString

func (d Distro) CasedString() string

CasedString returns the distro's name with proper casing.

func (Distro) String

func (d Distro) String() string

type DistroErr

type DistroErr struct {
	Distro
	// contains filtered or unexported fields
}

DistroErr is an error that occurs when processing a distro's information.

func (DistroErr) Error

func (d DistroErr) Error() string

type EmptyPathErr

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

func (EmptyPathErr) Error

func (e EmptyPathErr) Error() string

type Error

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

Error is the generic error wrapper used by this package.

func (Error) Error

func (e Error) Error() string

type IODirInf

type IODirInf struct {
	// Include the packer component name in the path. If true, the
	// component.String() value will be added as the parent of the output
	// resource path: i.e. OutDir/component.String()/resource_name.  This is a
	// pointer so that whether or not this setting was actually set can be
	// determined, otherwise determining whether it was an explicit false or
	// empty would not be possible.
	IncludeComponentString *bool `toml:"include_component_string" json:"include_component_string"`
	// PackerOutputDir is the output directory for the Packer artificts, when
	// applicable.  This is usually referenced in a Builder's output directory,
	// e.g. "output_dir=:packer_output_dir"
	PackerOutputDir string `toml:"packer_output_dir" json:"packer_output_dir"`
	// The directory that contains the source files for a build.
	SourceDir string `toml:"source_dir" json:"source_dir"`
	// If the source dir path is relative to the conf_dir.  If true, the path
	// is resolved relative to the conf_dir.  Otherwise, the path is used as
	// is.  This is a pointer so that whether or not this setting was actually
	// set can be determined, otherwise determining whether it was an explicit
	// false or empty would not be possible.
	SourceDirIsRelative *bool `toml:"source_dir_is_relative" json:"source_dir_is_relative"`
	// The output directory for a generated Packer template and its resources.
	TemplateOutputDir string `toml:"template_output_dir" json:"template_output_dir"`
	// If the template output dir path is relative to the current working
	// directory.  If true, the path is resolved relative to the working
	// directory, otherwise, the path is used as is.  This is a pointer so that
	// whether or not this setting was actually set can be determined,
	// otherwise determining whether it was an explicit false or empty would
	// not be possible.
	TemplateOutputDirIsRelative *bool `toml:"template_output_dir_is_relative" json:"template_output_dir_is_relative"`
}

IODirInf is used to store information about where Feedlot can find and put things. Source files are always in a SourceDir.

type ISO

type ISO struct {
	// The baseURL for download url formation. Usage of this is distro
	// specific.
	BaseURL string
	// The url for the checksum page
	ReleaseURL string
	// The actual checksum for the ISO file that this struct represents.
	Checksum string
	// The type of the Checksum.
	ChecksumType string
	// Name of the ISO.
	Name string
}

ISO image information

type InvalidComponentErr

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

func (InvalidComponentErr) Error

func (e InvalidComponentErr) Error() string

type List

type List struct {
	Builds []string
}

A List contains 1 or more builds.

type PackerInf

type PackerInf struct {
	MinPackerVersion string `toml:"min_packer_version" json:"min_packer_version"`
	Description      string `toml:"description" json:"description"`
}

PackerInf is used to store information about a Packer Template. In Packer, these fields are optional, put used here because they are always printed out in a template as custom creation of template output hasn't been written--it may never be written.

type PackerTemplate

type PackerTemplate struct {
	Description      string                 `json:"description"`
	MinPackerVersion string                 `json:"min_packer_version"`
	Builders         []interface{}          `json:"builders,omitempty"`
	PostProcessors   []interface{}          `json:"post-processors,omitempty"`
	Provisioners     []interface{}          `json:"provisioners,omitempty"`
	Variables        map[string]interface{} `json:"variables,omitempty"`
}

type PostProcessor

type PostProcessor int

PostProcessor is a Packer supported post-processor.

const (
	UnsupportedPostProcessor PostProcessor = iota
	Atlas
	Compress
	DockerImport
	DockerPush
	DockerSave
	DockerTag
	Vagrant
	VagrantCloud
	VSphere
)

PostProcessor constants

func PostProcessorFromString

func PostProcessorFromString(s string) PostProcessor

PostProcessorFromString returns the PostProcessor constant for the passed string, or unsupported. All incoming strings are normalized to lowercase.

func (PostProcessor) String

func (p PostProcessor) String() string

type PostProcessorC

type PostProcessorC struct {
	TemplateSection
}

PostProcessorC represents a Packer post-processor component.

func (*PostProcessorC) Copy

func (p *PostProcessorC) Copy() PostProcessorC

Copy makes a deep copy of the PostProcessor component.

type PostProcessorErr

type PostProcessorErr struct {
	PostProcessor
	Err error
	// contains filtered or unexported fields
}

PostProcessorErr is an error processing post-processors, its Err field may contain additional type information.

func (PostProcessorErr) Error

func (e PostProcessorErr) Error() string

type Provisioner

type Provisioner int

Provisioner is a packer supported provisioner

const (
	UnsupportedProvisioner Provisioner = iota
	Ansible
	AnsibleLocal
	ChefClient
	ChefSolo
	File
	PuppetMasterless
	PuppetServer
	Salt
	Shell
	ShellLocal
)

Provisioner constants

func ParseProvisioner

func ParseProvisioner(s string) Provisioner

ParseProvisioner returns the Provisioner constant for s. If no match is found, UnsupportedProvisioner is returned. All incoming strings are normalized to lowercase

func (Provisioner) String

func (p Provisioner) String() string

type ProvisionerC

type ProvisionerC struct {
	TemplateSection
}

ProvisionerC representa Packer provisioner component.

func (*ProvisionerC) Copy

func (p *ProvisionerC) Copy() ProvisionerC

Copy makes a deep copy of the Provisioner component.

type ProvisionerErr

type ProvisionerErr struct {
	Provisioner
	Err error
	// contains filtered or unexported fields
}

ProvisionerErr is an error processing provisioner, its Err field may contain additional type information.

func (ProvisionerErr) Error

func (e ProvisionerErr) Error() string

type RawTemplate

type RawTemplate struct {
	PackerInf
	IODirInf
	BuildInf
	// Example settings
	IsExample  bool
	ExampleDir string
	// holds release information
	ReleaseISO Releaser
	// the builder specific string for the template's OS and Arch
	OSType string
	// Current date in ISO 8601
	Date string
	// The character(s) used to identify variables for Feedlot. By default
	// this is a colon, :. Currently only a starting delimeter is supported.
	Delim string
	// The distro that this template targets. The type must be a supported
	// type, i.e. defined in supported.toml. The values for type are
	// consistent with Packer values.
	Distro string
	// The architecture for the ISO image, this is either 32bit or 64bit,
	// with the actual values being dependent on the operating system and
	// the target builder.
	Arch string
	// The image for the ISO. This is distro dependent.
	Image string
	// The release, or version, for the ISO. Usage and values are distro
	// dependent, however only version currently supported images that are
	// available on the distro's download site are supported.
	Release string
	// VarVals is a variable replacement map used in finalizing the value of strings for
	// which variable replacement is supported.
	VarVals map[string]string
	// Contains all the build information needed to create the target Packer
	// template and its associated artifacts.
	Build
	// Files maps destination files to their sources. These are the actual file locations
	// after they have been resolved. The destination file is the key, the source file
	// is the value
	Files map[string]string
	// Dirs maps destination directories to their source directories. Everything within
	// the directory will be copied. The same resolution rules apply for dirs as for
	// files. The destination directory is the key, the source directory is the value
	Dirs map[string]string
}

RawTemplate holds all the information for a Feedlot template. This is used to generate the Packer Build.

func (*RawTemplate) Copy

func (r *RawTemplate) Copy() *RawTemplate

Copy makes a deep copy of the template and returns the new copy.

func (*RawTemplate) ISOInfo

func (r *RawTemplate) ISOInfo(builderType Builder, settings []string) error

ISOInfo sets the ISO info for the template's supported distro type. This also sets the builder specific string, when applicable. TODO: these should use new functions in release.go. instead of creating the structs here

type Releaser

type Releaser interface {
	SetISOInfo() error
	// contains filtered or unexported methods
}

type RequiredSettingErr

type RequiredSettingErr struct {
	Key string
}

RequiredSettingErr occurs when a setting required by the Packer component being processed isn't set.

func (RequiredSettingErr) Error

func (e RequiredSettingErr) Error() string

type SSH

type SSH struct {
	// The address to SSH to. This usually is automatically configured by the builder.
	Host string
	// The port to connect to SSH. This defaults to 22.
	Port int
	// The username to connect to SSH with.
	Username string
	// A plaintext password to use to authenticate with SSH.
	Password string
	// Path to a PEM encoded private key file to use to authentiate with SSH.
	PrivateKeyFile string
	// If true, a PTY will be requested for the SSH connection. This defaults to false.
	PTY bool
	// The time to wait for SSH to become available. Packer uses this to determine when the
	// machine has booted so this is usually quite long. Example value: "10m"
	Timeout string
	// The number of handshakes to attempt with SSH once it can connect. This defaults to 10.
	HandshakeAttempts int
	//  If true, SSH agent forwarding will be disabled.
	DisableAgent bool
	// A bastion host to use for the actual SSH connection.
	BastionHost string
	// The port of the bastion host. Defaults to 22.
	BastionPort int
	// The username to connect to the bastion host.
	BastionUsername string
	// The password to use to authenticate with the bastion host.
	BastionPassword string
	// A private key file to use to authenticate with the bastion host.
	BastionPrivateKeyFile string
}

SSH communicator. In the templates, the actual field names are prefixed with ssh_, e.g. ssh_host. The field comments are copied from https://www.packer.io/docs/templates/communicator.html

type SettingErr

type SettingErr struct {
	Key   string
	Value string
	// contains filtered or unexported fields
}

SettingErr occurs when there is a problem with a packer component setting.

func (SettingErr) Error

func (e SettingErr) Error() string

type SupportedDistro

type SupportedDistro struct {
	IODirInf
	PackerInf
	BuildInf
	// The supported Architectures, which can differ per distro. The labels can also
	// differ, e.g. amd64 and x86_64.
	Arch []string `toml:"arch" json:"arch"`
	// Supported iso Images, e.g. server, minimal, etc.
	Image []string `toml:"image" json:"image"`
	// Supported Releases: the supported Releases are the Releases available for
	// download from that distribution's download page. Archived and unsupported
	// Releases are not used.
	Release []string `toml:"release" json:"release"`
	// The default Image configuration for this distribution. This usually consists of
	// things like Release, Architecture, Image type, etc.
	DefImage []string `toml:"default_image" json:"default_image"`
	// The configurations needed to generate the default settings for a build for this
	// distribution.
	Build
}

Struct to hold the details of supported distros. From this information a user should be able to build a Packer template by only executing the following, at minimum:

$ feedlot build -distro=ubuntu

All settings can be overridden. The information here represents the standard box configuration for its respective distribution.

type SupportedDistros

type SupportedDistros struct {
	Distros map[string]*SupportedDistro
	// contains filtered or unexported fields
}

To add support for a distribution, the information about it must be added to the supported. file, in addition to adding the code to support it to the application.

func (*SupportedDistros) Load

func (s *SupportedDistros) Load(p string) error

Load the supported distro info.

type TemplateSection

type TemplateSection struct {
	// Type is the actual Packer component type, this may or may not be the
	// same as the map key (ID).
	Type string `toml:"type" json:"type"`
	// Settings are string settings in "key=value" format.
	Settings []string `toml:"settings" json:"settings"`
	// Arrays are the string array settings.
	Arrays map[string]interface{} `toml:"arrays" json:"arrays"`
}

TemplateSection is used as an embedded type.

type UnsupportedDistroErr

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

func (UnsupportedDistroErr) Error

func (e UnsupportedDistroErr) Error() string

type WinRM

type WinRM struct {
	// The address for WinRM to connect to.
	Host string
	// The WinRM port to connect to. This defaults to 5985.
	Port int
	// The username to use to connect to WinRM.
	Username string
	// The password to use to connect to WinRM.
	Password string
	// The amount of time to wait for WinRM to become available. This defaults to "30m"
	// since setting up a Windows machine generally takes a long time.
	Timeout string
	// If true, use HTTPS for WinRM
	UseSSL bool
	// If true, do not check server certificate chain and host name
	Insecure bool
}

WinRm communicator. In the templates, the actual field names are prefixed with winrm_, e.g. winrm_host. The field comments are copied from https://www.packer.io/docs/templates/communicator.html

Jump to

Keyboard shortcuts

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