Documentation ¶
Index ¶
- Constants
- type Client
- func (dc *Client) GetContainerList() ([]types.Container, error)
- func (dc *Client) GetContainersByComponent(componentName string, containers []types.Container) []types.Container
- func (dc *Client) PullImage(image string) error
- func (dc *Client) StartContainer(containerConfig *container.Config, hostConfig *container.HostConfig, ...) error
- type DockerClient
Constants ¶
const MinDockerAPIVersion = "1.30"
MinDockerAPIVersion is the minimum Docker API version to use 1.30 corresponds to Docker 17.05, which should be sufficiently old enough
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Context context.Context Client DockerClient }
Client is a collection of fields used for client configuration and interaction
func FakeErrorNew ¶
func FakeErrorNew() *Client
FakeErrorNew returns a fake local client instance that can be used in unit tests to verify errors
func FakeNew ¶
func FakeNew() *Client
FakeNew returns a fake local client instance that can be used in unit tests
func New ¶
New creates a new instances of Docker client, with the minimum API version set to
to the value of MinDockerAPIVersion.
func (*Client) GetContainerList ¶
GetContainerList returns a list of all of the running containers on the user's system
func (*Client) GetContainersByComponent ¶
func (dc *Client) GetContainersByComponent(componentName string, containers []types.Container) []types.Container
GetContainersByComponent returns the list of Docker containers that matches the specified component label If no container with that component exists, it returns an empty list
func (*Client) PullImage ¶
PullImage uses Docker to pull the specified image. If there are any issues pulling the image, it returns an error.
func (*Client) StartContainer ¶
func (dc *Client) StartContainer(containerConfig *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) error
StartContainer takes in a Docker container object and starts it. containerConfig - configurations for the container itself (image name, command, ports, etc) (if needed) hostConfig - configurations related to the host (volume mounts, exposed ports, etc) (if needed) networkingConfig - endpoints to expose (if needed) containerName - name to give to the container Returns an error if the container couldn't be started.
type DockerClient ¶
type DockerClient interface { ImagePull(ctx context.Context, image string, imagePullOptions types.ImagePullOptions) (io.ReadCloser, error) ImageList(ctx context.Context, imageListOptions types.ImageListOptions) ([]types.ImageSummary, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error ContainerList(ctx context.Context, containerListOptions types.ContainerListOptions) ([]types.Container, error) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error) ContainerStop(ctx context.Context, containerID string, timeout *time.Duration) error ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error) }
DockerClient requires functions called on the docker client package By abstracting these functions into an interface, it makes creating mock clients for unit testing much easier