docker

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MPL-2.0 Imports: 38 Imported by: 1

Documentation

Index

Constants

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

EcrPublicApiRegion : The Amazon ECR Public registry requires authentication in the us-east-1 Region, so you need to specify --region us-east-1 each time you authenticate

View Source
const EcrPublicHost = "public.ecr.aws/"

Variables

This section is empty.

Functions

func ConfigTmpDir

func ConfigTmpDir() (string, error)

ConfigTmpDir returns the configuration tmp directory for Docker

Types

type AwsAccessConfig

type AwsAccessConfig struct {
	// The AWS access key used to communicate with AWS.
	AccessKey string `mapstructure:"aws_access_key" required:"false"`
	// The AWS secret key used to communicate with AWS.
	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.
	Profile string `mapstructure:"aws_profile" required:"false"`
	// The flag to identify whether to push docker image to Public _or_ Private
	// ECR. If the user sets this to `true` from the config, we will forcefully
	// try to push to Public ECR otherwise set this from code based on the
	// given LoginServer value.
	PublicEcrGallery bool `mapstructure:"aws_force_use_public_ecr" required:"false"`
}

func (*AwsAccessConfig) EcrGetLogin

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

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

func (*AwsAccessConfig) GetCredentials

func (c *AwsAccessConfig) GetCredentials(config *aws.Config) (*awsCredentials.Credentials, error)

GetCredentials gets credentials from the environment, shared credentials, the session (which may include a credential process), or ECS/EC2 metadata endpoints. GetCredentials also validates the credentials and the ability to assume a role or will return an error if unsuccessful.

func (*AwsAccessConfig) PublicEcrLogin added in v1.0.7

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

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

func (*AwsAccessConfig) SetPublicEcrGallery added in v1.0.8

func (c *AwsAccessConfig) SetPublicEcrGallery(ecrUrl string)

SetPublicEcrGallery sets PublicEcrGallery flag to `true` if the user given LoginServer is the ECR Public URL

type Builder

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

func (*Builder) ConfigSpec

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

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.
	// Default `false`. If `commit` is `false`, then either `discard` must be
	// set to `true` or an `export_path` must be provided.
	Commit bool `mapstructure:"commit" required:"true"`
	// The directory inside container to mount temp directory from host server
	// for work [file provisioner](/packer/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](/packer/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.
	// Any value format that you can provide to `docker pull` is valid.
	// Example: `ubuntu` or `ubuntu:xenial`. If you only provide the repo, Docker
	// will pull the latest image, so setting `ubuntu` is the same as setting
	// `ubuntu:latest`. You can also set a distribution digest. For example,
	// ubuntu@sha256:a0d9e826ab87bd665cfc640598a871b748b4b70a01a4f3d174d4fb02adad07a9
	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
	// Set the container runtime. A runtime different from the one installed
	// by default with Docker (`runc`) must be installed and configured.
	// The possible values are (non-exhaustive list):
	// `runsc` for [gVisor](https://gvisor.dev/),
	// `kata-runtime` for [Kata Containers](https://katacontainers.io/),
	// `sysbox-runc` for [Nestybox](https://www.nestybox.com/).
	Runtime string `mapstructure:"runtime" required:"false"`
	// 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"`
	// Set platform if server is multi-platform capable
	Platform string `mapstructure:"platform" 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

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

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
	Runtime    string
	Platform   string
}

ContainerConfig is the configuration used to start a container.

type DockerDriver

type DockerDriver struct {
	Ui  packersdk.Ui
	Ctx *interpolate.Context

	// The directory Docker should use to store its client configuration.
	// Provides an isolated client configuration to each Docker operation to
	// prevent race conditions.
	ConfigDir string
	// contains filtered or unexported fields
}

func (*DockerDriver) Cmd added in v1.0.9

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

func (*DockerDriver) Commit

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

func (*DockerDriver) DeleteImage

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

func (*DockerDriver) Digest

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

Digest retrieves the digest of the image using Docker inspect. Format for the digest is: <repo>@sha256:<shasum> For example: ubuntu@sha256:454054f5bbd571b088db25b662099c6c7b3f0cb78536a2077d54adc48f00cd68 This can be considered a source of truth for pointing to a specific image at a specific point in time.

func (*DockerDriver) Entrypoint added in v1.0.9

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

func (*DockerDriver) Export

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

func (*DockerDriver) IPAddress

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

func (*DockerDriver) Import

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

func (*DockerDriver) KillContainer

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

func (*DockerDriver) Login

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

func (*DockerDriver) Logout

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

func (*DockerDriver) Pull

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

func (*DockerDriver) Push

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

func (*DockerDriver) SaveImage

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

func (*DockerDriver) Sha256

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

Sha256 retrieves the image Id using Docker inspect.

func (*DockerDriver) StartContainer

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

func (*DockerDriver) StopContainer

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

func (*DockerDriver) TagImage

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

func (*DockerDriver) Verify

func (d *DockerDriver) Verify() error

func (*DockerDriver) Version

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, platform 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)

	// Retrieve the repo digest of the image.
	Digest(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, platform string) error

	// Push pushes an image to a Docker index/registry.
	Push(name string, platform 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 ECRType added in v1.0.7

type ECRType string

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

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

func (*ExportArtifact) String

func (a *ExportArtifact) String() string

type FlatConfig

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"`
	Runtime                   *string           `mapstructure:"runtime" required:"false" cty:"runtime" hcl:"runtime"`
	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"`
	Platform                  *string           `mapstructure:"platform" required:"false" cty:"platform" hcl:"platform"`
	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"`
	PublicEcrGallery          *bool             `mapstructure:"aws_force_use_public_ecr" required:"false" cty:"aws_force_use_public_ecr" hcl:"aws_force_use_public_ecr"`
}

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

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

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

