github.com/tilt-dev/tilt@v0.36.0/internal/docker/exploding.go (about) 1 package docker 2 3 import ( 4 "context" 5 "io" 6 7 "github.com/distribution/reference" 8 "github.com/docker/docker/api/types" 9 typescontainer "github.com/docker/docker/api/types/container" 10 "github.com/docker/docker/api/types/filters" 11 typesimage "github.com/docker/docker/api/types/image" 12 "golang.org/x/sync/errgroup" 13 14 "github.com/tilt-dev/tilt/internal/container" 15 "github.com/tilt-dev/tilt/pkg/model" 16 ) 17 18 // A docker client that returns errors on every method call. 19 // Useful when the client failed to init, but we don't have enough 20 // info at init time to tell if anyone is going to use it. 21 22 type explodingClient struct { 23 err error 24 } 25 26 func newExplodingClient(err error) explodingClient { 27 return explodingClient{err: err} 28 } 29 30 func (c explodingClient) SetOrchestrator(orc model.Orchestrator) { 31 } 32 func (c explodingClient) ForOrchestrator(orc model.Orchestrator) Client { 33 return c 34 } 35 func (c explodingClient) CheckConnected() error { 36 return c.err 37 } 38 func (c explodingClient) Env() Env { 39 return Env{} 40 } 41 func (c explodingClient) BuilderVersion(ctx context.Context) (types.BuilderVersion, error) { 42 return types.BuilderV1, c.err 43 } 44 func (c explodingClient) ServerVersion(ctx context.Context) (types.Version, error) { 45 return types.Version{}, c.err 46 } 47 func (c explodingClient) ContainerLogs(ctx context.Context, containerID string, options typescontainer.LogsOptions) (io.ReadCloser, error) { 48 return nil, c.err 49 } 50 func (c explodingClient) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { 51 return types.ContainerJSON{}, c.err 52 } 53 func (c explodingClient) ContainerList(ctx context.Context, options typescontainer.ListOptions) ([]types.Container, error) { 54 return nil, c.err 55 } 56 func (c explodingClient) ContainerRestartNoWait(ctx context.Context, containerID string) error { 57 return c.err 58 } 59 func (c explodingClient) Run(ctx context.Context, opts RunConfig) (RunResult, error) { 60 return RunResult{}, c.err 61 } 62 func (c explodingClient) ExecInContainer(ctx context.Context, cID container.ID, cmd model.Cmd, in io.Reader, out io.Writer) error { 63 return c.err 64 } 65 func (c explodingClient) ImagePull(_ context.Context, _ reference.Named) (reference.Canonical, error) { 66 return nil, c.err 67 } 68 func (c explodingClient) ImagePush(ctx context.Context, ref reference.NamedTagged) (io.ReadCloser, error) { 69 return nil, c.err 70 } 71 func (c explodingClient) ImageBuild(ctx context.Context, g *errgroup.Group, buildContext io.Reader, options BuildOptions) (types.ImageBuildResponse, error) { 72 return types.ImageBuildResponse{}, c.err 73 } 74 func (c explodingClient) ImageTag(ctx context.Context, source, target string) error { 75 return c.err 76 } 77 func (c explodingClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { 78 return types.ImageInspect{}, nil, c.err 79 } 80 func (c explodingClient) ImageList(ctx context.Context, options typesimage.ListOptions) ([]typesimage.Summary, error) { 81 return nil, c.err 82 } 83 func (c explodingClient) ImageRemove(ctx context.Context, imageID string, options typesimage.RemoveOptions) ([]typesimage.DeleteResponse, error) { 84 return nil, c.err 85 } 86 func (c explodingClient) NewVersionError(ctx context.Context, apiRequired, feature string) error { 87 return c.err 88 } 89 func (c explodingClient) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) { 90 return nil, c.err 91 } 92 func (c explodingClient) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (typescontainer.PruneReport, error) { 93 return typescontainer.PruneReport{}, c.err 94 } 95 96 var _ Client = &explodingClient{}