docker

package
v1.7.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	BuilderId       = "packer.docker"
	BuilderIdImport = "packer.post-processor.docker-import"
)

Variables

This section is empty.

Functions

func ConfigTmpDir added in v1.3.4

func ConfigTmpDir() (string, error)

ConfigTmpDir returns the configuration tmp directory for Docker

Types

type AwsAccessConfig added in v0.11.0

type AwsAccessConfig struct {
	// The AWS access key used to communicate with
	// AWS. Learn how to set
	// this.
	AccessKey string `mapstructure:"aws_access_key" required:"false"`
	// The AWS secret key used to communicate with
	// AWS. Learn how to set
	// this.
	SecretKey string `mapstructure:"aws_secret_key" required:"false"`
	// The AWS access token to use. This is different from
	// the access key and secret key. If you're not sure what this is, then you
	// probably don't need it. This will also be read from the AWS_SESSION_TOKEN
	// environmental variable.
	Token string `mapstructure:"aws_token" required:"false"`
	// The AWS shared credentials profile used to
	// communicate with AWS. Learn how to set
	// this.
	Profile string `mapstructure:"aws_profile" required:"false"`
	// contains filtered or unexported fields
}

func (*AwsAccessConfig) EcrGetLogin added in v0.11.0

func (c *AwsAccessConfig) EcrGetLogin(ecrUrl string) (string, string, error)

Get a login token for Amazon AWS ECR. Returns username and password or an error.

type Builder

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

func (*Builder) ConfigSpec added in v1.5.0

func (b *Builder) ConfigSpec() hcldec.ObjectSpec

func (*Builder) Prepare

func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error)

func (*Builder) Run

type Communicator

type Communicator struct {
	ContainerID   string
	HostDir       string
	ContainerDir  string
	Version       *version.Version
	Config        *Config
	ContainerUser string

	EntryPoint []string
	// contains filtered or unexported fields
}

func (*Communicator) Download

func (c *Communicator) Download(src string, dst io.Writer) error

Download pulls a file out of a container using `docker cp`. We have a source path and want to write to an io.Writer, not a file. We use - to make docker cp to write to stdout, and then copy the stream to our destination io.Writer.

func (*Communicator) DownloadDir added in v0.9.0

func (c *Communicator) DownloadDir(src string, dst string, exclude []string) error

func (*Communicator) Start

func (c *Communicator) Start(ctx context.Context, remote *packersdk.RemoteCmd) error

func (*Communicator) Upload

func (c *Communicator) Upload(dst string, src io.Reader, fi *os.FileInfo) error

Upload uploads a file to the docker container

func (*Communicator) UploadDir

func (c *Communicator) UploadDir(dst string, src string, exclude []string) error

type Config

