container

package
v18.9.11+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string

Create creates a container with the specified options nolint: golint

func IsInState

func IsInState(ctx context.Context, client client.APIClient, containerID string, state ...string) func(log poll.LogT) poll.Result

IsInState verifies the container is in one of the specified state, e.g., "running", "exited", etc.

func IsStopped

func IsStopped(ctx context.Context, client client.APIClient, containerID string) func(log poll.LogT) poll.Result

IsStopped verifies the container is in stopped state.

func Run

func Run(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string

Run creates and start a container with the specified options nolint: golint

func WithAutoRemove

func WithAutoRemove(c *TestContainerConfig)

WithAutoRemove sets the container to be removed on exit

func WithBind

func WithBind(src, target string) func(*TestContainerConfig)

WithBind sets the bind mount of the container

func WithCmd

func WithCmd(cmds ...string) func(*TestContainerConfig)

WithCmd sets the comannds of the container

func WithExposedPorts

func WithExposedPorts(ports ...string) func(*TestContainerConfig)

WithExposedPorts sets the exposed ports of the container

func WithIPv4

func WithIPv4(network, ip string) func(*TestContainerConfig)

WithIPv4 sets the specified ip for the specified network of the container

func WithIPv6

func WithIPv6(network, ip string) func(*TestContainerConfig)

WithIPv6 sets the specified ip6 for the specified network of the container

func WithImage

func WithImage(image string) func(*TestContainerConfig)

WithImage sets the image of the container

func WithLinks(links ...string) func(*TestContainerConfig)

WithLinks sets the links of the container

func WithLogDriver

func WithLogDriver(driver string) func(*TestContainerConfig)

WithLogDriver sets the log driver to use for the container

func WithName

func WithName(name string) func(*TestContainerConfig)

WithName sets the name of the container

func WithNetworkMode

func WithNetworkMode(mode string) func(*TestContainerConfig)

WithNetworkMode sets the network mode of the container

func WithTty

func WithTty(tty bool) func(*TestContainerConfig)

WithTty sets the TTY mode of the container

func WithVolume

func WithVolume(name string) func(*TestContainerConfig)

WithVolume sets the volume of the container

func WithWorkingDir

func WithWorkingDir(dir string) func(*TestContainerConfig)

WithWorkingDir sets the working dir of the container

Types

type ExecResult

type ExecResult struct {
	ExitCode int
	// contains filtered or unexported fields
}

ExecResult represents a result returned from Exec()

func Exec

func Exec(ctx context.Context, cli client.APIClient, id string, cmd []string) (ExecResult, error)

Exec executes a command inside a container, returning the result containing stdout, stderr, and exit code. Note:

  • this is a synchronous operation;
  • cmd stdin is closed.

func (*ExecResult) Combined

func (res *ExecResult) Combined() string

Combined returns combined stdout and stderr output of a command run by Exec()

func (*ExecResult) Stderr

func (res *ExecResult) Stderr() string

Stderr returns stderr output of a command run by Exec()

func (*ExecResult) Stdout

func (res *ExecResult) Stdout() string

Stdout returns stdout output of a command run by Exec()

type TestContainerConfig

type TestContainerConfig struct {
	Name             string
	Config           *container.Config
	HostConfig       *container.HostConfig
	NetworkingConfig *network.NetworkingConfig
}

TestContainerConfig holds container configuration struct that are used in api calls.

Jump to

Keyboard shortcuts

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