dockerapi

package
v1.42.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 34 Imported by: 44

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"
	// CannotStartContainerErrorName is the name of container start error.
	CannotStartContainerErrorName = "CannotStartContainerError"
	// CannotDescribeContainerErrorName is the name of describe container error.
	CannotDescribeContainerErrorName = "CannotDescribeContainerError"
)
View Source
const (

	// VolumeDriverType is one of the plugin capabilities see https://docs.docker.com/engine/reference/commandline/plugin_ls/#filtering
	VolumeDriverType = "volumedriver"
)

Variables

This section is empty.

Functions

func DockerStateToState

func DockerStateToState(state *types.ContainerState) apicontainerstatus.ContainerStatus

DockerStateToState converts the container status from docker to status recognized by the agent

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 CannotCreateVolumeError added in v1.21.0

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

CannotCreateVolumeError indicates any error when trying to create a volume

func (CannotCreateVolumeError) Error added in v1.21.0

func (err CannotCreateVolumeError) Error() string

func (CannotCreateVolumeError) ErrorName added in v1.21.0

func (err CannotCreateVolumeError) ErrorName() string

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 CannotInspectVolumeError added in v1.21.0

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

CannotInspectVolumeError indicates any error when trying to inspect a volume

func (CannotInspectVolumeError) Error added in v1.21.0

func (err CannotInspectVolumeError) Error() string

func (CannotInspectVolumeError) ErrorName added in v1.21.0

func (err CannotInspectVolumeError) ErrorName() string

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 CannotListImagesError added in v1.24.0

type CannotListImagesError struct {
	FromError error
}

func (CannotListImagesError) Error added in v1.24.0

func (err CannotListImagesError) Error() string

func (CannotListImagesError) ErrorName added in v1.24.0

func (err CannotListImagesError) ErrorName() string

ErrorName returns name of the CannotListImagesError

type CannotListPluginsError added in v1.21.0

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

CannotListPluginsError indicates any error when trying to list docker plugins

func (CannotListPluginsError) Error added in v1.21.0

func (err CannotListPluginsError) Error() string

func (CannotListPluginsError) ErrorName added in v1.21.0

func (err CannotListPluginsError) ErrorName() string

type CannotPullContainerAuthError added in v1.21.0

type CannotPullContainerAuthError struct {
	FromError error
}

CannotPullContainerAuthError indicates any error when trying to pull a container image

func (CannotPullContainerAuthError) Error added in v1.21.0

func (CannotPullContainerAuthError) ErrorName added in v1.21.0

func (err CannotPullContainerAuthError) ErrorName() string

ErrorName returns name of the CannotPullContainerAuthError.

func (CannotPullContainerAuthError) Retry added in v1.21.0

func (err CannotPullContainerAuthError) Retry() bool

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

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 CannotRemoveVolumeError added in v1.21.0

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

CannotRemoveVolumeError indicates any error when trying to inspect a volume

func (CannotRemoveVolumeError) Error added in v1.21.0

func (err CannotRemoveVolumeError) Error() string

func (CannotRemoveVolumeError) ErrorName added in v1.21.0