type Config struct {
	common.PackerConfig `mapstructure:",squash"`
	Comm                communicator.Config `mapstructure:",squash"`

	// Set the author (e-mail) of a commit.
	Author string `mapstructure:"author"`
	// Dockerfile instructions to add to the commit. Example of instructions
	// are CMD, ENTRYPOINT, ENV, and EXPOSE. Example: [ "USER ubuntu", "WORKDIR
	// /app", "EXPOSE 8080" ]
	Changes []string `mapstructure:"changes"`
	// If true, the container will be committed to an image rather than exported.
	Commit bool `mapstructure:"commit" required:"true"`

	// The directory inside container to mount temp directory from host server
	// for work [file provisioner](/docs/provisioners/file). This defaults
	// to c:/packer-files on windows and /packer-files on other systems.
	ContainerDir string `mapstructure:"container_dir" required:"false"`
	// An array of devices which will be accessible in container when it's run
	// without `--privileged` flag.
	Device []string `mapstructure:"device" required:"false"`
	// Throw away the container when the build is complete. This is useful for
	// the [artifice
	// post-processor](/docs/post-processors/artifice).
	Discard bool `mapstructure:"discard" required:"true"`
	// An array of additional [Linux
	// capabilities](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities)
	// to grant to the container.
	CapAdd []string `mapstructure:"cap_add" required:"false"`
	// An array of [Linux
	// capabilities](https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities)
	// to drop from the container.
	CapDrop []string `mapstructure:"cap_drop" required:"false"`
	// Username (UID) to run remote commands with. You can also set the group
	// name/ID if you want: (UID or UID:GID). You may need this if you get
	// permission errors trying to run the shell or other provisioners.
	ExecUser string `mapstructure:"exec_user" required:"false"`
	// The path where the final container will be exported as a tar file.
	ExportPath string `mapstructure:"export_path" required:"true"`
	// The base image for the Docker container that will be started. This image
	// will be pulled from the Docker registry if it doesn't already exist.
	Image string `mapstructure:"image" required:"true"`
	// Set a message for the commit.
	Message string `mapstructure:"message" required:"true"`
	// If true, run the docker container with the `--privileged` flag. This
	// defaults to false if not set.
	Privileged bool `mapstructure:"privileged" required:"false"`
	Pty        bool
	// If true, the configured image will be pulled using `docker pull` prior
	// to use. Otherwise, it is assumed the image already exists and can be
	// used. This defaults to true if not set.
	Pull bool `mapstructure:"pull" required:"false"`
	// An array of arguments to pass to docker run in order to run the
	// container. By default this is set to `["-d", "-i", "-t",
	// "--entrypoint=/bin/sh", "--", "{{.Image}}"]` if you are using a linux
	// container, and `["-d", "-i", "-t", "--entrypoint=powershell", "--",
	// "{{.Image}}"]` if you are running a windows container. `{{.Image}}` is a
	// template variable that corresponds to the image template option. Passing
	// the entrypoint option this way will make it the default entrypoint of
	// the resulting image, so running docker run -it --rm  will start the
	// docker image from the /bin/sh shell interpreter; you could run a script
	// or another shell by running docker run -it --rm  -c /bin/bash. If your
	// docker image embeds a binary intended to be run often, you should
	// consider changing the default entrypoint to point to it.
	RunCommand []string `mapstructure:"run_command" required:"false"`
	// An array of additional tmpfs volumes to mount into this container.
	TmpFs []string `mapstructure:"tmpfs" required:"false"`
	// A mapping of additional volumes to mount into this container. The key of
	// the object is the host path, the value is the container path.
	Volumes map[string]string `mapstructure:"volumes" required:"false"`
	// If true, files uploaded to the container will be owned by the user the
	// container is running as. If false, the owner will depend on the version
	// of docker installed in the system. Defaults to true.
	FixUploadOwner bool `mapstructure:"fix_upload_owner" required:"false"`
	// If "true", tells Packer that you are building a Windows container
	// running on a windows host. This is necessary for building Windows
	// containers, because our normal docker bindings do not work for them.
	WindowsContainer bool `mapstructure:"windows_container" required:"false"`

	// This is used to login to dockerhub to pull a private base container. For
	// pushing to dockerhub, see the docker post-processors
	Login bool `mapstructure:"login" required:"false"`
	// The password to use to authenticate to login.
	LoginPassword string `mapstructure:"login_password" required:"false"`
	// The server address to login to.
	LoginServer string `mapstructure:"login_server" required:"false"`
	// The username to use to authenticate to login.
	LoginUsername string `mapstructure:"login_username" required:"false"`
	// Defaults to false. If true, the builder will login in order to pull the
	// image from Amazon EC2 Container Registry (ECR). The builder only logs in
	// for the duration of the pull. If true login_server is required and
	// login, login_username, and login_password will be ignored. For more
	// information see the section on ECR.
	EcrLogin        bool `mapstructure:"ecr_login" required:"false"`
	AwsAccessConfig `mapstructure:",squash"`
	// contains filtered or unexported fields
}

func (*Config) FlatMapstructure added in v1.4.5

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

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

func (*Config) Prepare added in v1.5.0

func (c *Config) Prepare(raws ...interface{}) ([]string, error)

type ContainerConfig

