Documentation ¶
Overview ¶
Package docker implements runtime.Interface and runtime.Config interfaces by talking to Docker API.
Index ¶
- type Client
- type Config
- type FakeClient
- func (f *FakeClient) ContainerCreate(ctx context.Context, config *containertypes.Config, ...) (containertypes.ContainerCreateCreatedBody, error)
- func (f *FakeClient) ContainerInspect(ctx context.Context, container string) (dockertypes.ContainerJSON, error)
- func (f *FakeClient) ContainerRemove(ctx context.Context, container string, ...) error
- func (f *FakeClient) ContainerStart(ctx context.Context, container string, ...) error
- func (f *FakeClient) ContainerStatPath(ctx context.Context, container, path string) (dockertypes.ContainerPathStat, error)
- func (f *FakeClient) ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
- func (f *FakeClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, dockertypes.ContainerPathStat, error)
- func (f *FakeClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, ...) error
- func (f *FakeClient) ImageList(ctx context.Context, options dockertypes.ImageListOptions) ([]dockertypes.ImageSummary, error)
- func (f *FakeClient) ImagePull(ctx context.Context, ref string, options dockertypes.ImagePullOptions) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.8.0
type Client interface { ContainerCreate( ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, platform *v1.Platform, containerName string, ) (containertypes.ContainerCreateCreatedBody, error) ContainerStart(ctx context.Context, container string, options dockertypes.ContainerStartOptions) error ContainerStop(ctx context.Context, container string, timeout *time.Duration) error ContainerInspect(ctx context.Context, container string) (dockertypes.ContainerJSON, error) ContainerRemove(ctx context.Context, container string, options dockertypes.ContainerRemoveOptions) error CopyFromContainer( ctx context.Context, container, srcPath string, ) (io.ReadCloser, dockertypes.ContainerPathStat, error) CopyToContainer( ctx context.Context, container, path string, content io.Reader, options dockertypes.CopyToContainerOptions, ) error ContainerStatPath(ctx context.Context, container, path string) (dockertypes.ContainerPathStat, error) ImageList(ctx context.Context, options dockertypes.ImageListOptions) ([]dockertypes.ImageSummary, error) ImagePull(ctx context.Context, ref string, options dockertypes.ImagePullOptions) (io.ReadCloser, error) }
Client is a wrapper interface over https://godoc.org/github.com/docker/docker/client#ContainerAPIClient with the functions we use.
type Config ¶
type Config struct { // Host is a Docker runtime URL. Usually 'unix:///run/docker.sock'. If empty // Docker's default URL will be used. Host string `json:"host,omitempty"` // ClientGetter allows to use custom Docker client. ClientGetter func(...client.Opt) (Client, error) `json:"-"` }
Config struct represents Docker container runtime configuration.
func DefaultConfig ¶ added in v0.2.0
func DefaultConfig() *Config
DefaultConfig returns Docker's runtime default configuration.
func (*Config) GetAddress ¶
GetAddress returns configured container runtime address.
func (*Config) New ¶
New validates Docker runtime configuration and returns configured runtime client.
func (*Config) SetAddress ¶
SetAddress sets runtime config address where it should connect.
type FakeClient ¶ added in v0.2.0
type FakeClient struct { // ContainerCreateF will be called by ContainerCreate. ContainerCreateF func( ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, platform *v1.Platform, containerName string, ) (containertypes.ContainerCreateCreatedBody, error) // ContainerStartF will be called by ContainerStart. ContainerStartF func(ctx context.Context, container string, options dockertypes.ContainerStartOptions) error // ContainerStopF will be called by ContainerStop. ContainerStopF func(ctx context.Context, container string, timeout *time.Duration) error // ContainerInspectF will be called by ContainerInspect. ContainerInspectF func(ctx context.Context, container string) (dockertypes.ContainerJSON, error) // ContainerRemoveF will be called by ContainerRemove. ContainerRemoveF func(ctx context.Context, container string, options dockertypes.ContainerRemoveOptions) error // CopyFromContainerF will be called by CopyFromContainer. CopyFromContainerF func( ctx context.Context, container string, srcPath string, ) (io.ReadCloser, dockertypes.ContainerPathStat, error) // CopyToContainerF will be called by CopyToContainer. CopyToContainerF func( ctx context.Context, container, path string, content io.Reader, options dockertypes.CopyToContainerOptions, ) error // ContainerStatPathF will be called by ContainerStatPath. ContainerStatPathF func(ctx context.Context, container, path string) (dockertypes.ContainerPathStat, error) // ImageListF will be called by ImageList. ImageListF func(ctx context.Context, options dockertypes.ImageListOptions) ([]dockertypes.ImageSummary, error) // ImagePullF will be called by ImagePull. ImagePullF func(ctx context.Context, ref string, options dockertypes.ImagePullOptions) (io.ReadCloser, error) }
FakeClient is a mock of Docker client, which should be used only for testing.
func (*FakeClient) ContainerCreate ¶ added in v0.2.0
func (f *FakeClient) ContainerCreate( ctx context.Context, config *containertypes.Config, hostConfig *containertypes.HostConfig, networkingConfig *networktypes.NetworkingConfig, platform *v1.Platform, containerName string, ) (containertypes.ContainerCreateCreatedBody, error)
ContainerCreate mocks Docker client ContainerCreate().
func (*FakeClient) ContainerInspect ¶ added in v0.2.0
func (f *FakeClient) ContainerInspect(ctx context.Context, container string) (dockertypes.ContainerJSON, error)
ContainerInspect mocks Docker client ContainerInspect().
func (*FakeClient) ContainerRemove ¶ added in v0.2.0
func (f *FakeClient) ContainerRemove( ctx context.Context, container string, options dockertypes.ContainerRemoveOptions, ) error
ContainerRemove mocks Docker client ContainerRemove().
func (*FakeClient) ContainerStart ¶ added in v0.2.0
func (f *FakeClient) ContainerStart( ctx context.Context, container string, options dockertypes.ContainerStartOptions, ) error
ContainerStart mocks Docker client ContainerStart().
func (*FakeClient) ContainerStatPath ¶ added in v0.2.0
func (f *FakeClient) ContainerStatPath( ctx context.Context, container, path string, ) (dockertypes.ContainerPathStat, error)
ContainerStatPath mocks Docker client ContainerStatPath().
func (*FakeClient) ContainerStop ¶ added in v0.2.0
func (f *FakeClient) ContainerStop(ctx context.Context, container string, timeout *time.Duration) error
ContainerStop mocks Docker client ContainerStop().
func (*FakeClient) CopyFromContainer ¶ added in v0.2.0
func (f *FakeClient) CopyFromContainer( ctx context.Context, container, srcPath string, ) (io.ReadCloser, dockertypes.ContainerPathStat, error)
CopyFromContainer mocks Docker client CopyFromContainer().
func (*FakeClient) CopyToContainer ¶ added in v0.2.0
func (f *FakeClient) CopyToContainer( ctx context.Context, container, path string, content io.Reader, options dockertypes.CopyToContainerOptions, ) error
CopyToContainer mocks Docker client CopyToContainer().
func (*FakeClient) ImageList ¶ added in v0.2.0
func (f *FakeClient) ImageList( ctx context.Context, options dockertypes.ImageListOptions, ) ([]dockertypes.ImageSummary, error)
ImageList mocks Docker client ImageList().
func (*FakeClient) ImagePull ¶ added in v0.2.0
func (f *FakeClient) ImagePull( ctx context.Context, ref string, options dockertypes.ImagePullOptions, ) (io.ReadCloser, error)
ImagePull mocks Docker client ImagePull().