runner

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHostAddress = "127.0.0.1"
)

Variables

View Source
var (
	RegistryExtensionOptions = []string{".com", ".io", ".org", ".net"}
	DefaultContainerName     = uuid.New().String()
	ErrNoContainerId         = errors.New("container id does not exist")
)

Functions

This section is empty.

Types

type ContainerRunner

type ContainerRunner struct {
	// contains filtered or unexported fields
}

ContainerRunner implements ContainerRunnerInterface and can construct a custom container with image and port options

func NewContainerRunner

func NewContainerRunner() *ContainerRunner

NewContainerRunner builds a runner that can be used to start and stop containers using the locally installed docker engine

func (*ContainerRunner) Start

func (e *ContainerRunner) Start(ctx context.Context) error

Start starts the container with the provided options

func (*ContainerRunner) Stop

func (e *ContainerRunner) Stop(ctx context.Context) error

Stop stops the container that was started using Start

func (*ContainerRunner) WithEnvironmentVariable

func (r *ContainerRunner) WithEnvironmentVariable(key, val string) *ContainerRunner

func (*ContainerRunner) WithImage

func (r *ContainerRunner) WithImage(image string) *ContainerRunner

WithImage sets the container image that should be used. It defaults to the docker registry.

func (*ContainerRunner) WithName

func (r *ContainerRunner) WithName(name string) *ContainerRunner

WithName sets the name of the container. Note that running Start with a container name that already exists will cause Start to fail.

func (*ContainerRunner) WithOptions

func (r *ContainerRunner) WithOptions(opts *ContainerRunnerOpts) *ContainerRunner

WithOptions sets the options that the runner should run with=

func (*ContainerRunner) WithPorts

func (r *ContainerRunner) WithPorts(ports ...int) *ContainerRunner

WithPorts sets the ports that should be exposed and forwarded from the container

type ContainerRunnerInterface

type ContainerRunnerInterface interface {
	Start(context.Context) error
	Stop(context.Context) error
}

ContainerRunnerInterface describes something that can start and stop containers

type ContainerRunnerOpts

type ContainerRunnerOpts struct {
	// If RemoveOnFinalization is enabled, the container will be removed
	// after it is stopped.
	RemoveOnFinalization bool
}

ContainerRunnerOpts allows customization of the runner's behavior

Jump to

Keyboard shortcuts

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