Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Build ¶
type Build struct { // Dockerfile is the path to the dockerfile. Dockerfile string // Context is the directory to use. Context string }
Build is a set of instructions for building a container image. All paths are relative to the working directory of the test.
type Composer ¶
type Composer struct {
// contains filtered or unexported fields
}
Composer is the interface to launching manifests. This is returned from New()
func New ¶
New constructs a new Composer from a Manifest. A network name must also be provided; it will be created and cleaned up when Run and Teardown are called.
func (*Composer) GetNetworkID ¶ added in v0.2.0
GetNetworkID returns the network identifier of the created network from Launch. If this composition is not launched yet, it will return an empty string.
func (*Composer) HandleSignals ¶
HandleSignals handles SIGINT and SIGTERM to ensure that containers get cleaned up. It is expected that no other signal handler will be installed afterwards. If the forward argument is true, it will forward the signal back to its own process after deregistering itself as the signal handler, allowing your test suite to exit gracefully. Set it to false to stay out of your way.
func (*Composer) Launch ¶
Launch launches the manifest. On error containers are automatically cleaned up.
type Container ¶
type Container struct { // Name is required; it is the independent name of the container. It maps // directly to the name on the docker installation, so be mindful of // collisions. Name string // Env is the array of key=value string pairs in `man 7 environ` fashion. Env []string // PostCommands is a series of argvs for running commands after the container // is booted, and after the bootwait is consumed. PostCommands [][]string // Command is the command to run as the booted container. Command []string // Entrypoint maps directly to Docker's entrypoint. Entrypoint []string // Image is the docker image; it uses repository syntax, and will attempt to // pull it unless LocalImage is set true. Image string // BindMounts is a map of absolute path -> absolute path for host -> // container bind mounting. BindMounts map[string]string // LocalImage indicates this image is not to be pulled. LocalImage bool // BootWait is how long to wait after booting the container before moving // forward with PostCommands and other orchestration. BootWait time.Duration // AliveFunc is a locally run golang function for testing the availability of // the container. The client is passed in as well as the container ID to // assist with this process. AliveFunc func(context.Context, *dc.Client, string) error // PortForwards are a simple mapping of host -> container port mappings that // forward the port on 0.0.0.0 automatically. PortForwards map[int]int // WaitForExit runs this container until it exits. Helpful for scenarios where a container operates // on another (example: initialize database data), but does not expose a service. WaitForExit bool // IPv4 attempts to set IPv4 addresses for the container. IPv4 string // IPv6 attempts to set IPv6 addresses for the container. IPv6 string // ExtraHosts is a map of IP -> names in /etc/hosts. It does this by // constructing an /etc/hosts file and bind mounting it in. ExtraHosts map[string][]string // contains filtered or unexported fields }
Container is the description of a single container. Usually several of these are composed in a Manifest and sent to the New() call. Please see the fields below for more information.
type Manifest ¶
type Manifest []*Container
Manifest is the containers to run, in order. Passed to New().
type Options ¶ added in v0.2.0
type Options map[string]interface{}
Options is a generic type for options.
func WithExistingNetwork ¶ added in v0.2.0
WithExistingNetwork uses an existing network by ID (*not* name, since network names are not unique!)
func WithLogWriter ¶ added in v0.3.0
WithLogWriter routes all logging output to the specified writer, or to none if nil is pecified
func WithNewNetwork ¶ added in v0.2.0
WithNewNetwork creates a network for use with the manifest.
func WithNewNetworkAndSubnet ¶ added in v0.3.3
WithNewNetwork creates a network for use with the manifest.