func (a *ImportArtifact) BuilderId() string

func (*ImportArtifact) Destroy

func (a *ImportArtifact) Destroy() error

func (*ImportArtifact) Files

func (*ImportArtifact) Files() []string

func (*ImportArtifact) Id

func (a *ImportArtifact) Id() string

func (*ImportArtifact) State

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

func (*ImportArtifact) String

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
	ImportPlatform string
	ImportErr      error

	IPAddressCalled bool
	IPAddressID     string
	IPAddressResult string
	IPAddressErr    error

	Sha256Called bool
	Sha256Id     string
	Sha256Result string
	Sha256Err    error

	DigestCalled bool
	DigestId     string
	DigestResult string
	DigestErr    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
	PushPlatform 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
	PullPlatform 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

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

func (*MockDriver) DeleteImage

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

func (*MockDriver) Digest

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

func (*MockDriver) Export

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

func (*MockDriver) IPAddress

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

func (*MockDriver) Import

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

func (*MockDriver) KillContainer

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

func (*MockDriver) Login

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

func (*MockDriver) Logout

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

func (*MockDriver) Pull

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

func (*MockDriver) Push

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

func (*MockDriver) SaveImage

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

func (*MockDriver) Sha256

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

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

func (*MockDriver) Verify

func (d *MockDriver) Verify() error

func (*MockDriver) Version

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

type StepCommit

type StepCommit struct {
	GeneratedData *packerbuilderdata.GeneratedData
	// contains filtered or unexported fields
}

StepCommit commits the container to a image.

func (*StepCommit) Cleanup

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

func (*StepCommit) Run

type StepConnectDocker

type StepConnectDocker struct{}

func (*StepConnectDocker) Cleanup

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

func (*StepConnectDocker) Run

type StepDefaultGeneratedData

type StepDefaultGeneratedData struct {
	GeneratedData *packerbuilderdata.GeneratedData
}

StepDefaultGeneratedData Adds the placeholders for special generated values that Docker is expected to return. This makes sure that the accessor has _something_ to read in the provisioners, regardless of whether the value. was created. The true values are put in generated data in the steps where the values are actually created (step pull, and step commit)

func (*StepDefaultGeneratedData) Cleanup

func (*StepDefaultGeneratedData) Run

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 {
	GeneratedData *packerbuilderdata.GeneratedData
}

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 StepSetDefaults added in v1.0.9

type StepSetDefaults struct{}

func (*StepSetDefaults) Cleanup added in v1.0.9

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

func (*StepSetDefaults) Run added in v1.0.9

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

type WindowsContainerCommunicator struct {
	Communicator
}

func (*WindowsContainerCommunicator) Download

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

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

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

Jump to

Keyboard shortcuts

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