dockertest: github.com/ory/dockertest Index | Files | Directories

package dockertest

import "github.com/ory/dockertest"

Index

Package Files

dockertest.go

type BuildOptions Uses

type BuildOptions struct {
    Dockerfile string
    ContextDir string
}

BuildOptions is used to pass in optional parameters when building a container

type Pool Uses

type Pool struct {
    Client  *dc.Client
    MaxWait time.Duration
}

Pool represents a connection to the docker API and is used to create and remove docker images.

func NewPool Uses

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

NewPool creates a new pool. You can pass an empty string to use the default, which is taken from the environment variable DOCKER_HOST and DOCKER_URL, or from docker-machine if the environment variable DOCKER_MACHINE_NAME is set, or if neither is defined a sensible default for the operating system you are on. TLS pools are automatically configured if the DOCKER_CERT_PATH environment variable exists.

func NewTLSPool Uses

func NewTLSPool(endpoint, certpath string) (*Pool, error)

NewTLSPool creates a new pool given an endpoint and the certificate path. This is required for endpoints that require TLS communication.

func (*Pool) BuildAndRun Uses

func (d *Pool) BuildAndRun(name, dockerfilePath string, env []string) (*Resource, error)

BuildAndRun builds and starts a docker container

func (*Pool) BuildAndRunWithBuildOptions Uses

func (d *Pool) BuildAndRunWithBuildOptions(buildOpts *BuildOptions, runOpts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)

BuildAndRunWithBuildOptions builds and starts a docker container. Optional modifier functions can be passed in order to change the hostconfig values not covered in RunOptions

func (*Pool) BuildAndRunWithOptions Uses

func (d *Pool) BuildAndRunWithOptions(dockerfilePath string, opts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)

BuildAndRunWithOptions builds and starts a docker container. Optional modifier functions can be passed in order to change the hostconfig values not covered in RunOptions

func (*Pool) ContainerByName Uses

func (d *Pool) ContainerByName(containerName string) (*Resource, bool)

ContainerByName finds a container with the given name and returns it if present

func (*Pool) Purge Uses

func (d *Pool) Purge(r *Resource) error

Purge removes a container and linked volumes from docker.

func (*Pool) RemoveContainerByName Uses

func (d *Pool) RemoveContainerByName(containerName string) error

RemoveContainerByName find a container with the given name and removes it if present

func (*Pool) Retry Uses

func (d *Pool) Retry(op func() error) error

Retry is an exponential backoff retry helper. You can use it to wait for e.g. mysql to boot up.

func (*Pool) Run Uses

func (d *Pool) Run(repository, tag string, env []string) (*Resource, error)

Run starts a docker container.

pool.Run("mysql", "5.3", []string{"FOO=BAR", "BAR=BAZ"})

func (*Pool) RunWithOptions Uses

func (d *Pool) RunWithOptions(opts *RunOptions, hcOpts ...func(*dc.HostConfig)) (*Resource, error)

RunWithOptions starts a docker container. Optional modifier functions can be passed in order to change the hostconfig values not covered in RunOptions

 pool.RunWithOptions(&RunOptions{Repository: "mongo", Cmd: []string{"mongod", "--smallfiles"}})
 pool.RunWithOptions(&RunOptions{Repository: "mongo", Cmd: []string{"mongod", "--smallfiles"}}, func(hostConfig *dc.HostConfig) {
			hostConfig.ShmSize = shmemsize
		})

type Resource Uses

type Resource struct {
    Container *dc.Container
    // contains filtered or unexported fields
}

Resource represents a docker container.

func (*Resource) Close Uses

func (r *Resource) Close() error

Close removes a container and linked volumes from docker by calling pool.Purge.

func (*Resource) Expire Uses

func (r *Resource) Expire(seconds uint) error

Expire sets a resource's associated container to terminate after a period has passed

func (*Resource) GetBoundIP Uses

func (r *Resource) GetBoundIP(id string) string

GetBoundIP returns a resource's published IP address.

func (*Resource) GetHostPort Uses

func (r *Resource) GetHostPort(portID string) string

GetHostPort returns a resource's published port with an address.

func (*Resource) GetPort Uses

func (r *Resource) GetPort(id string) string

GetPort returns a resource's published port. You can use it to connect to the service via localhost, e.g. tcp://localhost:1231/

type RunOptions Uses

type RunOptions struct {
    Hostname     string
    Name         string
    Repository   string
    Tag          string
    Env          []string
    Entrypoint   []string
    Cmd          []string
    Mounts       []string
    Links        []string
    ExposedPorts []string
    ExtraHosts   []string
    CapAdd       []string
    SecurityOpt  []string
    DNS          []string
    WorkingDir   string
    NetworkID    string
    Labels       map[string]string
    Auth         dc.AuthConfiguration
    PortBindings map[dc.Port][]dc.PortBinding
    Privileged   bool
}

RunOptions is used to pass in optional parameters when running a container.

Directories

PathSynopsis
dockerPackage docker provides a client for the Docker remote API.
docker/opts

Package dockertest imports 12 packages (graph) and is imported by 56 packages. Updated 2019-10-31. Refresh now. Tools for package owners.