Documentation ¶
Index ¶
- Constants
- Variables
- func CreateClientOpts(ctx context.Context, env Env) ([]func(client *client.Client) error, error)
- func IsExitError(err error) bool
- func NegotiateAPIVersion(ctx context.Context) func(client *client.Client) error
- func NewFakeDockerResponse(contents string) fakeDockerResponse
- func ProvideSwitchCli(clusterCli ClusterClient, localCli LocalClient) *switchCli
- func SupportedVersion(v types.Version) bool
- func SupportsBuildkit(v types.Version, env k8s.Env) bool
- type BuildOptions
- type Cli
- func (c *Cli) BuilderVersion() types.BuilderVersion
- func (c *Cli) ContainerRestartNoWait(ctx context.Context, containerID string) error
- func (c *Cli) CopyToContainerRoot(ctx context.Context, container string, content io.Reader) error
- func (c *Cli) Env() Env
- func (c *Cli) ExecInContainer(ctx context.Context, cID container.ID, cmd model.Cmd, out io.Writer) error
- func (c *Cli) ImageBuild(ctx context.Context, buildContext io.Reader, options BuildOptions) (types.ImageBuildResponse, error)
- func (c *Cli) ServerVersion() types.Version
- func (c *Cli) SetOrchestrator(orc model.Orchestrator)
- type Client
- type ClusterClient
- type ClusterEnv
- type Env
- type ExecCall
- type ExitError
- type FakeClient
- func (c *FakeClient) BuilderVersion() types.BuilderVersion
- func (c *FakeClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
- func (c *FakeClient) ContainerRestartNoWait(ctx context.Context, containerID string) error
- func (c *FakeClient) CopyToContainerRoot(ctx context.Context, container string, content io.Reader) error
- func (c *FakeClient) Env() Env
- func (c *FakeClient) ExecInContainer(ctx context.Context, cID container.ID, cmd model.Cmd, out io.Writer) error
- func (c *FakeClient) ImageBuild(ctx context.Context, buildContext io.Reader, options BuildOptions) (types.ImageBuildResponse, error)
- func (c *FakeClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
- func (c *FakeClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
- func (c *FakeClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error)
- func (c *FakeClient) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
- func (c *FakeClient) ImageTag(ctx context.Context, source, target string) error
- func (c *FakeClient) ServerVersion() types.Version
- func (c *FakeClient) SetContainerListOutput(output map[string][]types.Container)
- func (c *FakeClient) SetDefaultContainerListOutput()
- func (c *FakeClient) SetOrchestrator(orc model.Orchestrator)
- type ImgNameAndTag
- type LocalClient
- type LocalEnv
Constants ¶
const ( TestPod = "test_pod" TestContainer = "test_container" )
const ExampleBuildOutput1 = `` /* 276-byte string literal not displayed */
const ExampleBuildOutputV1_23 = `` /* 186-byte string literal not displayed */
const ExampleBuildSHA1 = "sha256:11cd0b38bc3ceb958ffb2f9bd70be3fb317ce7d255c8a4c3f4af30e298aa1aab"
const ExamplePushSHA1 = "sha256:cc5f4c463f81c55183d8d737ba2f0d30b3e6f3670dbe2da68f0aac168e93fbb1"
const TagLatest = "latest"
Variables ¶
var ClusterWireSet = wire.NewSet( ProvideClusterCli, ProvideLocalCli, ProvideLocalEnv, ProvideClusterEnv, ProvideClusterAsDefault)
Bind a docker client that talks to the in-cluster Docker daemon.
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"}, }, }
var ExamplePushOutput1 = `` /* 1660-byte string literal not displayed */
var LocalWireSet = wire.NewSet( ProvideLocalCli, ProvideLocalEnv, ProvideLocalAsDefault)
Bind a docker client that can only talk to the local Docker daemon.
var SwitchWireSet = wire.NewSet( ProvideClusterCli, ProvideLocalCli, ProvideSwitchCli, ProvideLocalEnv, ProvideClusterEnv, wire.Bind(new(Client), new(switchCli)))
Bind a docker client that can either talk to the in-cluster Docker daemon or to the local Docker daemon.
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 NegotiateAPIVersion ¶ added in v0.4.1
func NewFakeDockerResponse ¶
func NewFakeDockerResponse(contents string) fakeDockerResponse
func ProvideSwitchCli ¶ added in v0.9.1
func ProvideSwitchCli(clusterCli ClusterClient, localCli LocalClient) *switchCli
func SupportedVersion ¶ added in v0.4.1
func SupportsBuildkit ¶ added in v0.4.1
Sadly, certain versions of docker return an error if the client requests buildkit. We have to infer whether it supports buildkit from version numbers.
Inferred from release notes https://docs.docker.com/engine/release-notes/
Types ¶
type BuildOptions ¶ added in v0.7.1
type Cli ¶ added in v0.5.0
func NewDockerClient ¶ added in v0.9.1
func (*Cli) BuilderVersion ¶ added in v0.9.1
func (c *Cli) BuilderVersion() types.BuilderVersion
func (*Cli) ContainerRestartNoWait ¶ added in v0.5.0
func (*Cli) CopyToContainerRoot ¶ added in v0.5.0
func (*Cli) ExecInContainer ¶ added in v0.5.0
func (*Cli) ImageBuild ¶ added in v0.5.0
func (c *Cli) ImageBuild(ctx context.Context, buildContext io.Reader, options BuildOptions) (types.ImageBuildResponse, error)
func (*Cli) ServerVersion ¶ added in v0.9.1
func (*Cli) SetOrchestrator ¶ added in v0.9.1
func (c *Cli) SetOrchestrator(orc model.Orchestrator)
type Client ¶ added in v0.5.0
type Client interface { // If you'd like to call this Docker instance in a separate process, these // are the environment variables you'll need to do so. Env() Env // If you'd like to call this Docker instance in a separate process, this // is the default builder version you want (buildkit or legacy) BuilderVersion() types.BuilderVersion ServerVersion() types.Version // Set the orchestrator we're talking to. This is only relevant to switchClient, // which can talk to either the Local or in-cluster docker daemon. SetOrchestrator(orc model.Orchestrator) 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 container.ID, 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 BuildOptions) (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.
func ProvideClusterAsDefault ¶ added in v0.9.1
func ProvideClusterAsDefault(cli ClusterClient) Client
func ProvideLocalAsDefault ¶ added in v0.9.1
func ProvideLocalAsDefault(cli LocalClient) Client
type ClusterClient ¶ added in v0.9.1
type ClusterClient Client
func ProvideClusterCli ¶ added in v0.9.1
func ProvideClusterCli(ctx context.Context, lEnv LocalEnv, cEnv ClusterEnv, kEnv k8s.Env, lClient LocalClient) (ClusterClient, error)
type ClusterEnv ¶ added in v0.9.1
type ClusterEnv Env
Tell wire to create two docker envs: one for the local CLI and one for the in-cluster CLI.
type Env ¶ added in v0.7.11
See notes on CreateClientOpts. These environment variables are standard docker env configs.
type FakeClient ¶ added in v0.5.0
type FakeClient struct { PushCount int PushImage string PushOptions types.ImagePushOptions PushOutput string BuildCount int BuildOptions BuildOptions BuildOutput string BuildErrorToThrow error // next call to Build will throw this err (after which we clear the error) ImageListCount int 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 Images map[string]types.ImageInspect }
func NewFakeClient ¶ added in v0.5.0
func NewFakeClient() *FakeClient
func (*FakeClient) BuilderVersion ¶ added in v0.9.1
func (c *FakeClient) BuilderVersion() types.BuilderVersion
func (*FakeClient) ContainerList ¶ added in v0.5.0
func (c *FakeClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error)
func (*FakeClient) ContainerRestartNoWait ¶ added in v0.5.0
func (c *FakeClient) ContainerRestartNoWait(ctx context.Context, containerID string) error
func (*FakeClient) CopyToContainerRoot ¶ added in v0.5.0
func (*FakeClient) Env ¶ added in v0.9.1
func (c *FakeClient) Env() Env
func (*FakeClient) ExecInContainer ¶ added in v0.5.0
func (*FakeClient) ImageBuild ¶ added in v0.5.0
func (c *FakeClient) ImageBuild(ctx context.Context, buildContext io.Reader, options BuildOptions) (types.ImageBuildResponse, error)
func (*FakeClient) ImageInspectWithRaw ¶ added in v0.5.0
func (c *FakeClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
func (*FakeClient) ImageList ¶ added in v0.5.0
func (c *FakeClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
func (*FakeClient) ImagePush ¶ added in v0.5.0
func (c *FakeClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error)
func (*FakeClient) ImageRemove ¶ added in v0.5.0
func (c *FakeClient) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
func (*FakeClient) ImageTag ¶ added in v0.5.0
func (c *FakeClient) ImageTag(ctx context.Context, source, target string) error
func (*FakeClient) ServerVersion ¶ added in v0.9.1
func (c *FakeClient) ServerVersion() types.Version
func (*FakeClient) SetContainerListOutput ¶ added in v0.5.0
func (c *FakeClient) SetContainerListOutput(output map[string][]types.Container)
func (*FakeClient) SetDefaultContainerListOutput ¶ added in v0.5.0
func (c *FakeClient) SetDefaultContainerListOutput()
func (*FakeClient) SetOrchestrator ¶ added in v0.9.1
func (c *FakeClient) SetOrchestrator(orc model.Orchestrator)
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
type LocalClient ¶ added in v0.9.1
type LocalClient Client
func ProvideLocalCli ¶ added in v0.9.1
func ProvideLocalCli(ctx context.Context, lEnv LocalEnv) (LocalClient, error)