dockerlib

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: BSD-3-Clause Imports: 14 Imported by: 3

README

dockerlib

Helper functions around the Docker GO SDK

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureImage

func EnsureImage(ctx context.Context, cli *client.Client, image string) error

EnsureImage is a helper method to pull the specified image to the local machine running Docker.

func SetLogger

func SetLogger(newLogger *zap.Logger)

Types

type Container

type Container struct {
	Name        string
	Image       string
	ID          string
	Mounts      []mount.Mount
	Ports       map[int]int
	Command     []string
	Environment []string
}

Container represents a simplified interface for starting a Docker container

func (Container) PortBindings

func (c Container) PortBindings() (map[nat.Port]struct{}, map[nat.Port][]nat.PortBinding, error)

PortBindings Helper method to return the structs required to start a Docker container, or any error

func (Container) String

func (c Container) String() string

Returns a simplified string representation

type ContainerError

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

func (ContainerError) Error

func (e ContainerError) Error() string

type Controller

type Controller interface {
	Start(ctx context.Context, c Container, ready string) (chan bool, error)
	Shutdown(ctx context.Context, c Container) error
	ShutdownAll(ctx context.Context) error
}

Controller is used to represent a type that can Start, Shutdown, or ShutdownAll containers.

func NewDockerController

func NewDockerController() (*Controller, error)

NewDockerController is a helper method to create a new instance of a DockerController.

type DockerController

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

DockerController is a concrete type that can be used to control Docker containers using its SDK.

func (DockerController) Shutdown

func (controller DockerController) Shutdown(ctx context.Context, c Container) error

Shutdown terminates and removes the specified running Container.

func (DockerController) ShutdownAll

func (controller DockerController) ShutdownAll(ctx context.Context) error

ShutdownAll terminates and removes all running containers

func (DockerController) Start

func (controller DockerController) Start(ctx context.Context, c Container, ready string) (chan bool, error)

Start is the method used to Start a Docker container using the specified Container c. It also automatically follows logs and creates a channel that is used to indicate when a running container is ready according to the provided ready string.

type DockerError

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

func (DockerError) Error

func (e DockerError) Error() string

type EnsureImageProgress

type EnsureImageProgress struct {
	Status         string
	ProgressDetail EnsureImageProgressDetail
	Progress       string
	ID             string
}

EnsureImageProgress is an object to unmarshall JSON returned from Docker during a pull.

func (EnsureImageProgress) String

func (p EnsureImageProgress) String() string

type EnsureImageProgressDetail

type EnsureImageProgressDetail struct {
	Current int
	Total   int
}

EnsureImageProgressDetail is an object to help unmarshall JSON returned from Docker during a pull.

Jump to

Keyboard shortcuts

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