lclient

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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 to support most systems
	DockerStorageDriver  = ""
	OdoSourceVolumeMount = "/projects"
)

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

func New() (*Client, error)

New creates a new instances of Docker client, with the minimum API version set to

to the value of MinDockerAPIVersion.

func (*Client) CreateVolume added in v1.1.3

func (dc *Client) CreateVolume(labels map[string]string) (types.Volume, error)

CreateVolume creates a Docker volume with the given labels and the default Docker storage driver

func (*Client) GenerateContainerConfig added in v1.1.3

func (dc *Client) GenerateContainerConfig(image string, entrypoint []string, cmd []string, envVars []string, labels map[string]string) container.Config

GenerateContainerConfig creates a containerConfig resource that can be used to create a local Docker container

func (*Client) GenerateHostConfig added in v1.1.3

func (dc *Client) GenerateHostConfig(isPrivileged bool, publishPorts bool) container.HostConfig

func (*Client) GetContainerConfig added in v1.1.3

func (dc *Client) GetContainerConfig(containerID string) (*container.Config, error)

GetContainerConfig takes in a given container ID and retrieves its corresponding container config

func (*Client) GetContainerList

func (dc *Client) GetContainerList() ([]types.Container, error)

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) GetContainersByComponentAndAlias added in v1.1.3

func (dc *Client) GetContainersByComponentAndAlias(componentName string, alias string) ([]types.Container, error)

GetContainersByComponentAndAlias returns the list of Docker containers that have the same component and alias labeled

func (*Client) GetVolumesByLabel added in v1.1.3

func (dc *Client) GetVolumesByLabel(labels map[string]string) ([]types.Volume, error)

GetVolumesByLabel returns the list of all volumes matching the given label.

func (*Client) PullImage

func (dc *Client) PullImage(image string) error

PullImage uses Docker to pull the specified image. If there are any issues pulling the image, it returns an error.

func (*Client) RemoveContainer added in v1.1.3

func (dc *Client) RemoveContainer(containerID string) error

RemoveContainer takes in a given container ID and kills it, then removes it.

func (*Client) StartContainer

func (dc *Client) StartContainer(containerConfig *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig) 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) 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)
	ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
	DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
	VolumeCreate(ctx context.Context, options volumeTypes.VolumeCreateBody) (types.Volume, error)
	VolumeList(ctx context.Context, filter filters.Args) (volumeTypes.VolumeListOKBody, 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

Jump to

Keyboard shortcuts

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