Documentation ¶
Index ¶
- func TruncateID(id string) string
- type Callback
- type DockerComponent
- type DockerEnvironment
- func (r *DockerEnvironment) Close()
- func (r *DockerEnvironment) Destroy(names ...string) error
- func (r *DockerEnvironment) Host() string
- func (r *DockerEnvironment) Port(componentName string, portName string) (int, error)
- func (r *DockerEnvironment) Resolve(template string) (string, error)
- func (r *DockerEnvironment) Shutdown(beforeShutdown ...func())
- func (r *DockerEnvironment) Start(names ...string) error
- func (r *DockerEnvironment) StartParallel(names ...string) error
- func (r *DockerEnvironment) Stop(names ...string) error
- func (r *DockerEnvironment) WithShutdown(beforeShutdown ...func()) chan struct{}
- type Port
- type ValueResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TruncateID ¶
TruncateID returns a shorthand version of a string identifier.
Types ¶
type Callback ¶
type Callback interface { // Callback method invoked with the current component name and value resolver Call(componentName string, resolver ValueResolver) error }
Callback provides a way for the callee to invoke the code inside the caller
type DockerComponent ¶
type DockerComponent struct { // Name of the docker component Name string // Docker image name Image string // Pull an image from a registry ForcePull bool // After destroy remove image from the docker host RemoveImageAfterDestroy bool // List of exposed ports ExposedPorts []Port // Container environment variables EnvironmentVariables map[string]string // Command to run when starting the container Cmd []string // List of volume bindings for this container Binds []string // DNS server to lookup DNSServer string // Follow container log output FollowLogs bool // Callback invoked after start container command was invoked. AfterStart Callback }
DockerComponent holds parameters defining docker component.
type DockerEnvironment ¶
type DockerEnvironment struct {
// contains filtered or unexported fields
}
DockerEnvironment holds defined docker components
func NewDockerEnvironment ¶
func NewDockerEnvironment(components ...DockerComponent) (*DockerEnvironment, error)
NewDockerEnvironment creates a new docker test environment
func (*DockerEnvironment) Close ¶
func (r *DockerEnvironment) Close()
Close closes docker environment lifecycle handle
func (*DockerEnvironment) Destroy ¶
func (r *DockerEnvironment) Destroy(names ...string) error
Destroy destroys docker components by destroying the containers
func (*DockerEnvironment) Host ¶
func (r *DockerEnvironment) Host() string
Host provides external IP of docker containers
func (*DockerEnvironment) Port ¶
func (r *DockerEnvironment) Port(componentName string, portName string) (int, error)
Port provides port number for a given component and named port
func (*DockerEnvironment) Resolve ¶
func (r *DockerEnvironment) Resolve(template string) (string, error)
Resolve executes the template applying the environment context as data object
func (*DockerEnvironment) Shutdown ¶
func (r *DockerEnvironment) Shutdown(beforeShutdown ...func())
Shutdown stops and destroys environment containers and closes life cycle handler
func (*DockerEnvironment) Start ¶
func (r *DockerEnvironment) Start(names ...string) error
Start starts docker components by starting docker containers
func (*DockerEnvironment) StartParallel ¶
func (r *DockerEnvironment) StartParallel(names ...string) error
StartParallel starts docker components in parallel
func (*DockerEnvironment) Stop ¶
func (r *DockerEnvironment) Stop(names ...string) error
Stop stops docker components
func (*DockerEnvironment) WithShutdown ¶
func (r *DockerEnvironment) WithShutdown(beforeShutdown ...func()) chan struct{}
WithShutdown registers callback invoked after SIGINT or SIGTERM were received
type Port ¶
type Port struct { // Optional port name. If not specified, the lower-cased component name is used. // Each named port in a component must have a unique name. Name string // Container port mapped to the host port ContainerPort int // Number of port to expose on the host. If not specified, ephemeral port is used. HostPort int }
Port holds definition of a port mapping
type ValueResolver ¶
type ValueResolver interface { // Resolve applies a parsed template to the docker environment context Resolve(template string) (string, error) // Hosts provides external IP of the container Host() string // Port provides a host port for a given component and named port Port(componentName string, portName string) (int, error) }
ValueResolver allows resolution of container parameters