Documentation ¶
Index ¶
- Variables
- func NewMock() (*MockClient, Client)
- type BuildImageOptions
- type Client
- func (dk Client) Build(name, dockerfile string) (id string, err error)
- func (dk Client) ConfigureNetwork(driver string) error
- func (dk Client) Get(id string) (Container, 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) Push(registry, 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)
- type Container
- type ContainerSlice
- type MockClient
- func (dk MockClient) BuildImage(opts dkc.BuildImageOptions) error
- func (dk *MockClient) CreateContainer(opts dkc.CreateContainerOptions) (*dkc.Container, error)
- func (dk MockClient) CreateExec(opts dkc.CreateExecOptions) (*dkc.Exec, error)
- func (dk MockClient) CreateNetwork(opts dkc.CreateNetworkOptions) (*dkc.Network, error)
- func (dk MockClient) DownloadFromContainer(id string, opts dkc.DownloadFromContainerOptions) error
- func (dk MockClient) InspectContainer(id string) (*dkc.Container, error)
- func (dk MockClient) InspectImage(name string) (*dkc.Image, error)
- func (dk MockClient) ListContainers(opts dkc.ListContainersOptions) ([]dkc.APIContainers, error)
- func (dk MockClient) ListNetworks() ([]dkc.Network, error)
- func (dk MockClient) PullImage(opts dkc.PullImageOptions, auth dkc.AuthConfiguration) error
- func (dk MockClient) PushImage(opts dkc.PushImageOptions, _ dkc.AuthConfiguration) error
- func (dk MockClient) RemoveContainer(opts dkc.RemoveContainerOptions) error
- func (dk *MockClient) ResetBuilt()
- 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
- type UploadToContainerOptions
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 BuildImageOptions ¶
type BuildImageOptions struct {
Name, Dockerfile string
}
BuildImageOptions represents the parameters in a call to BuildImage.
type Client ¶
A Client to the local docker daemon.
func (Client) Build ¶
Build builds an image with the given name and Dockerfile, and returns the ID of the resulting image.
func (Client) ConfigureNetwork ¶
ConfigureNetwork makes a request to docker to create a network running on driver.
func (Client) List ¶
List returns a slice of all running containers. The List can be be filtered with the supplied `filters` map.
func (Client) Pull ¶
Pull retrieves the given docker image from an image cache. The `image` argument can be of the form <repo>, <repo>:<tag>, or <repo>:<tag>@<digestFormat>:<digest>. If no tag is specified, then the "latest" tag is applied.
type Container ¶
type Container struct { ID string EID string Name string Image string ImageID string IP string Mac string Path string Status string Args []string Pid int Env map[string]string Labels map[string]string Created time.Time }
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 Built map[BuildImageOptions]struct{} Pulled map[string]struct{} Pushed map[dkc.PushImageOptions]struct{} Containers map[string]mockContainer Networks map[string]*dkc.Network Uploads map[UploadToContainerOptions]struct{} Images map[string]*dkc.Image Executions map[string][]string CreateError bool CreateNetworkError bool ListNetworksError bool CreateExecError bool InspectContainerError bool InspectImageError bool ListError bool BuildError bool PullError bool PushError bool RemoveError bool StartError bool StartExecError bool UploadError bool // contains filtered or unexported fields }
MockClient gives unit testers access to the internals of the mock docker client returned by NewMock.
func (MockClient) BuildImage ¶
func (dk MockClient) BuildImage(opts dkc.BuildImageOptions) error
BuildImage builds the requested image.
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) CreateNetwork ¶
func (dk MockClient) CreateNetwork(opts dkc.CreateNetworkOptions) (*dkc.Network, error)
CreateNetwork creates a network according to opts.
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) InspectImage ¶
func (dk MockClient) InspectImage(name string) (*dkc.Image, error)
InspectImage inspects the requested image.
func (MockClient) ListContainers ¶
func (dk MockClient) ListContainers(opts dkc.ListContainersOptions) ([]dkc.APIContainers, error)
ListContainers lists the running containers.
func (MockClient) ListNetworks ¶
func (dk MockClient) ListNetworks() ([]dkc.Network, error)
ListNetworks lists all networks.
func (MockClient) PullImage ¶
func (dk MockClient) PullImage(opts dkc.PullImageOptions, auth dkc.AuthConfiguration) error
PullImage pulls the requested image.
func (MockClient) PushImage ¶
func (dk MockClient) PushImage(opts dkc.PushImageOptions, _ dkc.AuthConfiguration) error
PushImage pushes the requested image.
func (MockClient) RemoveContainer ¶
func (dk MockClient) RemoveContainer(opts dkc.RemoveContainerOptions) error
RemoveContainer removes the given docker container.
func (*MockClient) ResetBuilt ¶
func (dk *MockClient) ResetBuilt()
ResetBuilt clears the list of built images, for use by the unit tests.
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 extracts a tarball into the given container.
type RunOptions ¶
type RunOptions struct { Name string Image string Args []string Labels map[string]string Env map[string]string FilepathToContent map[string]string IP string NetworkMode string DNS []string DNSSearch []string PidMode string Privileged bool VolumesFrom []string }
RunOptions changes the behavior of the Run function.
type UploadToContainerOptions ¶
type UploadToContainerOptions struct {
ContainerID, UploadPath, TarPath, Contents string
}
UploadToContainerOptions represents the parameters in a call to UploadToContainer.