Help us shape the future of Go! Take the 2026 Go Developer Survey

docker

package
v1.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureNetwork

func EnsureNetwork(ctx context.Context, c Client, name string) error

EnsureNetwork inspects the named network; if not found, creates it as a bridge with Attachable: true. Idempotent.

Types

type Client

type Client interface {
	Ping(ctx context.Context) error
	Close() error
	ContainerList(ctx context.Context, opts container.ListOptions) ([]container.Summary, error)
	ContainerStats(ctx context.Context, containerID string) (container.StatsResponseReader, error)
	ContainerLogs(ctx context.Context, containerID string, opts container.LogsOptions) (io.ReadCloser, error)
	ContainerInspect(ctx context.Context, id string) (container.InspectResponse, error)
	NetworkInspect(ctx context.Context, id string) (network.Inspect, error)
	NetworkCreate(ctx context.Context, name string, opts network.CreateOptions) (network.CreateResponse, error)
	Raw() *dockerclient.Client
}

type DockerClient

type DockerClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() (*DockerClient, error)

func (*DockerClient) Close

func (c *DockerClient) Close() error

func (*DockerClient) ContainerInspect

func (c *DockerClient) ContainerInspect(ctx context.Context, id string) (container.InspectResponse, error)

func (*DockerClient) ContainerList

func (c *DockerClient) ContainerList(ctx context.Context, opts container.ListOptions) ([]container.Summary, error)

func (*DockerClient) ContainerLogs

func (c *DockerClient) ContainerLogs(ctx context.Context, containerID string, opts container.LogsOptions) (io.ReadCloser, error)

func (*DockerClient) ContainerStats

func (c *DockerClient) ContainerStats(ctx context.Context, id string) (container.StatsResponseReader, error)

func (*DockerClient) NetworkCreate

func (c *DockerClient) NetworkCreate(ctx context.Context, name string, opts network.CreateOptions) (network.CreateResponse, error)

func (*DockerClient) NetworkInspect

func (c *DockerClient) NetworkInspect(ctx context.Context, id string) (network.Inspect, error)

func (*DockerClient) Ping

func (c *DockerClient) Ping(ctx context.Context) error

func (*DockerClient) Raw

func (c *DockerClient) Raw() *dockerclient.Client

type MockClient

type MockClient struct {
	Calls []string

	// Optional overrides for test setup.
	NetworkInspectFn   func(ctx context.Context, id string) (network.Inspect, error)
	NetworkCreateFn    func(ctx context.Context, name string, opts network.CreateOptions) (network.CreateResponse, error)
	ContainerInspectFn func(ctx context.Context, id string) (container.InspectResponse, error)
	// contains filtered or unexported fields
}

MockClient is a thread-safe in-memory Docker client for testing.

func NewMockClient

func NewMockClient() *MockClient

func (*MockClient) AddContainer

func (m *MockClient) AddContainer(id string, labels map[string]string)

AddContainer pre-populates the mock with a container for testing.

func (*MockClient) Close

func (m *MockClient) Close() error

func (*MockClient) ContainerInspect

func (m *MockClient) ContainerInspect(ctx context.Context, id string) (container.InspectResponse, error)

func (*MockClient) ContainerList

func (m *MockClient) ContainerList(_ context.Context, _ container.ListOptions) ([]container.Summary, error)

func (*MockClient) ContainerLogs

func (m *MockClient) ContainerLogs(_ context.Context, id string, _ container.LogsOptions) (io.ReadCloser, error)

func (*MockClient) ContainerStats

func (m *MockClient) ContainerStats(_ context.Context, _ string) (container.StatsResponseReader, error)

func (*MockClient) HasCall

func (m *MockClient) HasCall(prefix string) bool

HasCall returns true if any recorded call has the given prefix.

func (*MockClient) NetworkCreate

func (m *MockClient) NetworkCreate(ctx context.Context, name string, opts network.CreateOptions) (network.CreateResponse, error)

func (*MockClient) NetworkInspect

func (m *MockClient) NetworkInspect(ctx context.Context, id string) (network.Inspect, error)

func (*MockClient) Ping

func (m *MockClient) Ping(_ context.Context) error

func (*MockClient) Raw

func (m *MockClient) Raw() *dockerclient.Client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL