container

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package container contains utilities for building image from services.

Package container is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	FailedToListImages   = errors.New("failed to list images")
	FailedToBuildImage   = errors.New("failed to build the image")
	FailedToPullImage    = errors.New("failed to pull the image")
	FailedToInspectImage = errors.New("failed to inspect the image")
)
View Source
var (
	DockerEngineError                  = errors.New("failed to connect to docker engine")
	FailedToConnectToDockerEngineError = errors.New("failed to connect to docker engine")
	FailedToPrepareBuildArchive        = errors.New("failed to prepare the build archive")
	FailedToCreateContainer            = errors.New("failed to create the container")
	FailedToStartContainer             = errors.New("failed to start the container")
	FailedToStopContainer              = errors.New("failed to stop the container")
	FailedToRemoveContainer            = errors.New("failed to remove the container")
	FailedToBindVolume                 = errors.New("failed to bind container volume")
)
View Source
var (
	FailedToCreateNetwork  = errors.New("failed to create the network")
	FailedToDestroyNetwork = errors.New("failed to destroy the network")
	FailedToJoinNetwork    = errors.New("failed to join the network")
	FailedToLeaveNetwork   = errors.New("failed to leave the network")
)

Functions

This section is empty.

Types

type Container

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

A very simple struct for representing the functionality we actually need to expose from here.

type ContainerRuntime

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

func NewRuntime

func NewRuntime(
	ctx context.Context, logger logging.Logger, out io.Writer,
) (*ContainerRuntime, error)

func (*ContainerRuntime) AddToNetwork

func (cr *ContainerRuntime) AddToNetwork(n *Network, con *Container) error

func (*ContainerRuntime) AllContainers

func (cr *ContainerRuntime) AllContainers() ([]*Container, error)

func (*ContainerRuntime) BuildImage

func (cr *ContainerRuntime) BuildImage(img *Image) error

func (*ContainerRuntime) Context

func (cr *ContainerRuntime) Context() context.Context

func (*ContainerRuntime) CreateNetwork

func (cr *ContainerRuntime) CreateNetwork(net *Network) error

func (*ContainerRuntime) GetContainer

func (cr *ContainerRuntime) GetContainer(name string) (*Container, error)

func (*ContainerRuntime) GetImage

func (cr *ContainerRuntime) GetImage(name string) (*Image, error)

func (*ContainerRuntime) ListImages

func (cr *ContainerRuntime) ListImages() ([]*Image, error)

func (*ContainerRuntime) NetworkExists

func (cr *ContainerRuntime) NetworkExists(net *Network) (bool, error)

func (*ContainerRuntime) NewContainer

func (cr *ContainerRuntime) NewContainer(
	name string, image Image, mounts ...Mount,
) *Container

func (*ContainerRuntime) NewNetwork

func (cr *ContainerRuntime) NewNetwork(name string) *Network

func (*ContainerRuntime) PullImage

func (cr *ContainerRuntime) PullImage(name string) (*Image, error)

func (*ContainerRuntime) RemoveContainer

func (cr *ContainerRuntime) RemoveContainer(con *Container) error

func (*ContainerRuntime) RemoveFromNetwork

func (cr *ContainerRuntime) RemoveFromNetwork(net *Network, con *Container) error

func (*ContainerRuntime) RemoveNetwork

func (cr *ContainerRuntime) RemoveNetwork(net *Network) error

func (*ContainerRuntime) RunContainer

func (cr *ContainerRuntime) RunContainer(net *Network, con *Container) error

func (*ContainerRuntime) StopContainer

func (cr *ContainerRuntime) StopContainer(con *Container) error

type DockerClient

type DockerClient interface {
	ImagePull(
		ctx context.Context,
		ref string,
		options types.ImagePullOptions,
	) (io.ReadCloser, error)

	ImageList(
		ctx context.Context,
		options types.ImageListOptions,
	) ([]types.ImageSummary, error)

	ImageBuild(
		ctx context.Context,
		buildContext io.Reader,
		options types.ImageBuildOptions,
	) (types.ImageBuildResponse, error)

	ImageInspectWithRaw(
		ctx context.Context,
		imageID string,
	) (types.ImageInspect, []byte, error)

	NetworkCreate(
		ctx context.Context,
		name string,
		options types.NetworkCreate,
	) (types.NetworkCreateResponse, error)

	NetworkRemove(
		ctx context.Context,
		networkID string,
	) error

	NetworkList(
		ctx context.Context,
		options types.NetworkListOptions,
	) ([]types.NetworkResource, error)

	NetworkConnect(
		ctx context.Context,
		networkID,
		containerID string,
		config *network.EndpointSettings,
	) error

	NetworkDisconnect(
		ctx context.Context,
		networkID,
		containerID string,
		force bool,
	) error

	ContainerCreate(
		ctx context.Context,
		config *container.Config,
		hostConfig *container.HostConfig,
		networkingConfig *network.NetworkingConfig,
		platform *specs.Platform,
		containerName string,
	) (container.ContainerCreateCreatedBody, error)

	ContainerStart(
		ctx context.Context,
		containerID string,
		options types.ContainerStartOptions,
	) error

	ContainerStop(
		ctx context.Context,
		containerID string,
		timeout *time.Duration,
	) error

	ContainerRemove(
		ctx context.Context,
		containerID string,
		options types.ContainerRemoveOptions,
	) error

	ContainerList(
		ctx context.Context,
		options types.ContainerListOptions,
	) ([]types.Container, error)
}

type Image

type Image struct {
	ID      string
	Src     string
	Name    string
	WorkDir string
}

type MockDockerClient

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

MockDockerClient is a mock of DockerClient interface