type ContainerConfig struct {
	Image      string
	RunCommand []string
	Device     []string
	CapAdd     []string
	CapDrop    []string
	Volumes    map[string]string
	TmpFs      []string
	Privileged bool
}

ContainerConfig is the configuration used to start a container.

type DockerDriver

type DockerDriver struct {
	Ui  packersdk.Ui
	Ctx *interpolate.Context
	// contains filtered or unexported fields
}

func (*DockerDriver) Commit added in v0.7.0

func (d *DockerDriver) Commit(id string, author string, changes []string, message string) (string, error)

func (*DockerDriver) DeleteImage added in v0.5.2

func (d *DockerDriver) DeleteImage(id string) error

func (*DockerDriver) Export

func (d *DockerDriver) Export(id string, dst io.Writer) error

func (*DockerDriver) IPAddress added in v0.8.0

func (d *DockerDriver) IPAddress(id string) (string, error)

func (*DockerDriver) Import added in v0.5.2

func (d *DockerDriver) Import(path string, changes []string, repo string) (string, error)

func (*DockerDriver) KillContainer added in v1.4.0

func (d *DockerDriver) KillContainer(id string) error

func (*DockerDriver) Login added in v0.7.0

func (d *DockerDriver) Login(repo, user, pass string) error

func (*DockerDriver) Logout added in v0.7.0

func (d *DockerDriver) Logout(repo string) error

func (*DockerDriver) Pull

func (d *DockerDriver) Pull(image string) error

func (*DockerDriver) Push added in v0.5.2

func (d *DockerDriver) Push(name string) error

func (*DockerDriver) SaveImage added in v0.7.0

func (d *DockerDriver) SaveImage(id string, dst io.Writer) error

func (*DockerDriver) Sha256 added in v1.6.3

func (d *DockerDriver) Sha256(id string) (string, error)

func (*DockerDriver) StartContainer

func (d *DockerDriver) StartContainer(config *ContainerConfig) (string, error)

func (*DockerDriver) StopContainer

func (d *DockerDriver) StopContainer(id string) error

func (*DockerDriver) TagImage added in v0.7.0

func (d *DockerDriver) TagImage(id string, repo string, force bool) error

func (*DockerDriver) Verify

func (d *DockerDriver) Verify() error

func (*DockerDriver) Version added in v0.8.0

func (d *DockerDriver) Version() (*version.Version, error)

type Driver

type Driver interface {
	// Commit the container to a tag
	Commit(id string, author string, changes []string, message string) (string, error)

	// Delete an image that is imported into Docker
	DeleteImage(id string) error

	// Export exports the container with the given ID to the given writer.
	Export(id string, dst io.Writer) error

	// Import imports a container from a tar file
	Import(path string, changes []string, repo string) (string, error)

	// IPAddress returns the address of the container that can be used
	// for external access.
	IPAddress(id string) (string, error)

	// Sha256 returns the sha256 id of the image
	Sha256(id string) (string, error)

	// Login. This will lock the driver from performing another Login
	// until Logout is called. Therefore, any users MUST call Logout.
	Login(repo, username, password string) error

	// Logout. This can only be called if Login succeeded.
	Logout(repo string) error

	// Pull should pull down the given image.
	Pull(image string) error

	// Push pushes an image to a Docker index/registry.
	Push(name string) error

	// Save an image with the given ID to the given writer.
	SaveImage(id string, dst io.Writer) error

	// StartContainer starts a container and returns the ID for that container,
	// along with a potential error.
	StartContainer(*ContainerConfig) (string, error)

	// KillContainer forcibly stops a container.
	KillContainer(id string) error

	// StopContainer gently stops a container.
	StopContainer(id string) error

	// TagImage tags the image with the given ID
	TagImage(id string, repo string, force bool) error

	// Verify verifies that the driver can run
	Verify() error

	// Version reads the Docker version
	Version() (*version.Version, error)
}

Driver is the interface that has to be implemented to communicate with Docker. The Driver interface also allows the steps to be tested since a mock driver can be shimmed in.

type ExportArtifact

