Documentation ¶
Index ¶
- Constants
- Variables
- func CreateClientOpts(env func(string) string) ([]func(client *client.Client) error, error)
- func IsExitError(err error) bool
- func NewFakeDockerResponse(contents string) fakeDockerResponse
- type DockerCli
- func (d *DockerCli) ContainerRestartNoWait(ctx context.Context, containerID string) error
- func (d *DockerCli) CopyToContainerRoot(ctx context.Context, container string, content io.Reader) error
- func (d *DockerCli) ExecInContainer(ctx context.Context, cID k8s.ContainerID, cmd model.Cmd, out io.Writer) error
- type DockerClient
- type ExecCall
- type ExitError
- type FakeDockerClient
- func (c *FakeDockerClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
- func (c *FakeDockerClient) ContainerRestartNoWait(ctx context.Context, containerID string) error
- func (c *FakeDockerClient) CopyToContainerRoot(ctx context.Context, container string, content io.Reader) error
- func (c *FakeDockerClient) ExecInContainer(ctx context.Context, cID k8s.ContainerID, cmd model.Cmd, out io.Writer) error
- func (c *FakeDockerClient) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
- func (c *FakeDockerClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
- func (c *FakeDockerClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
- func (c *FakeDockerClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error)
- func (c *FakeDockerClient) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
- func (c *FakeDockerClient) ImageTag(ctx context.Context, source, target string) error
- func (c *FakeDockerClient) SetContainerListOutput(output map[string][]types.Container)
- func (c *FakeDockerClient) SetDefaultContainerListOutput()
- type ImgNameAndTag
Constants ¶
View Source
const ( TestPod = "test_pod" TestContainer = "test_container" )
View Source
const ExampleBuildOutput1 = `` /* 277-byte string literal not displayed */
View Source
const ExampleBuildSHA1 = "sha256:11cd0b38bc3ceb958ffb2f9bd70be3fb317ce7d255c8a4c3f4af30e298aa1aab"
View Source
const ExamplePushSHA1 = "sha256:cc5f4c463f81c55183d8d737ba2f0d30b3e6f3670dbe2da68f0aac168e93fbb1"
Variables ¶
View Source
var DefaultContainerListOutput = map[string][]types.Container{ TestPod: []types.Container{ types.Container{ID: TestContainer, ImageID: ExampleBuildSHA1, Command: "./stuff"}, }, "two-containers": []types.Container{ types.Container{ID: "not a match", ImageID: ExamplePushSHA1, Command: "/pause"}, types.Container{ID: "the right container", ImageID: ExampleBuildSHA1, Command: "./stuff"}, }, }
View Source
var ExamplePushOutput1 = `` /* 1660-byte string literal not displayed */
Functions ¶
func CreateClientOpts ¶
Adapted from client.FromEnv
Supported environment variables: DOCKER_HOST to set the url to the docker server. DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest. DOCKER_CERT_PATH to load the TLS certificates from. DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.
func IsExitError ¶
func NewFakeDockerResponse ¶
func NewFakeDockerResponse(contents string) fakeDockerResponse
Types ¶
type DockerCli ¶
func DefaultDockerClient ¶
func (*DockerCli) ContainerRestartNoWait ¶
func (*DockerCli) CopyToContainerRoot ¶
type DockerClient ¶
type DockerClient interface { ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) ContainerRestartNoWait(ctx context.Context, containerID string) error CopyToContainerRoot(ctx context.Context, container string, content io.Reader) error // Execute a command in a container, streaming the command output to `out`. // Returns an ExitError if the command exits with a non-zero exit code. ExecInContainer(ctx context.Context, cID k8s.ContainerID, cmd model.Cmd, out io.Writer) error ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) ImageTag(ctx context.Context, source, target string) error ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) }
Create an interface so this can be mocked out.
type FakeDockerClient ¶
type FakeDockerClient struct { PushCount int PushImage string PushOptions types.ImagePushOptions PushOutput string BuildCount int BuildOptions types.ImageBuildOptions BuildOutput string TagCount int TagSource string TagTarget string ContainerListOutput map[string][]types.Container CopyCount int CopyContainer string CopyContent io.Reader ExecCalls []ExecCall ExecErrorToThrow error // next call to Exec will throw this err (after which we clear the error) RestartsByContainer map[string]int RemovedImageIDs []string }
func NewFakeDockerClient ¶
func NewFakeDockerClient() *FakeDockerClient
func (*FakeDockerClient) ContainerList ¶
func (c *FakeDockerClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
func (*FakeDockerClient) ContainerRestartNoWait ¶
func (c *FakeDockerClient) ContainerRestartNoWait(ctx context.Context, containerID string) error
func (*FakeDockerClient) CopyToContainerRoot ¶
func (*FakeDockerClient) ExecInContainer ¶
func (c *FakeDockerClient) ExecInContainer(ctx context.Context, cID k8s.ContainerID, cmd model.Cmd, out io.Writer) error
func (*FakeDockerClient) ImageBuild ¶
func (c *FakeDockerClient) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
func (*FakeDockerClient) ImageInspectWithRaw ¶
func (c *FakeDockerClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
func (*FakeDockerClient) ImageList ¶
func (c *FakeDockerClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
func (*FakeDockerClient) ImagePush ¶
func (c *FakeDockerClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error)
func (*FakeDockerClient) ImageRemove ¶
func (c *FakeDockerClient) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
func (*FakeDockerClient) ImageTag ¶
func (c *FakeDockerClient) ImageTag(ctx context.Context, source, target string) error
func (*FakeDockerClient) SetContainerListOutput ¶
func (c *FakeDockerClient) SetContainerListOutput(output map[string][]types.Container)
func (*FakeDockerClient) SetDefaultContainerListOutput ¶
func (c *FakeDockerClient) SetDefaultContainerListOutput()
type ImgNameAndTag ¶
For use storing reference.NamedTagged as a map key, since we can't rely on the two different underlying representations the same name+tag combo being equivalent.
func ToImgNameAndTag ¶
func ToImgNameAndTag(nt reference.NamedTagged) ImgNameAndTag
Click to show internal directories.
Click to hide internal directories.