lclient

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package lclient is a generated GoMock package.

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"
	ProjectSourceVolumeName = "odo-project-source"
)

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

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

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

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

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

func (*Client) ExecCMDInContainer

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

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

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

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

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

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

GetContainerList returns a list of all of the running containers on the user's system

func (*Client) GetContainerLogs

func (dc *Client) GetContainerLogs(containerName string, followLog bool) (io.ReadCloser, error)

DisplayContainerLog prints the log from pod to stdout

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

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) GetVolumes

func (dc *Client) GetVolumes() ([]types.Volume, error)

GetVolumes returns the list of all volumes

func (*Client) GetVolumesByLabel

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

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

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

func (*Client) RemoveVolume

func (dc *Client) RemoveVolume(volumeID string) error

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) (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) Returns containerID of the started container, an error if the container couldn't be started

func (*Client) WaitForContainer

func (dc *Client) WaitForContainer(containerID string, condition container.WaitCondition) error

WaitForContainer waits for the container until the condition is reached

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
	ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, 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

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

MockDockerClient is a mock of DockerClient interface

func NewMockDockerClient

func NewMockDockerClient(ctrl *gomock.Controller) *MockDockerClient

NewMockDockerClient creates a new mock instance

func (*MockDockerClient) ContainerCreate

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

func (m *MockDockerClient) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)

ContainerExecAttach mocks base method

func (*MockDockerClient) ContainerExecCreate

func (m *MockDockerClient) ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)

ContainerExecCreate mocks base method

func (*MockDockerClient) ContainerExecInspect

func (m *MockDockerClient) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)

ContainerExecInspect mocks base method

func (*MockDockerClient) ContainerExecStart

func (m *MockDockerClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error

ContainerExecStart mocks base method

func (*MockDockerClient) ContainerInspect

func (m *MockDockerClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error)

ContainerInspect mocks base method

func (*MockDockerClient) ContainerList

func (m *MockDockerClient) ContainerList(ctx context.Context, containerListOptions types.ContainerListOptions) ([]types.Container, error)

ContainerList mocks base method

func (*MockDockerClient) ContainerLogs

func (m *MockDockerClient) ContainerLogs(ctx context.Context, container string, options types.ContainerLogsOptions) (io.ReadCloser, error)

ContainerLogs mocks base method

func (*MockDockerClient) ContainerRemove

func (m *MockDockerClient) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error

ContainerRemove mocks base method

func (*MockDockerClient) ContainerStart

func (m *MockDockerClient) ContainerStart(ctx context.Context, containerID string, options types.ContainerStartOptions) error

ContainerStart mocks base method

func (*MockDockerClient) ContainerWait

func (m *MockDockerClient) ContainerWait(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.ContainerWaitOKBody, <-chan error)

ContainerWait mocks base method

func (*MockDockerClient) CopyToContainer

func (m *MockDockerClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options types.CopyToContainerOptions) error

CopyToContainer mocks base method

func (*MockDockerClient) DistributionInspect

func (m *MockDockerClient) DistributionInspect(ctx context.Context, image, encodedRegistryAuth string) (registry.DistributionInspect, error)

DistributionInspect mocks base method

func (*MockDockerClient) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDockerClient) ImageList

func (m *MockDockerClient) ImageList(ctx context.Context, imageListOptions types.ImageListOptions) ([]types.ImageSummary, error)

ImageList mocks base method

func (*MockDockerClient) ImagePull

func (m *MockDockerClient) ImagePull(ctx context.Context, image string, imagePullOptions types.ImagePullOptions) (io.ReadCloser, error)

ImagePull mocks base method

func (*MockDockerClient) VolumeCreate

func (m *MockDockerClient) VolumeCreate(ctx context.Context, options volume.VolumeCreateBody) (types.Volume, error)

VolumeCreate mocks base method

func (*MockDockerClient) VolumeList

func (m *MockDockerClient) VolumeList(ctx context.Context, filter filters.Args) (volume.VolumeListOKBody, error)

VolumeList mocks base method

func (*MockDockerClient) VolumeRemove

func (m *MockDockerClient) VolumeRemove(ctx context.Context, volumeID string, force bool) error

VolumeRemove mocks base method

type MockDockerClientMockRecorder

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

MockDockerClientMockRecorder is the mock recorder for MockDockerClient

func (*MockDockerClientMockRecorder) ContainerCreate

