Documentation ¶
Overview ¶
Package lclient is a generated GoMock package.
Index ¶
- Constants
- func FakeNewMockClient(ctrl *gomock.Controller) (*Client, *MockDockerClient)
- type Client
- func (dc *Client) CreateVolume(name string, labels map[string]string) (types.Volume, error)
- func (dc *Client) ExecCMDInContainer(compInfo common.ComponentInfo, cmd []string, stdout io.Writer, ...) error
- func (dc *Client) ExtractProjectToComponent(compInfo common.ComponentInfo, targetPath string, stdin io.Reader) error
- func (dc *Client) GenerateContainerConfig(image string, entrypoint []string, cmd []string, envVars []string, ...) container.Config
- func (dc *Client) GenerateHostConfig(isPrivileged bool, publishPorts bool, portmap nat.PortMap) container.HostConfig
- func (dc *Client) GetContainerConfigHostConfigAndMounts(containerID string) (*container.Config, *container.HostConfig, []types.MountPoint, 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) RemoveVolume(volumeID string) error
- func (dc *Client) StartContainer(containerConfig *container.Config, hostConfig *container.HostConfig, ...) error
- type DockerClient
- type MockDockerClient
- func (m *MockDockerClient) ContainerCreate(ctx context.Context, config *container.Config, ...) (container.ContainerCreateCreatedBody, error)
- func (m *MockDockerClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
- func (m *MockDockerClient) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
- func (m *MockDockerClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
- func (m *MockDockerClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
- func (m *MockDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
- func (m *MockDockerClient) ContainerList(ctx context.Context, containerListOptions types.ContainerListOptions) ([]types.Container, error)
- func (m *MockDockerClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
- func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error
- func (m *MockDockerClient) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error)
- func (m *MockDockerClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, ...) error
- func (m *MockDockerClient) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
- func (m *MockDockerClient) EXPECT() *MockDockerClientMockRecorder
- func (m *MockDockerClient) ImageList(ctx context.Context, imageListOptions types.ImageListOptions) ([]types.ImageSummary, error)
- func (m *MockDockerClient) ImagePull(ctx context.Context, image string, imagePullOptions types.ImagePullOptions) (io.ReadCloser, error)
- func (m *MockDockerClient) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error)
- func (m *MockDockerClient) VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)
- func (m *MockDockerClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error
- type MockDockerClientMockRecorder
- func (mr *MockDockerClientMockRecorder) ContainerCreate(ctx, config, hostConfig, networkingConfig, containerName interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerExecAttach(ctx, execID, config interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerExecCreate(ctx, container, config interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerExecInspect(ctx, execID interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerExecStart(ctx, execID, config interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerInspect(ctx, containerID interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerList(ctx, containerListOptions interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerRemove(ctx, containerID, options interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerStart(ctx, containerID, options interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ContainerWait(ctx, containerID, condition interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) CopyToContainer(ctx, container, path, content, options interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) DistributionInspect(ctx, image, encodedRegistryAuth interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ImageList(ctx, imageListOptions interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) ImagePull(ctx, image, imagePullOptions interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) VolumeCreate(ctx, options interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) VolumeList(ctx, filter interface{}) *gomock.Call
- func (mr *MockDockerClientMockRecorder) VolumeRemove(ctx, volumeID, force interface{}) *gomock.Call
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 ¶
func FakeNewMockClient ¶ added in v1.2.0
func FakeNewMockClient(ctrl *gomock.Controller) (*Client, *MockDockerClient)
FakeNewMockClient returns a fake local client instance that can be used in unit tests To regenerate the mock file, in the same directory as mock_client.go, run: 'mockgen -source=client.go -package=lclient DockerClient > /tmp/mock_client.go ; cp /tmp/mock_client.go ./mock_client.go'
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) ExecCMDInContainer ¶ added in v1.2.0
func (dc *Client) ExecCMDInContainer(compInfo common.ComponentInfo, cmd []string, stdout io.Writer, stderr io.Writer, stdin io.Reader, tty bool) error
ExecCMDInContainer executes the command in the container with containerID
func (*Client) ExtractProjectToComponent ¶ added in v1.2.0
func (dc *Client) ExtractProjectToComponent(compInfo common.ComponentInfo, targetPath string, stdin io.Reader) error
ExtractProjectToComponent extracts the project archive(tar) to the target path from the reader stdin
func (*Client) GenerateContainerConfig ¶ added in v1.1.3
func (dc *Client) GenerateContainerConfig(image string, entrypoint []string, cmd []string, envVars []string, labels map[string]string, ports nat.PortSet) 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, portmap nat.PortMap) container.HostConfig
GenerateHostConfig creates a HostConfig resource that can be used to create a local Docker container
func (*Client) GetContainerConfigHostConfigAndMounts ¶ added in v1.2.0
func (dc *Client) GetContainerConfigHostConfigAndMounts(containerID string) (*container.Config, *container.HostConfig, []types.MountPoint, error)
GetContainerConfigHostConfigAndMounts takes in a given container ID and retrieves its corresponding container config, host config and mounts
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) RemoveVolume ¶ added in v1.2.0
RemoveVolume removes a volume with the specified volume ID
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) VolumeRemove(ctx context.Context, volumeID string, force bool) error ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) 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
type MockDockerClient ¶ added in v1.2.0
type MockDockerClient struct {
// contains filtered or unexported fields
}
MockDockerClient is a mock of DockerClient interface
func NewMockDockerClient ¶ added in v1.2.0
func NewMockDockerClient(ctrl *gomock.Controller) *MockDockerClient
NewMockDockerClient creates a new mock instance
func (*MockDockerClient) ContainerCreate ¶ added in v1.2.0
func (m *MockDockerClient) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, containerName string) (container.ContainerCreateCreatedBody, error)
ContainerCreate mocks base method
func (*MockDockerClient) ContainerExecAttach ¶ added in v1.2.0
func (m *MockDockerClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
ContainerExecAttach mocks base method
func (*MockDockerClient) ContainerExecCreate ¶ added in v1.2.0
func (m *MockDockerClient) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
ContainerExecCreate mocks base method
func (*MockDockerClient) ContainerExecInspect ¶ added in v1.2.0
func (m *MockDockerClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
ContainerExecInspect mocks base method
func (*MockDockerClient) ContainerExecStart ¶ added in v1.2.0
func (m *MockDockerClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
ContainerExecStart mocks base method
func (*MockDockerClient) ContainerInspect ¶ added in v1.2.0
func (m *MockDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)
ContainerInspect mocks base method
func (*MockDockerClient) ContainerList ¶ added in v1.2.0
func (m *MockDockerClient) ContainerList(ctx context.Context, containerListOptions types.ContainerListOptions) ([]types.Container, error)
ContainerList mocks base method
func (*MockDockerClient) ContainerRemove ¶ added in v1.2.0
func (m *MockDockerClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error
ContainerRemove mocks base method
func (*MockDockerClient) ContainerStart ¶ added in v1.2.0
func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error
ContainerStart mocks base method
func (*MockDockerClient) ContainerWait ¶ added in v1.2.0
func (m *MockDockerClient) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error)
ContainerWait mocks base method
func (*MockDockerClient) CopyToContainer ¶ added in v1.2.0
func (m *MockDockerClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error
CopyToContainer mocks base method
func (*MockDockerClient) DistributionInspect ¶ added in v1.2.0
func (m *MockDockerClient) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)
DistributionInspect mocks base method
func (*MockDockerClient) EXPECT ¶ added in v1.2.0
func (m *MockDockerClient) EXPECT() *MockDockerClientMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockDockerClient) ImageList ¶ added in v1.2.0
func (m *MockDockerClient) ImageList(ctx context.Context, imageListOptions types.ImageListOptions) ([]types.ImageSummary, error)
ImageList mocks base method
func (*MockDockerClient) ImagePull ¶ added in v1.2.0
func (m *MockDockerClient) ImagePull(ctx context.Context, image string, imagePullOptions types.ImagePullOptions) (io.ReadCloser, error)
ImagePull mocks base method
func (*MockDockerClient) VolumeCreate ¶ added in v1.2.0
func (m *MockDockerClient) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error)
VolumeCreate mocks base method
func (*MockDockerClient) VolumeList ¶ added in v1.2.0
func (m *MockDockerClient) VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)
VolumeList mocks base method
func (*MockDockerClient) VolumeRemove ¶ added in v1.2.0
VolumeRemove mocks base method
type MockDockerClientMockRecorder ¶ added in v1.2.0
type MockDockerClientMockRecorder struct {
// contains filtered or unexported fields
}
MockDockerClientMockRecorder is the mock recorder for MockDockerClient
func (*MockDockerClientMockRecorder) ContainerCreate ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerCreate(ctx, config, hostConfig, networkingConfig, containerName interface{}) *gomock.Call
ContainerCreate indicates an expected call of ContainerCreate
func (*MockDockerClientMockRecorder) ContainerExecAttach ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerExecAttach(ctx, execID, config interface{}) *gomock.Call
ContainerExecAttach indicates an expected call of ContainerExecAttach
func (*MockDockerClientMockRecorder) ContainerExecCreate ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerExecCreate(ctx, container, config interface{}) *gomock.Call
ContainerExecCreate indicates an expected call of ContainerExecCreate
func (*MockDockerClientMockRecorder) ContainerExecInspect ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerExecInspect(ctx, execID interface{}) *gomock.Call
ContainerExecInspect indicates an expected call of ContainerExecInspect
func (*MockDockerClientMockRecorder) ContainerExecStart ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerExecStart(ctx, execID, config interface{}) *gomock.Call
ContainerExecStart indicates an expected call of ContainerExecStart
func (*MockDockerClientMockRecorder) ContainerInspect ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerInspect(ctx, containerID interface{}) *gomock.Call
ContainerInspect indicates an expected call of ContainerInspect
func (*MockDockerClientMockRecorder) ContainerList ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerList(ctx, containerListOptions interface{}) *gomock.Call
ContainerList indicates an expected call of ContainerList
func (*MockDockerClientMockRecorder) ContainerRemove ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerRemove(ctx, containerID, options interface{}) *gomock.Call
ContainerRemove indicates an expected call of ContainerRemove
func (*MockDockerClientMockRecorder) ContainerStart ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerStart(ctx, containerID, options interface{}) *gomock.Call
ContainerStart indicates an expected call of ContainerStart
func (*MockDockerClientMockRecorder) ContainerWait ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ContainerWait(ctx, containerID, condition interface{}) *gomock.Call
ContainerWait indicates an expected call of ContainerWait
func (*MockDockerClientMockRecorder) CopyToContainer ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) CopyToContainer(ctx, container, path, content, options interface{}) *gomock.Call
CopyToContainer indicates an expected call of CopyToContainer
func (*MockDockerClientMockRecorder) DistributionInspect ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) DistributionInspect(ctx, image, encodedRegistryAuth interface{}) *gomock.Call
DistributionInspect indicates an expected call of DistributionInspect
func (*MockDockerClientMockRecorder) ImageList ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ImageList(ctx, imageListOptions interface{}) *gomock.Call
ImageList indicates an expected call of ImageList
func (*MockDockerClientMockRecorder) ImagePull ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) ImagePull(ctx, image, imagePullOptions interface{}) *gomock.Call
ImagePull indicates an expected call of ImagePull
func (*MockDockerClientMockRecorder) VolumeCreate ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) VolumeCreate(ctx, options interface{}) *gomock.Call
VolumeCreate indicates an expected call of VolumeCreate
func (*MockDockerClientMockRecorder) VolumeList ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) VolumeList(ctx, filter interface{}) *gomock.Call
VolumeList indicates an expected call of VolumeList
func (*MockDockerClientMockRecorder) VolumeRemove ¶ added in v1.2.0
func (mr *MockDockerClientMockRecorder) VolumeRemove(ctx, volumeID, force interface{}) *gomock.Call
VolumeRemove indicates an expected call of VolumeRemove