type ExportArtifact struct {

	// StateData should store data such as GeneratedData
	// to be shared with post-processors
	StateData map[string]interface{}
	// contains filtered or unexported fields
}

ExportArtifact is an Artifact implementation for when a container is exported from docker into a single flat file.

func (*ExportArtifact) BuilderId

func (*ExportArtifact) BuilderId() string

func (*ExportArtifact) Destroy

func (a *ExportArtifact) Destroy() error

func (*ExportArtifact) Files

func (a *ExportArtifact) Files() []string

func (*ExportArtifact) Id

func (*ExportArtifact) Id() string

func (*ExportArtifact) State added in v0.7.2

func (a *ExportArtifact) State(name string) interface{}

func (*ExportArtifact) String

func (a *ExportArtifact) String() string

type FlatConfig added in v1.4.5

type FlatConfig struct {
	PackerBuildName           *string           `mapstructure:"packer_build_name" cty:"packer_build_name" hcl:"packer_build_name"`
	PackerBuilderType         *string           `mapstructure:"packer_builder_type" cty:"packer_builder_type" hcl:"packer_builder_type"`
	PackerCoreVersion         *string           `mapstructure:"packer_core_version" cty:"packer_core_version" hcl:"packer_core_version"`
	PackerDebug               *bool             `mapstructure:"packer_debug" cty:"packer_debug" hcl:"packer_debug"`
	PackerForce               *bool             `mapstructure:"packer_force" cty:"packer_force" hcl:"packer_force"`
	PackerOnError             *string           `mapstructure:"packer_on_error" cty:"packer_on_error" hcl:"packer_on_error"`
	PackerUserVars            map[string]string `mapstructure:"packer_user_variables" cty:"packer_user_variables" hcl:"packer_user_variables"`
	PackerSensitiveVars       []string          `mapstructure:"packer_sensitive_variables" cty:"packer_sensitive_variables" hcl:"packer_sensitive_variables"`
	Type                      *string           `mapstructure:"communicator" cty:"communicator" hcl:"communicator"`
	PauseBeforeConnect        *string           `mapstructure:"pause_before_connecting" cty:"pause_before_connecting" hcl:"pause_before_connecting"`
	SSHHost                   *string           `mapstructure:"ssh_host" cty:"ssh_host" hcl:"ssh_host"`
	SSHPort                   *int              `mapstructure:"ssh_port" cty:"ssh_port" hcl:"ssh_port"`
	SSHUsername               *string           `mapstructure:"ssh_username" cty:"ssh_username" hcl:"ssh_username"`
	SSHPassword               *string           `mapstructure:"ssh_password" cty:"ssh_password" hcl:"ssh_password"`
	SSHKeyPairName            *string           `mapstructure:"ssh_keypair_name" undocumented:"true" cty:"ssh_keypair_name" hcl:"ssh_keypair_name"`
	SSHTemporaryKeyPairName   *string           `mapstructure:"temporary_key_pair_name" undocumented:"true" cty:"temporary_key_pair_name" hcl:"temporary_key_pair_name"`
	SSHTemporaryKeyPairType   *string           `mapstructure:"temporary_key_pair_type" cty:"temporary_key_pair_type" hcl:"temporary_key_pair_type"`
	SSHTemporaryKeyPairBits   *int              `mapstructure:"temporary_key_pair_bits" cty:"temporary_key_pair_bits" hcl:"temporary_key_pair_bits"`
	SSHCiphers                []string          `mapstructure:"ssh_ciphers" cty:"ssh_ciphers" hcl:"ssh_ciphers"`
	SSHClearAuthorizedKeys    *bool             `mapstructure:"ssh_clear_authorized_keys" cty:"ssh_clear_authorized_keys" hcl:"ssh_clear_authorized_keys"`
	SSHKEXAlgos               []string          `mapstructure:"ssh_key_exchange_algorithms" cty:"ssh_key_exchange_algorithms" hcl:"ssh_key_exchange_algorithms"`
	SSHPrivateKeyFile         *string           `mapstructure:"ssh_private_key_file" undocumented:"true" cty:"ssh_private_key_file" hcl:"ssh_private_key_file"`
	SSHCertificateFile        *string           `mapstructure:"ssh_certificate_file" cty:"ssh_certificate_file" hcl:"ssh_certificate_file"`
	SSHPty                    *bool             `mapstructure:"ssh_pty" cty:"ssh_pty" hcl:"ssh_pty"`
	SSHTimeout                *string           `mapstructure:"ssh_timeout" cty:"ssh_timeout" hcl:"ssh_timeout"`
	SSHWaitTimeout            *string           `mapstructure:"ssh_wait_timeout" undocumented:"true" cty:"ssh_wait_timeout" hcl:"ssh_wait_timeout"`
	SSHAgentAuth              *bool             `mapstructure:"ssh_agent_auth" undocumented:"true" cty:"ssh_agent_auth" hcl:"ssh_agent_auth"`
	SSHDisableAgentForwarding *bool             `mapstructure:"ssh_disable_agent_forwarding" cty:"ssh_disable_agent_forwarding" hcl:"ssh_disable_agent_forwarding"`
	SSHHandshakeAttempts      *int              `mapstructure:"ssh_handshake_attempts" cty:"ssh_handshake_attempts" hcl:"ssh_handshake_attempts"`
	SSHBastionHost            *string           `mapstructure:"ssh_bastion_host" cty:"ssh_bastion_host" hcl:"ssh_bastion_host"`
	SSHBastionPort            *int              `mapstructure:"ssh_bastion_port" cty:"ssh_bastion_port" hcl:"ssh_bastion_port"`
	SSHBastionAgentAuth       *bool             `mapstructure:"ssh_bastion_agent_auth" cty:"ssh_bastion_agent_auth" hcl:"ssh_bastion_agent_auth"`
	SSHBastionUsername        *string           `mapstructure:"ssh_bastion_username" cty:"ssh_bastion_username" hcl:"ssh_bastion_username"`
	SSHBastionPassword        *string           `mapstructure:"ssh_bastion_password" cty:"ssh_bastion_password" hcl:"ssh_bastion_password"`
	SSHBastionInteractive     *bool             `mapstructure:"ssh_bastion_interactive" cty:"ssh_bastion_interactive" hcl:"ssh_bastion_interactive"`
	SSHBastionPrivateKeyFile  *string           `mapstructure:"ssh_bastion_private_key_file" cty:"ssh_bastion_private_key_file" hcl:"ssh_bastion_private_key_file"`
	SSHBastionCertificateFile *string           `mapstructure:"ssh_bastion_certificate_file" cty:"ssh_bastion_certificate_file" hcl:"ssh_bastion_certificate_file"`
	SSHFileTransferMethod     *string           `mapstructure:"ssh_file_transfer_method" cty:"ssh_file_transfer_method" hcl:"ssh_file_transfer_method"`
	SSHProxyHost              *string           `mapstructure:"ssh_proxy_host" cty:"ssh_proxy_host" hcl:"ssh_proxy_host"`
	SSHProxyPort              *int              `mapstructure:"ssh_proxy_port" cty:"ssh_proxy_port" hcl:"ssh_proxy_port"`
	SSHProxyUsername          *string           `mapstructure:"ssh_proxy_username" cty:"ssh_proxy_username" hcl:"ssh_proxy_username"`
	SSHProxyPassword          *string           `mapstructure:"ssh_proxy_password" cty:"ssh_proxy_password" hcl:"ssh_proxy_password"`
	SSHKeepAliveInterval      *string           `mapstructure:"ssh_keep_alive_interval" cty:"ssh_keep_alive_interval" hcl:"ssh_keep_alive_interval"`
	SSHReadWriteTimeout       *string           `mapstructure:"ssh_read_write_timeout" cty:"ssh_read_write_timeout" hcl:"ssh_read_write_timeout"`
	SSHRemoteTunnels          []string          `mapstructure:"ssh_remote_tunnels" cty:"ssh_remote_tunnels" hcl:"ssh_remote_tunnels"`
	SSHLocalTunnels           []string          `mapstructure:"ssh_local_tunnels" cty:"ssh_local_tunnels" hcl:"ssh_local_tunnels"`
	SSHPublicKey              []byte            `mapstructure:"ssh_public_key" undocumented:"true" cty:"ssh_public_key" hcl:"ssh_public_key"`
	SSHPrivateKey             []byte            `mapstructure:"ssh_private_key" undocumented:"true" cty:"ssh_private_key" hcl:"ssh_private_key"`
	WinRMUser                 *string           `mapstructure:"winrm_username" cty:"winrm_username" hcl:"winrm_username"`
	WinRMPassword             *string           `mapstructure:"winrm_password" cty:"winrm_password" hcl:"winrm_password"`
	WinRMHost                 *string           `mapstructure:"winrm_host" cty:"winrm_host" hcl:"winrm_host"`
	WinRMNoProxy              *bool             `mapstructure:"winrm_no_proxy" cty:"winrm_no_proxy" hcl:"winrm_no_proxy"`
	WinRMPort                 *int              `mapstructure:"winrm_port" cty:"winrm_port" hcl:"winrm_port"`
	WinRMTimeout              *string           `mapstructure:"winrm_timeout" cty:"winrm_timeout" hcl:"winrm_timeout"`
	WinRMUseSSL               *bool             `mapstructure:"winrm_use_ssl" cty:"winrm_use_ssl" hcl:"winrm_use_ssl"`
	WinRMInsecure             *bool             `mapstructure:"winrm_insecure" cty:"winrm_insecure" hcl:"winrm_insecure"`
	WinRMUseNTLM              *bool             `mapstructure:"winrm_use_ntlm" cty:"winrm_use_ntlm" hcl:"winrm_use_ntlm"`
	Author                    *string           `mapstructure:"author" cty:"author" hcl:"author"`
	Changes                   []string          `mapstructure:"changes" cty:"changes" hcl:"changes"`
	Commit                    *bool             `mapstructure:"commit" required:"true" cty:"commit" hcl:"commit"`
	ContainerDir              *string           `mapstructure:"container_dir" required:"false" cty:"container_dir" hcl:"container_dir"`
	Device                    []string          `mapstructure:"device" required:"false" cty:"device" hcl:"device"`
	Discard                   *bool             `mapstructure:"discard" required:"true" cty:"discard" hcl:"discard"`
	CapAdd                    []string          `mapstructure:"cap_add" required:"false" cty:"cap_add" hcl:"cap_add"`
	CapDrop                   []string          `mapstructure:"cap_drop" required:"false" cty:"cap_drop" hcl:"cap_drop"`
	ExecUser                  *string           `mapstructure:"exec_user" required:"false" cty:"exec_user" hcl:"exec_user"`
	ExportPath                *string           `mapstructure:"export_path" required:"true" cty:"export_path" hcl:"export_path"`
	Image                     *string           `mapstructure:"image" required:"true" cty:"image" hcl:"image"`
	Message                   *string           `mapstructure:"message" required:"true" cty:"message" hcl:"message"`
	Privileged                *bool             `mapstructure:"privileged" required:"false" cty:"privileged" hcl:"privileged"`
	Pty                       *bool             `cty:"pty" hcl:"pty"`
	Pull                      *bool             `mapstructure:"pull" required:"false" cty:"pull" hcl:"pull"`
	RunCommand                []string          `mapstructure:"run_command" required:"false" cty:"run_command" hcl:"run_command"`
	TmpFs                     []string          `mapstructure:"tmpfs" required:"false" cty:"tmpfs" hcl:"tmpfs"`
	Volumes                   map[string]string `mapstructure:"volumes" required:"false" cty:"volumes" hcl:"volumes"`
	FixUploadOwner            *bool             `mapstructure:"fix_upload_owner" required:"false" cty:"fix_upload_owner" hcl:"fix_upload_owner"`
	WindowsContainer          *bool             `mapstructure:"windows_container" required:"false" cty:"windows_container" hcl:"windows_container"`
	Login                     *bool             `mapstructure:"login" required:"false" cty:"login" hcl:"login"`
	LoginPassword             *string           `mapstructure:"login_password" required:"false" cty:"login_password" hcl:"login_password"`
	LoginServer               *string           `mapstructure:"login_server" required:"false" cty:"login_server" hcl:"login_server"`
	LoginUsername             *string           `mapstructure:"login_username" required:"false" cty:"login_username" hcl:"login_username"`
	EcrLogin                  *bool             `mapstructure:"ecr_login" required:"false" cty:"ecr_login" hcl:"ecr_login"`
	AccessKey                 *string           `mapstructure:"aws_access_key" required:"false" cty:"aws_access_key" hcl:"aws_access_key"`
	SecretKey                 *string           `mapstructure:"aws_secret_key" required:"false" cty:"aws_secret_key" hcl:"aws_secret_key"`
	Token                     *string           `mapstructure:"aws_token" required:"false" cty:"aws_token" hcl:"aws_token"`
	Profile                   *string           `mapstructure:"aws_profile" required:"false" cty:"aws_profile" hcl:"aws_profile"`
}

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

