Documentation ¶
Index ¶
- Constants
- type Client
- func (dc *Client) CreateVolume(labels map[string]string) (types.Volume, error)
- func (dc *Client) GenerateContainerConfig(image string, entrypoint []string, cmd []string, envVars []string, ...) container.Config
- func (dc *Client) GenerateHostConfig(isPrivileged bool, publishPorts bool) container.HostConfig
- func (dc *Client) GetContainerConfig(containerID string) (*container.Config, error)
- func (dc *Client) GetContainerList() ([]types.Container, error)
- func (dc *Client) GetContainersByComponent(componentName string, containers []types.Container) []types.Container
- func (dc *Client) GetContainersByComponentAndAlias(componentName string, alias string) ([]types.Container, error)
- func (dc *Client) GetVolumesByLabel(labels map[string]string) ([]types.Volume, error)
- func (dc *Client) PullImage(image string) error
- func (dc *Client) RemoveContainer(containerID 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 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 ¶
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
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
GetContainerConfig takes in a given container ID and retrieves its corresponding container config
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) 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
GetVolumesByLabel returns the list of all volumes matching the given label.
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) RemoveContainer ¶ added in v1.1.3
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