Documentation
¶
Index ¶
- Variables
- func NewMock() (*MockClient, Client)
- type Client
- func (dk Client) Exec(name string, cmd ...string) error
- func (dk Client) ExecVerbose(name string, cmd ...string) ([]byte, error)
- func (dk Client) Get(id string) (Container, error)
- func (dk Client) GetFromContainer(id string, src string) (string, error)
- func (dk Client) IsRunning(name string) (bool, error)
- func (dk Client) List(filters map[string][]string) ([]Container, error)
- func (dk Client) Pull(image string) error
- func (dk Client) Remove(name string) error
- func (dk Client) RemoveID(id string) error
- func (dk Client) Run(opts RunOptions) (string, error)
- func (dk Client) WriteToContainer(id, src, dst, archiveName string, permission int) error
- type Container
- type ContainerSlice
- type MockClient
- func (dk *MockClient) CreateContainer(opts dkc.CreateContainerOptions) (*dkc.Container, error)
- func (dk MockClient) CreateExec(opts dkc.CreateExecOptions) (*dkc.Exec, error)
- func (dk MockClient) DownloadFromContainer(id string, opts dkc.DownloadFromContainerOptions) error
- func (dk MockClient) InspectContainer(id string) (*dkc.Container, error)
- func (dk MockClient) ListContainers(opts dkc.ListContainersOptions) ([]dkc.APIContainers, error)
- func (dk MockClient) PullImage(opts dkc.PullImageOptions, auth dkc.AuthConfiguration) error
- func (dk MockClient) RemoveContainer(opts dkc.RemoveContainerOptions) error
- func (dk *MockClient) ResetExec()
- func (dk MockClient) StartContainer(id string, hostConfig *dkc.HostConfig) error
- func (dk MockClient) StartExec(id string, opts dkc.StartExecOptions) error
- func (dk MockClient) StopContainer(id string)
- func (dk MockClient) UploadToContainer(id string, opts dkc.UploadToContainerOptions) error
- type RunOptions
Constants ¶
This section is empty.
Variables ¶
var ErrNoSuchContainer = errors.New("container does not exist")
ErrNoSuchContainer is the error returned when an operation is requested on a non-existent container.
Functions ¶
func NewMock ¶
func NewMock() (*MockClient, Client)
NewMock creates a mock docker client suitable for use in unit tests, and a MockClient that allows testers to manipulate it's behavior.
Types ¶
type Client ¶
A Client to the local docker daemon.
func (Client) ExecVerbose ¶
ExecVerbose executes a command within the container with the supplied name. It also returns the output of that command.
func (Client) GetFromContainer ¶
GetFromContainer returns a string containing the content of the file named SRC on the container with id ID.
func (Client) List ¶
List returns a slice of all running containers. The List can be be filtered with the supplied `filters` map.
type Container ¶
type Container struct { ID string Name string Image string IP string Path string Args []string Pid int Env map[string]string Labels map[string]string }
A Container as returned by the docker client API.
type ContainerSlice ¶
type ContainerSlice []Container
ContainerSlice is an alias for []Container to allow for joins
func (ContainerSlice) Get ¶
func (cs ContainerSlice) Get(ii int) interface{}
Get returns the value contained at the given index
func (ContainerSlice) Len ¶
func (cs ContainerSlice) Len() int
Len returns the number of items in the slice
type MockClient ¶
type MockClient struct { *sync.Mutex Pulled map[string]struct{} Containers map[string]mockContainer Executions map[string][]string CreateError bool CreateExecError bool InspectError bool ListError bool PullError bool RemoveError bool StartError bool StartExecError bool // contains filtered or unexported fields }
MockClient gives unit testers access to the internals of the mock docker client returned by NewMock.
func (*MockClient) CreateContainer ¶
func (dk *MockClient) CreateContainer(opts dkc.CreateContainerOptions) (*dkc.Container, error)
CreateContainer creates a container in accordance with the supplied options.
func (MockClient) CreateExec ¶
func (dk MockClient) CreateExec(opts dkc.CreateExecOptions) (*dkc.Exec, error)
CreateExec creates an execution option to be started by StartExec.
func (MockClient) DownloadFromContainer ¶
func (dk MockClient) DownloadFromContainer(id string, opts dkc.DownloadFromContainerOptions) error
DownloadFromContainer is not implemented.
func (MockClient) InspectContainer ¶
func (dk MockClient) InspectContainer(id string) (*dkc.Container, error)
InspectContainer returns details of the specified container.
func (MockClient) ListContainers ¶
func (dk MockClient) ListContainers(opts dkc.ListContainersOptions) ([]dkc.APIContainers, error)
ListContainers lists the running containers.
func (MockClient) PullImage ¶
func (dk MockClient) PullImage(opts dkc.PullImageOptions, auth dkc.AuthConfiguration) error
PullImage pulls the requested image.
func (MockClient) RemoveContainer ¶
func (dk MockClient) RemoveContainer(opts dkc.RemoveContainerOptions) error
RemoveContainer removes the given docker container.
func (*MockClient) ResetExec ¶
func (dk *MockClient) ResetExec()
ResetExec clears the list of created and started executions, for use by the unit tests.
func (MockClient) StartContainer ¶
func (dk MockClient) StartContainer(id string, hostConfig *dkc.HostConfig) error
StartContainer starts the given docker container.
func (MockClient) StartExec ¶
func (dk MockClient) StartExec(id string, opts dkc.StartExecOptions) error
StartExec starts the supplied execution object.
func (MockClient) StopContainer ¶
func (dk MockClient) StopContainer(id string)
StopContainer stops the given docker container.
func (MockClient) UploadToContainer ¶
func (dk MockClient) UploadToContainer(id string, opts dkc.UploadToContainerOptions) error
UploadToContainer is not implemented.