func (*FlatConfig) HCL2Spec added in v1.4.5

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

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

type ImportArtifact added in v0.5.2

type ImportArtifact struct {
	BuilderIdValue string
	Driver         Driver
	IdValue        string

	// StateData should store data such as GeneratedData
	// to be shared with post-processors
	StateData map[string]interface{}
}

ImportArtifact is an Artifact implementation for when a container is exported from docker into a single flat file.

func (*ImportArtifact) BuilderId added in v0.5.2

func (a *ImportArtifact) BuilderId() string

func (*ImportArtifact) Destroy added in v0.5.2

func (a *ImportArtifact) Destroy() error

func (*ImportArtifact) Files added in v0.5.2

func (*ImportArtifact) Files() []string

func (*ImportArtifact) Id added in v0.5.2

func (a *ImportArtifact) Id() string

func (*ImportArtifact) State added in v0.7.2

func (a *ImportArtifact) State(name string) interface{}

func (*ImportArtifact) String added in v0.5.2

func (a *ImportArtifact) String() string

type MockDriver

type MockDriver struct {
	CommitCalled      bool
	CommitContainerId string
	CommitImageId     string
	CommitErr         error

	DeleteImageCalled bool
	DeleteImageId     string
	DeleteImageErr    error

	ImportCalled bool
	ImportPath   string
	ImportRepo   string
	ImportId     string
	ImportErr    error

	IPAddressCalled bool
	IPAddressID     string
	IPAddressResult string
	IPAddressErr    error

	Sha256Called bool
	Sha256Id     string
	Sha256Result string
	Sha256Err    error

	KillCalled bool
	KillID     string
	KillError  error

	LoginCalled   bool
	LoginUsername string
	LoginPassword string
	LoginRepo     string
	LoginErr      error

	LogoutCalled bool
	LogoutRepo   string
	LogoutErr    error

	PushCalled bool
	PushName   string
	PushErr    error

	SaveImageCalled bool
	SaveImageId     string
	SaveImageReader io.Reader
	SaveImageError  error

	TagImageCalled  int
	TagImageImageId string
	TagImageRepo    []string
	TagImageForce   bool
	TagImageErr     error

	ExportReader io.Reader
	ExportError  error
	PullError    error
	StartID      string
	StartError   error
	StopError    error
	VerifyError  error

	ExportCalled bool
	ExportID     string
	PullCalled   bool
	PullImage    string
	StartCalled  bool
	StartConfig  *ContainerConfig
	StopCalled   bool
	StopID       string
	VerifyCalled bool

	VersionCalled  bool
	VersionVersion string
}

