dockertest

package
v0.0.0-...-4756806 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package dockertest is inspired by github.com/ory-am/dockertest@v3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPort

func GetPort(container *dc.Container, id string) string

GetPort returns a bound host port in the container. `id` is an id of the exposed port in the container.

func GetServiceAddr

func GetServiceAddr(container *dc.Container, portID string) string

GetServiceAddr returns a local host with port for the container.

func Retry

func Retry(maxWait time.Duration, op func() error) error

Retry runs `op` every x seconds using exponential back-off strategy.

Types

type ContainerList

type ContainerList []*dc.Container

ContainerList is a list of `*dc.Container`.

func (ContainerList) Remove

func (c ContainerList) Remove(search *dc.Container) ContainerList

Remove removes an item from `ContainerList`.

type Env

type Env []string

Env is a list of environment variables in format NAME=VALUE.

type Pool

type Pool struct {
	Client *dc.Client

	Containers ContainerList
	Networks   []*dc.Network
	// contains filtered or unexported fields
}

Pool manages created docker artifacts.

func NewPool

func NewPool(endpoint string) (*Pool, error)

NewPool creates a new client.

func (*Pool) CreateNetwork

func (p *Pool) CreateNetwork(name string) (*dc.Network, error)

CreateNetwork creates a new network in the docker.

func (*Pool) GetContainer

func (p *Pool) GetContainer(name string) (*dc.Container, bool)

GetContainer returns container struct by name. Remember to preceed name with `/`. This is how go-dockerclient works.

func (*Pool) PullImage

func (p *Pool) PullImage(image string) error

PullImage pulls image from the Docker Hub.

func (*Pool) PurgeAll

func (p *Pool) PurgeAll() error

PurgeAll removes every docker resource that was created in a pool.

func (*Pool) PurgeContainer

func (p *Pool) PurgeContainer(container *dc.Container) error

PurgeContainer stops and removes container from the docker.

func (*Pool) PurgeContainers

func (p *Pool) PurgeContainers(containers ContainerList) error

PurgeContainers removes containers passed as in the argument.

func (*Pool) PurgeNetwork

func (p *Pool) PurgeNetwork(net *dc.Network) error

PurgeNetwork removes network from the container.

func (*Pool) RunContainer

func (p *Pool) RunContainer(
	image string, env Env, pullImage bool,
) (*dc.Container, error)

RunContainer runs a container with a given image and env vars. It's a short version of `RunContainerWithOpts()`.

func (*Pool) RunContainerWithOpts

func (p *Pool) RunContainerWithOpts(
	opts dc.CreateContainerOptions,
) (*dc.Container, error)

RunContainerWithOpts runs a container based on given options.

func (*Pool) RunMultipleContainers

func (p *Pool) RunMultipleContainers(
	opts []dc.CreateContainerOptions,
) (ContainerList, error)

RunMultipleContainers spawns multiple containers asynchronously.

Jump to

Keyboard shortcuts

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