func (err CannotRemoveVolumeError) ErrorName() string

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 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(context.Context) (<-chan DockerContainerChangeEvent, error)

	// PullImage pulls an image. authData should contain authentication data provided by the ECS backend.
	PullImage(context.Context, string, *apicontainer.RegistryAuthenticationData, time.Duration) DockerContainerMetadata

	// CreateContainer creates a container with the provided Config, HostConfig, and name. A timeout value
	// and a context should be provided for the request.
	CreateContainer(context.Context, *dockercontainer.Config, *dockercontainer.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) (apicontainerstatus.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) (*types.ContainerJSON, 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

	// ListImages returns the set of the images known to the Docker daemon
	ListImages(context.Context, time.Duration) ListImagesResponse

	// CreateVolume creates a docker volume. A timeout value should be provided for the request
	CreateVolume(context.Context, string, string, map[string]string, map[string]string, time.Duration) SDKVolumeResponse

	// InspectVolume returns a volume by its name. A timeout value should be provided for the request
	InspectVolume(context.Context, string, time.Duration) SDKVolumeResponse

	// RemoveVolume removes a volume by its name. A timeout value should be provided for the request
	RemoveVolume(context.Context, string, time.Duration) error

	// ListPluginsWithFilters returns the set of docker plugins installed on the host, filtered by options provided.
	// A timeout value should be provided for the request.
	// TODO ListPluginsWithFilters can be removed since ListPlugins takes in filters
	ListPluginsWithFilters(context.Context, bool, []string, time.Duration) ([]string, error)

	// ListPlugins returns the set of docker plugins installed on the host. A timeout value should be provided for
	// the request.
	ListPlugins(context.Context, time.Duration, filters.Args) ListPluginsResponse

	// Stats returns a channel of stat data for the specified container. A context should be provided so the request can
	// be canceled.
	Stats(context.Context, string, time.Duration) (<-chan *types.StatsJSON, <-chan 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) (*types.ImageInspect, 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

	// Info returns the information of the Docker server.
	Info(context.Context, time.Duration) (types.Info, error)
}

DockerClient interface to make testing it easier

func NewDockerGoClient

func NewDockerGoClient(sdkclientFactory sdkclientfactory.Factory,
	cfg *config.Config, ctx context.Context) (DockerClient, error)

NewDockerGoClient creates a new DockerGoClient TODO Remove clientfactory parameter once migration to Docker SDK is complete.

type DockerContainerChangeEvent

type DockerContainerChangeEvent struct {
	// Status represents the container's status in the event
	Status apicontainerstatus.ContainerStatus
	// DockerContainerMetadata is the metadata of the container in the event
	DockerContainerMetadata
	// Type is the event type received from docker events
	Type apicontainer.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 []apicontainer.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 []types.MountPoint
	// 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 apicontainer.HealthStatus
	// NetworkMode denotes the network mode in which the container is started
	NetworkMode string
	// NetworksUnsafe denotes the Docker Network Settings in the container
	NetworkSettings *types.NetworkSettings
}

DockerContainerMetadata is a type for metadata about Docker containers

func MetadataFromContainer

func MetadataFromContainer(dockerContainer *types.ContainerJSON) 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 ImagePullResponse added in v1.24.0

type ImagePullResponse struct {
	Id             string `json:"id,omitempty"`
	Status         string `json:"status,omitempty"`
	ProgressDetail struct {
		Current int64 `json:"current,omitempty"`
		Total   int64 `json:"total,omitempty"`
	} `json:"progressDetail,omitempty"`
	Progress string `json:"progress,omitempty"`
	Error    string `json:"error,omitempty"`
}

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<- *events.Message)

Consume reads the buffer and write to a listener channel

func (*InfiniteBuffer) CopyEvents

func (buffer *InfiniteBuffer) CopyEvents(event *events.Message)

CopyEvents copies the event into the buffer

func (*InfiniteBuffer) StartListening

func (buffer *InfiniteBuffer) StartListening(ctx context.Context, eventChan <-chan events.Message)

StartListening starts reading from the input channel and writes to the buffer When context is cancelled, 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 ListImagesResponse added in v1.24.0

type ListImagesResponse struct {
	// ImagesIDs is the list of Images IDs from the ListImages call
	ImageIDs []string
	// RepoTags is the list of Images names from the ListImages call
	RepoTags []string
	// Error contains any error returned when listing images
	Error error
}

ListImagesResponse encapsulates the response from the docker client for the ListImages call.

type ListPluginsResponse added in v1.21.0

type ListPluginsResponse struct {
	Plugins []*types.Plugin
	Error   error
}

ListPluginsResponse is a wrapper for ListPlugins api

type NoSuchContainerError added in v1.24.0

type NoSuchContainerError struct {
	ID string
}

NoSuchContainerError indicates error when a given container is not found.

func (NoSuchContainerError) Error added in v1.24.0

func (err NoSuchContainerError) Error() string

func (NoSuchContainerError) ErrorName added in v1.24.0

func (err NoSuchContainerError) ErrorName() string

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

type SDKVolumeResponse added in v1.24.0

type SDKVolumeResponse struct {
	DockerVolume *types.Volume
	Error        error
}

VolumeResponse wrapper for CreateVolume for SDK Clients

type VolumeResponse added in v1.21.0

type VolumeResponse struct {
	DockerVolume *types.Volume
	Error        error
}

VolumeResponse wrapper for CreateVolume and InspectVolume TODO Remove type when migration is complete

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