MockDriver is a driver implementation that can be used for tests.

func (*MockDriver) Commit added in v0.7.0

func (d *MockDriver) Commit(id string, author string, changes []string, message string) (string, error)

func (*MockDriver) DeleteImage added in v0.5.2

func (d *MockDriver) DeleteImage(id string) error

func (*MockDriver) Export

func (d *MockDriver) Export(id string, dst io.Writer) error

func (*MockDriver) IPAddress added in v0.8.0

func (d *MockDriver) IPAddress(id string) (string, error)

func (*MockDriver) Import added in v0.5.2

func (d *MockDriver) Import(path string, changes []string, repo string) (string, error)

func (*MockDriver) KillContainer added in v1.4.0

func (d *MockDriver) KillContainer(id string) error

func (*MockDriver) Login added in v0.7.0

func (d *MockDriver) Login(r, u, p string) error

func (*MockDriver) Logout added in v0.7.0

func (d *MockDriver) Logout(r string) error

func (*MockDriver) Pull

func (d *MockDriver) Pull(image string) error

func (*MockDriver) Push added in v0.5.2

func (d *MockDriver) Push(name string) error

func (*MockDriver) SaveImage added in v0.7.0

func (d *MockDriver) SaveImage(id string, dst io.Writer) error

func (*MockDriver) Sha256 added in v1.6.3