func NewMockDockerClient

func NewMockDockerClient(ctrl *gomock.Controller) *MockDockerClient

NewMockDockerClient creates a new mock instance

func (*MockDockerClient) ContainerCreate

func (m *MockDockerClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (container.ContainerCreateCreatedBody, error)

ContainerCreate mocks base method

func (*MockDockerClient) ContainerList

func (m *MockDockerClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)

ContainerList mocks base method

func (*MockDockerClient) ContainerRemove

func (m *MockDockerClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error

ContainerRemove mocks base method

func (*MockDockerClient) ContainerStart

func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error

ContainerStart mocks base method

func (*MockDockerClient) ContainerStop

func (m *MockDockerClient) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error

ContainerStop mocks base method

func (*MockDockerClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDockerClient) ImageBuild

func (m *MockDockerClient) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)

ImageBuild mocks base method

func (*MockDockerClient) ImageInspectWithRaw

func (m *MockDockerClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)

ImageInspectWithRaw mocks base method

func (*MockDockerClient) ImageList

ImageList mocks base method

func (*MockDockerClient) ImagePull

func (m *MockDockerClient) ImagePull(ctx context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error)

ImagePull mocks base method

func (*MockDockerClient) NetworkConnect

func (m *MockDockerClient) NetworkConnect(ctx context.Context, networkID, containerID string, config *network.EndpointSettings) error

NetworkConnect mocks base method

func (*MockDockerClient) NetworkCreate

func (m *MockDockerClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)

NetworkCreate mocks base method

func (*MockDockerClient) NetworkDisconnect

func (m *MockDockerClient) NetworkDisconnect(ctx context.Context, networkID, containerID string, force bool) error

NetworkDisconnect mocks base method

func (*MockDockerClient) NetworkList

NetworkList mocks base method

func (*MockDockerClient) NetworkRemove

func (m *MockDockerClient) NetworkRemove(ctx context.Context, networkID string) error

NetworkRemove mocks base method

type MockDockerClientMockRecorder

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

MockDockerClientMockRecorder is the mock recorder for MockDockerClient

func (*MockDockerClientMockRecorder) ContainerCreate

func (mr *MockDockerClientMockRecorder) ContainerCreate(ctx, config, hostConfig, networkingConfig, platform, containerName interface{}) *gomock.Call

ContainerCreate indicates an expected call of ContainerCreate

func (*MockDockerClientMockRecorder) ContainerList

func (mr *MockDockerClientMockRecorder) ContainerList(ctx, options interface{}) *gomock.Call

ContainerList indicates an expected call of ContainerList

func (*MockDockerClientMockRecorder) ContainerRemove

func (mr *MockDockerClientMockRecorder) ContainerRemove(ctx, containerID, options interface{}) *gomock.Call

ContainerRemove indicates an expected call of ContainerRemove

func (*MockDockerClientMockRecorder) ContainerStart

func (mr *MockDockerClientMockRecorder) ContainerStart(ctx, containerID, options interface{}) *gomock.Call

ContainerStart indicates an expected call of ContainerStart

func (*MockDockerClientMockRecorder) ContainerStop

func (mr *MockDockerClientMockRecorder) ContainerStop(ctx, containerID, timeout interface{}) *gomock.Call

ContainerStop indicates an expected call of ContainerStop

func (*MockDockerClientMockRecorder) ImageBuild

func (mr *MockDockerClientMockRecorder) ImageBuild(ctx, buildContext, options interface{}) *gomock.Call

ImageBuild indicates an expected call of ImageBuild

func (*MockDockerClientMockRecorder) ImageInspectWithRaw

func (mr *MockDockerClientMockRecorder) ImageInspectWithRaw(ctx, imageID interface{}) *gomock.Call

ImageInspectWithRaw indicates an expected call of ImageInspectWithRaw

func (*MockDockerClientMockRecorder) ImageList

func (mr *MockDockerClientMockRecorder) ImageList(ctx, options interface{}) *gomock.Call

ImageList indicates an expected call of ImageList

func (*MockDockerClientMockRecorder) ImagePull

func (mr *MockDockerClientMockRecorder) ImagePull(ctx, ref, options interface{}) *gomock.Call

ImagePull indicates an expected call of ImagePull

func (*MockDockerClientMockRecorder) NetworkConnect

func (mr *MockDockerClientMockRecorder) NetworkConnect(ctx, networkID, containerID, config interface{}) *gomock.Call

NetworkConnect indicates an expected call of NetworkConnect

func (*MockDockerClientMockRecorder) NetworkCreate

func (mr *MockDockerClientMockRecorder) NetworkCreate(ctx, name, options interface{}) *gomock.Call

NetworkCreate indicates an expected call of NetworkCreate

func (*MockDockerClientMockRecorder) NetworkDisconnect

func (mr *MockDockerClientMockRecorder) NetworkDisconnect(ctx, networkID, containerID, force interface{}) *gomock.Call

NetworkDisconnect indicates an expected call of NetworkDisconnect

func (*MockDockerClientMockRecorder) NetworkList

func (mr *MockDockerClientMockRecorder) NetworkList(ctx, options interface{}) *gomock.Call

NetworkList indicates an expected call of NetworkList

func (*MockDockerClientMockRecorder) NetworkRemove

func (mr *MockDockerClientMockRecorder) NetworkRemove(ctx, networkID interface{}) *gomock.Call

NetworkRemove indicates an expected call of NetworkRemove

type Mount

type Mount struct {
	Src string
	Dst string
}

type Network

type Network struct {
	ID   string
	Name string
}

A very simple abstraction for a network that avoids exposing too much of the docker API

Jump to

Keyboard shortcuts

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