dockerapi

package
v1.18.0-coveo.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DockerTimeoutErrorName is the name of docker timeout error.
	DockerTimeoutErrorName = "DockerTimeoutError"
	// CannotInspectContainerErrorName is the name of container inspect error.
	CannotInspectContainerErrorName = "CannotInspectContainerError"
	// CannotDescribeContainerErrorName is the name of describe container error.
	CannotDescribeContainerErrorName = "CannotDescribeContainerError"
)
View Source
const (

	// StatsInactivityTimeout controls the amount of time we hold open a
	// connection to the Docker daemon waiting for stats data
	StatsInactivityTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func DockerStateToState

func DockerStateToState(state docker.State) api.ContainerStatus

DockerStateToState converts the container status from docker to status recognized by the agent Ref: https://github.com/fsouza/go-dockerclient/blob/fd53184a1439b6d7b82ca54c1cd9adac9a5278f2/container.go#L133

Types

type CannotCreateContainerError

type CannotCreateContainerError struct {
	FromError error
}

CannotCreateContainerError indicates any error when trying to create a container

func (CannotCreateContainerError) Error

func (err CannotCreateContainerError) Error() string

func (CannotCreateContainerError) ErrorName

func (err CannotCreateContainerError) ErrorName() string

ErrorName returns name of the CannotCreateContainerError.

type CannotDescribeContainerError

type CannotDescribeContainerError struct {
	FromError error
}

CannotDescribeContainerError indicates any error when trying to describe a container

func (CannotDescribeContainerError) Error

func (CannotDescribeContainerError) ErrorName

func (err CannotDescribeContainerError) ErrorName() string

ErrorName returns name of the CannotDescribeContainerError

type CannotGetDockerClientError

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

CannotGetDockerClientError is a type for failing to get a specific Docker client

func (CannotGetDockerClientError) Error

func (CannotGetDockerClientError) ErrorName

func (CannotGetDockerClientError) ErrorName() string

ErrorName returns the name of the CannotGetDockerClientError.

type CannotInspectContainerError

type CannotInspectContainerError struct {
	FromError error
}

CannotInspectContainerError indicates any error when trying to inspect a container

func (CannotInspectContainerError) Error

func (err CannotInspectContainerError) Error() string

func (CannotInspectContainerError) ErrorName

func (err CannotInspectContainerError) ErrorName() string

ErrorName returns name of the CannotInspectContainerError

type CannotListContainersError

type CannotListContainersError struct {
	FromError error
}

CannotListContainersError indicates any error when trying to list containers

func (CannotListContainersError) Error

func (err CannotListContainersError) Error() string

func (CannotListContainersError) ErrorName

func (err CannotListContainersError) ErrorName() string

ErrorName returns name of the CannotListContainersError

type CannotPullContainerError

type CannotPullContainerError struct {
	FromError error
}

CannotPullContainerError indicates any error when trying to pull a container image

func (CannotPullContainerError) Error

func (err CannotPullContainerError) Error() string

func (CannotPullContainerError) ErrorName

func (err CannotPullContainerError) ErrorName() string

ErrorName returns name of the CannotPullContainerError.

type CannotPullECRContainerError

type CannotPullECRContainerError struct {
	FromError error
}

CannotPullECRContainerError indicates any error when trying to pull a container image from ECR

func (CannotPullECRContainerError) Error

func (err CannotPullECRContainerError) Error() string

func (CannotPullECRContainerError) ErrorName

func (err CannotPullECRContainerError) ErrorName() string

ErrorName returns name of the CannotPullECRContainerError.

func (CannotPullECRContainerError) Retry

func (err CannotPullECRContainerError) Retry() bool

Retry fulfills the utils.Retrier interface and allows retries to be skipped by utils.Retry* functions

type CannotRemoveContainerError

type CannotRemoveContainerError struct {
	FromError error
}

CannotRemoveContainerError indicates any error when trying to remove a container

func (CannotRemoveContainerError) Error

func (err CannotRemoveContainerError) Error() string

func (CannotRemoveContainerError) ErrorName

func (err CannotRemoveContainerError) ErrorName() string

ErrorName returns name of the CannotRemoveContainerError

type CannotStartContainerError

type CannotStartContainerError struct {
	FromError error
}

CannotStartContainerError indicates any error when trying to start a container

func (CannotStartContainerError) Error

func (err CannotStartContainerError) Error() string

func (CannotStartContainerError) ErrorName

func (err CannotStartContainerError) ErrorName() string

ErrorName returns name of the CannotStartContainerError

type CannotStopContainerError

type CannotStopContainerError struct {
	FromError error
}

CannotStopContainerError indicates any error when trying to stop a container

func (CannotStopContainerError) Error

func (err CannotStopContainerError) Error() string

func (CannotStopContainerError) ErrorName

func (err CannotStopContainerError) ErrorName() string

ErrorName returns name of the CannotStopContainerError.

func (CannotStopContainerError) IsRetriableError

func (err CannotStopContainerError) IsRetriableError() bool

IsRetriableError returns a boolean indicating whether the call that generated the error can be retried. When stopping a container, most errors that we can get should be considered retriable. However, in the case where the container is already stopped or doesn't exist at all, there's no sense in retrying.

type ContainerNotFound

type ContainerNotFound struct {
	// TaskArn is the ARN of the task the container belongs to
	TaskArn string
	// ContainerName is the name of the container that's missing
	ContainerName string
}

ContainerNotFound is a type for a missing container

func (ContainerNotFound) Error

func (cnferror ContainerNotFound) Error() string

Error returns an error string for the ContainerNotFound error

type CreateEmptyVolumeError

type CreateEmptyVolumeError struct {
	FromError error
}

CreateEmptyVolumeError indicates any error when trying create empty volume

func (CreateEmptyVolumeError) Error

func (err CreateEmptyVolumeError) Error() string

func (CreateEmptyVolumeError) ErrorName

func (err CreateEmptyVolumeError) ErrorName() string

ErrorName returns name of the CreateEmptyVolumeError.

func (CreateEmptyVolumeError) Retry

func (err CreateEmptyVolumeError) Retry() bool

Retry fulfills the utils.Retrier interface and allows retries to be skipped by utils.Retry* functions

type DockerClient

type DockerClient interface {
	// SupportedVersions returns a slice of the supported docker versions (or at least supposedly supported).
	SupportedVersions() []dockerclient.DockerVersion

	// KnownVersions returns a slice of the Docker API versions known to the Docker daemon.
	KnownVersions() []dockerclient.DockerVersion

	// WithVersion returns a new DockerClient for which all operations will use the given remote api version.
	// A default version will be used for a client not produced via this method.
	WithVersion(dockerclient.DockerVersion) DockerClient

	// ContainerEvents returns a channel of DockerContainerChangeEvents. Events are placed into the channel and should
	// be processed by the listener.
	ContainerEvents(ctx context.Context) (<-chan DockerContainerChangeEvent, error)

	// PullImage pulls an image. authData should contain authentication data provided by the ECS backend.
	PullImage(image string, authData *ecr.RegistryAuthenticationData) DockerContainerMetadata

	// ImportLocalEmptyVolumeImage imports a locally-generated empty-volume image for supported platforms.
	ImportLocalEmptyVolumeImage() DockerContainerMetadata

	// CreateContainer creates a container with the provided docker.Config, docker.HostConfig, and name. A timeout value
	// and a context should be provided for the request.
	CreateContainer(context.Context, *docker.Config, *docker.HostConfig, string, time.Duration) DockerContainerMetadata

	// StartContainer starts the container identified by the name provided. A timeout value and a context should be
	// provided for the request.
	StartContainer(context.Context, string, time.Duration) DockerContainerMetadata

	// StopContainer stops the container identified by the name provided. A timeout value and a context should be provided
	// for the request.
	StopContainer(context.Context, string, time.Duration) DockerContainerMetadata

	// DescribeContainer returns status information about the specified container. A context should be provided
	// for the request
	DescribeContainer(context.Context, string) (api.ContainerStatus, DockerContainerMetadata)

	// RemoveContainer removes a container (typically the rootfs, logs, and associated metadata) identified by the name.
	// A timeout value and a context should be provided for the request.
	RemoveContainer(context.Context, string, time.Duration) error

	// InspectContainer returns information about the specified container. A timeout value and a context should be
	// provided for the request.
	InspectContainer(context.Context, string, time.Duration) (*docker.Container, error)

	// ListContainers returns the set of containers known to the Docker daemon. A timeout value and a context
	// should be provided for the request.
	ListContainers(context.Context, bool, time.Duration) ListContainersResponse

	// Stats returns a channel of stat data for the specified container. A context should be provided so the request can
	// be canceled.
	Stats(string, context.Context) (<-chan *docker.Stats, error)

	// Version returns the version of the Docker daemon.
	Version(context.Context, time.Duration) (string, error)

	// APIVersion returns the api version of the client
	APIVersion() (dockerclient.DockerVersion, error)

	// InspectImage returns information about the specified image.
	InspectImage(string) (*docker.Image, error)

	// RemoveImage removes the metadata associated with an image and may remove the underlying layer data. A timeout
	// value and a context should be provided for the request.
	RemoveImage(context.Context, string, time.Duration) error
	// LoadImage loads an image from an input stream. A timeout value and a context should be provided for the request.
	LoadImage(context.Context, io.Reader, time.Duration) error
}

DockerClient interface to make testing it easier

func NewDockerGoClient

func NewDockerGoClient(clientFactory clientfactory.Factory, cfg *config.Config) (DockerClient, error)

NewDockerGoClient creates a new DockerGoClient

type DockerContainerChangeEvent

type DockerContainerChangeEvent struct {
	// Status represents the container's status in the event
	Status api.ContainerStatus
	// DockerContainerMetadata is the metadata of the container in the event
	DockerContainerMetadata
	// Type is the event type received from docker events
	Type api.DockerEventType
}

DockerContainerChangeEvent is a type for container change events

func (*DockerContainerChangeEvent) String

func (event *DockerContainerChangeEvent) String() string

String returns a human readable string of the container change event

type DockerContainerMetadata

type DockerContainerMetadata struct {
	// DockerID is the contianer's id generated by Docker
	DockerID string
	// ExitCode contains container's exit code if it has stopped
	ExitCode *int
	// PortBindings is the list of port binding information of the container
	PortBindings []api.PortBinding
	// Error wraps various container transition errors and is set if engine
	// is unable to perform any of the required container transitions
	Error apierrors.NamedError
	// Volumes contains volume informaton for the container
	Volumes map[string]string
	// Labels contains labels set for the container
	Labels map[string]string
	// CreatedAt is the timestamp of container creation
	CreatedAt time.Time
	// StartedAt is the timestamp of container start
	StartedAt time.Time
	// FinishedAt is the timestamp of container stop
	FinishedAt time.Time
	// Health contains the result of a container health check
	Health api.HealthStatus
}

DockerContainerMetadata is a type for metadata about Docker containers

func MetadataFromContainer

func MetadataFromContainer(dockerContainer *docker.Container) DockerContainerMetadata

MetadataFromContainer translates dockerContainer into DockerContainerMetadata

type DockerStateError

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

DockerStateError is a wrapper around the error docker puts in the '.State.Error' field of its inspect output.

func NewDockerStateError

func NewDockerStateError(err string) DockerStateError

NewDockerStateError creates a DockerStateError

func (DockerStateError) Error

func (err DockerStateError) Error() string

func (DockerStateError) ErrorName

func (err DockerStateError) ErrorName() string

ErrorName returns the name of the DockerStateError.

type DockerTimeoutError

type DockerTimeoutError struct {
	// Duration is the timeout period.
	Duration time.Duration
	// Transition is the description of operation that timed out.
	Transition string
}

DockerTimeoutError is an error type for describing timeouts

func (*DockerTimeoutError) Error

func (err *DockerTimeoutError) Error() string

func (*DockerTimeoutError) ErrorName

func (err *DockerTimeoutError) ErrorName() string

ErrorName returns the name of the error

type InfiniteBuffer

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

InfiniteBuffer defines an unlimited buffer, where it reads from input channel and write to output channel.

func NewInfiniteBuffer

func NewInfiniteBuffer() *InfiniteBuffer

NewInfiniteBuffer returns an InfiniteBuffer object

func (*InfiniteBuffer) Consume

func (buffer *InfiniteBuffer) Consume(in chan<- *docker.APIEvents)

Consume reads the buffer and write to a listener channel

func (*InfiniteBuffer) CopyEvents

func (buffer *InfiniteBuffer) CopyEvents(event *docker.APIEvents)

CopyEvents copies the event into the buffer

func (*InfiniteBuffer) StartListening

func (buffer *InfiniteBuffer) StartListening(events chan *docker.APIEvents)

StartListening starts reading from the input channel and writes to the buffer TODO: wire in ctx to stop listening

type ListContainersResponse

type ListContainersResponse struct {
	// DockerIDs is the list of container IDs from the ListContainers call
	DockerIDs []string
	// Error contains any error returned when listing containers
	Error error
}

ListContainersResponse encapsulates the response from the docker client for the ListContainers call.

type OutOfMemoryError

type OutOfMemoryError struct{}

OutOfMemoryError is a type for errors caused by running out of memory

func (OutOfMemoryError) Error

func (err OutOfMemoryError) Error() string

func (OutOfMemoryError) ErrorName

func (err OutOfMemoryError) ErrorName() string

ErrorName returns the name of the error

Directories

Path Synopsis
Package mock_dockerapi is a generated GoMock package.
Package mock_dockerapi is a generated GoMock package.

Jump to

Keyboard shortcuts

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