docker

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostAddr

func HostAddr(port int) string

func HostIP

func HostIP() (string, error)

HostIP returns host ip that allows to reach host directly inside docker container.

Types

type BuildImageConfig

type BuildImageConfig struct {
	Path string
	Tag  string
}

type Container

type Container interface {
	Start(context.Context) error
	Stop(context.Context) error
	Logs(context.Context) (io.Reader, error)
	GetState(context.Context) (*types.ContainerState, error)
	Name() string
}

type ContainerConfig

type ContainerConfig struct {
	Image           string
	Env             []string
	Name            string
	PortMap         PortMap
	PublishAllPorts bool
	EntryPoint      []string
	Cmd             []string
	Hostname        string
	CapAdd          []string
	Labels          map[string]string
	Mounts          Mounts
	NetworkName     string
	Healtcheck      *HealthCheckConfig
	AttachIfExist   bool
	AutoRemove      bool
	Privileged      bool
	WaitPolicy      WaitPolicy
}

type ContainerPort

type ContainerPort int

type ContainerType

type ContainerType struct {
	ID         string
	WaitPolicy WaitPolicy
	// contains filtered or unexported fields
}

func (*ContainerType) GetState

func (c *ContainerType) GetState(ctx context.Context) (*types.ContainerState, error)

func (*ContainerType) GetStateV2

func (c *ContainerType) GetStateV2(ctx context.Context) (*types.ContainerState, error)

func (*ContainerType) Logs

func (c *ContainerType) Logs(ctx context.Context) (io.Reader, error)

func (*ContainerType) Name

func (c *ContainerType) Name() string

func (*ContainerType) Start

func (c *ContainerType) Start(ctx context.Context) error

func (*ContainerType) Stop

func (c *ContainerType) Stop(ctx context.Context) error

func (*ContainerType) WaitForReady

func (c *ContainerType) WaitForReady(ctx context.Context) (state *types.ContainerState, err error)

func (*ContainerType) WaitForStatusHealthly

func (c *ContainerType) WaitForStatusHealthly(ctx context.Context) (state *types.ContainerState, err error)

type Docker

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

func New

func New() (*Docker, error)

func (*Docker) BuildImage

func (c *Docker) BuildImage(path, tag string) error

func (Docker) ContainerExists

func (c Docker) ContainerExists(ctx context.Context, containerID string) bool

ImageExists return if image is already present.

func (*Docker) CreateNetwork

func (c *Docker) CreateNetwork(name string) (*Network, error)

func (Docker) ImageExists

func (c Docker) ImageExists(ctx context.Context, image string) bool

ImageExists return if image is already present.

func (*Docker) ImagePull

func (c *Docker) ImagePull(ctx context.Context, image string) error

ImagePull fetch image from docker.io registry.

func (*Docker) NewContainer

func (c *Docker) NewContainer(config ContainerConfig) (*ContainerType, error)

func (*Docker) PullImage

func (c *Docker) PullImage(ref string) error

func (*Docker) PullImageIfNotExist

func (c *Docker) PullImageIfNotExist(ctx context.Context, image string) error

PullImageIfNotExist fetch image from remote repository if not exits.

func (*Docker) RemoveContainer

func (c *Docker) RemoveContainer(ctx context.Context, id string) error

type HealthCheckConfig

type HealthCheckConfig struct {
	Test     []string
	Interval time.Duration
	Timeout  time.Duration
	Retries  int
}

type HostPort

type HostPort int

type Mount

type Mount struct {
	Source string
	Target string
}

type Mounts

type Mounts []Mount

type MultiWaitPolicy

type MultiWaitPolicy struct {
	WaitPolicies []WaitForIt
}

func (*MultiWaitPolicy) WaitForIt

func (w *MultiWaitPolicy) WaitForIt(ctx context.Context, c *ContainerType) error

type Network

type Network struct {
	ID string
	NetworkConfig
	// contains filtered or unexported fields
}

func NewNetwork

func NewNetwork(client *Docker, config NetworkConfig) (*Network, error)

func (*Network) Close

func (n *Network) Close() error

func (*Network) Remove

func (n *Network) Remove() error

type NetworkConfig

type NetworkConfig struct {
	Name          string
	Labels        map[string]string
	AttachIfExist bool
}

type PortMap

type PortMap map[ContainerPort]HostPort

type PullImageConfig

type PullImageConfig struct {
	Ref string
}

type State

type State struct {
	ExitCode int
	Status   string
}

type WaitForCommand

type WaitForCommand struct {
	Command string
}

func (*WaitForCommand) WaitForIt

func (w *WaitForCommand) WaitForIt(ctx context.Context, c *ContainerType) error

type WaitForIt

type WaitForIt interface {
	WaitForIt(context.Context, *ContainerType) error
}

type WaitForPort

type WaitForPort struct {
	Port int
}

func (*WaitForPort) WaitForIt

func (w *WaitForPort) WaitForIt(ctx context.Context, c *ContainerType) error

type WaitForProcess

type WaitForProcess struct {
	Process string
}

func (*WaitForProcess) WaitForIt

func (w *WaitForProcess) WaitForIt(ctx context.Context, c *ContainerType) error

type WaitPolicy

type WaitPolicy interface {
	WaitForIt(context.Context, *ContainerType) error
	// contains filtered or unexported methods
}

type WaitWithDeley

type WaitWithDeley struct {
	Deley time.Duration
}

func (*WaitWithDeley) WaitForIt

func (w *WaitWithDeley) WaitForIt(ctx context.Context, c *ContainerType) error

Jump to

Keyboard shortcuts

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