func (d *MockDriver) Sha256(id string) (string, error)

func (*MockDriver) StartContainer

func (d *MockDriver) StartContainer(config *ContainerConfig) (string, error)

func (*MockDriver) StopContainer

func (d *MockDriver) StopContainer(id string) error

func (*MockDriver) TagImage added in v0.7.0

func (d *MockDriver) TagImage(id string, repo string, force bool) error

func (*MockDriver) Verify

func (d *MockDriver) Verify() error

func (*MockDriver) Version added in v0.8.0

func (d *MockDriver) Version() (*version.Version, error)

type StepCommit added in v0.7.0

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

StepCommit commits the container to a image.

func (*StepCommit) Cleanup added in v0.7.0

func (s *StepCommit) Cleanup(state multistep.StateBag)

func (*StepCommit) Run added in v0.7.0

type StepConnectDocker added in v0.8.0

type StepConnectDocker struct{}

func (*StepConnectDocker) Cleanup added in v0.8.0

func (s *StepConnectDocker) Cleanup(state multistep.StateBag)

func (*StepConnectDocker) Run added in v0.8.0

type StepExport

type StepExport struct{}

StepExport exports the container to a flat tar file.

func (*StepExport) Cleanup

func (s *StepExport) Cleanup(state multistep.StateBag)