func (mr *MockDockerClientMockRecorder) ContainerCreate(ctx, config, hostConfig, networkingConfig, containerName interface{}) *gomock.Call

ContainerCreate indicates an expected call of ContainerCreate

func (*MockDockerClientMockRecorder) ContainerExecAttach

func (mr *MockDockerClientMockRecorder) ContainerExecAttach(ctx, execID, config interface{}) *gomock.Call

ContainerExecAttach indicates an expected call of ContainerExecAttach

func (*MockDockerClientMockRecorder) ContainerExecCreate

func (mr *MockDockerClientMockRecorder) ContainerExecCreate(ctx, container, config interface{}) *gomock.Call

ContainerExecCreate indicates an expected call of ContainerExecCreate

func (*MockDockerClientMockRecorder) ContainerExecInspect

func (mr *MockDockerClientMockRecorder) ContainerExecInspect(ctx, execID interface{}) *gomock.Call

ContainerExecInspect indicates an expected call of ContainerExecInspect

func (*MockDockerClientMockRecorder) ContainerExecStart

func (mr *MockDockerClientMockRecorder) ContainerExecStart(ctx, execID, config interface{}) *gomock.Call

ContainerExecStart indicates an expected call of ContainerExecStart

func (*MockDockerClientMockRecorder) ContainerInspect

func (mr *MockDockerClientMockRecorder) ContainerInspect(ctx, containerID interface{}) *gomock.Call

ContainerInspect indicates an expected call of ContainerInspect

func (*MockDockerClientMockRecorder) ContainerList

func (mr *MockDockerClientMockRecorder) ContainerList(ctx, containerListOptions interface{}) *gomock.Call

ContainerList indicates an expected call of ContainerList

func (*MockDockerClientMockRecorder) ContainerLogs

func (mr *MockDockerClientMockRecorder) ContainerLogs(ctx, container, options interface{}) *gomock.Call

ContainerLogs indicates an expected call of ContainerLogs

func (*MockDockerClientMockRecorder) ContainerRemove

func (mr *MockDockerClientMockRecorder) ContainerRemove(ctx, containerID, options interface{}) *gomock.Call

ContainerRemove indicates an expected call of ContainerRemove

func (*MockDockerClientMockRecorder) ContainerStart

func (mr *MockDockerClientMockRecorder) ContainerStart(ctx, containerID, options interface{}) *gomock.Call

ContainerStart indicates an expected call of ContainerStart

func (*MockDockerClientMockRecorder) ContainerWait

func (mr *MockDockerClientMockRecorder) ContainerWait(ctx, containerID, condition interface{}) *gomock.Call

ContainerWait indicates an expected call of ContainerWait

func (*MockDockerClientMockRecorder) CopyToContainer

func (mr *MockDockerClientMockRecorder) CopyToContainer(ctx, container, path, content, options interface{}) *gomock.Call

CopyToContainer indicates an expected call of CopyToContainer

func (*MockDockerClientMockRecorder) DistributionInspect

func (mr *MockDockerClientMockRecorder) DistributionInspect(ctx, image, encodedRegistryAuth interface{}) *gomock.Call

DistributionInspect indicates an expected call of DistributionInspect

func (*MockDockerClientMockRecorder) ImageList

func (mr *MockDockerClientMockRecorder) ImageList(ctx, imageListOptions interface{}) *gomock.Call

ImageList indicates an expected call of ImageList

func (*MockDockerClientMockRecorder) ImagePull

func (mr *MockDockerClientMockRecorder) ImagePull(ctx, image, imagePullOptions interface{}) *gomock.Call

ImagePull indicates an expected call of ImagePull

func (*MockDockerClientMockRecorder) VolumeCreate

func (mr *MockDockerClientMockRecorder) VolumeCreate(ctx, options interface{}) *gomock.Call

VolumeCreate indicates an expected call of VolumeCreate

func (*MockDockerClientMockRecorder) VolumeList

func (mr *MockDockerClientMockRecorder) VolumeList(ctx, filter interface{}) *gomock.Call

VolumeList indicates an expected call of VolumeList

func (*MockDockerClientMockRecorder) VolumeRemove

func (mr *MockDockerClientMockRecorder) VolumeRemove(ctx, volumeID, force interface{}) *gomock.Call

VolumeRemove indicates an expected call of VolumeRemove

Jump to

Keyboard shortcuts

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