func (*StepExport) Run

type StepPull

type StepPull struct{}

func (*StepPull) Cleanup

func (s *StepPull) Cleanup(state multistep.StateBag)

func (*StepPull) Run

type StepRun

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

func (*StepRun) Cleanup

func (s *StepRun) Cleanup(state multistep.StateBag)

func (*StepRun) Run

type StepSetGeneratedData added in v1.6.3

type StepSetGeneratedData struct {
	GeneratedData *packerbuilderdata.GeneratedData
}

func (*StepSetGeneratedData) Cleanup added in v1.6.3

func (s *StepSetGeneratedData) Cleanup(_ multistep.StateBag)

func (*StepSetGeneratedData) Run added in v1.6.3

type StepTempDir

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

StepTempDir creates a temporary directory that we use in order to share data with the docker container over the communicator.

func (*StepTempDir) Cleanup

func (s *StepTempDir) Cleanup(state multistep.StateBag)

func (*StepTempDir) Run

type WindowsContainerCommunicator added in v1.4.0

type WindowsContainerCommunicator struct {
	Communicator
}

func (*WindowsContainerCommunicator) Download added in v1.4.0

func (c *WindowsContainerCommunicator) Download(src string, dst io.Writer) error

Download pulls a file out of a container using `docker cp`. We have a source path and want to write to an io.Writer

func (*WindowsContainerCommunicator) Upload added in v1.4.0

func (c *WindowsContainerCommunicator) Upload(dst string, src io.Reader, fi *os.FileInfo) error

Upload uses docker exec to copy the file from the host to the container

func (*WindowsContainerCommunicator) UploadDir added in v1.4.0

func (c *WindowsContainerCommunicator) UploadDir(dst string, src string, exclude []string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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