Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) CopyDirToContainer(ctx context.Context, containerID, localDir, destDir string) error
- func (c *Client) CreateContainer(ctx context.Context, opts ContainerOpts) (string, error)
- func (c *Client) CreateNetwork(ctx context.Context, name string) (string, error)
- func (c *Client) CreateServiceContainer(ctx context.Context, opts ContainerOpts) (string, error)
- func (c *Client) ExecInContainer(ctx context.Context, containerID string, opts ExecOpts) (*ExecResult, error)
- func (c *Client) ExecStreaming(ctx context.Context, containerID string, opts ExecOpts, ...) (int, error)
- func (c *Client) ImageExists(ctx context.Context, imageName string) (bool, error)
- func (c *Client) OpenInteractiveShell(ctx context.Context, containerID, workDir string) error
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) PullImage(ctx context.Context, imageName string) error
- func (c *Client) Raw() *dockerclient.Client
- func (c *Client) RemoveNetwork(ctx context.Context, networkID string)
- func (c *Client) StartContainer(ctx context.Context, containerID string) error
- func (c *Client) StopAndRemove(ctx context.Context, containerID string) error
- func (c *Client) WaitContainer(ctx context.Context, containerID string) (int, error)
- func (c *Client) WriteScript(ctx context.Context, containerID, path, content string) error
- type ContainerOpts
- type ExecOpts
- type ExecResult
Constants ¶
const (
// ManagedLabel marks containers created by ci-debugger for cleanup.
ManagedLabel = "ci-debugger=true"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Docker SDK client.
func (*Client) CopyDirToContainer ¶
func (c *Client) CopyDirToContainer(ctx context.Context, containerID, localDir, destDir string) error
CopyDirToContainer copies the contents of localDir into destDir inside the container. destDir must already exist in the container (e.g. /tmp/). Each file is placed at destDir/<relpath> where relpath is relative to localDir.
func (*Client) CreateContainer ¶
CreateContainer creates and returns a container ID. The container uses "tail -f /dev/null" as entrypoint to stay alive.
func (*Client) CreateNetwork ¶
CreateNetwork creates a bridge network and returns its ID.
func (*Client) CreateServiceContainer ¶
CreateServiceContainer creates a service sidecar container using the image's own CMD/ENTRYPOINT (not overridden), and registers the service name as a network alias so job steps can reach it by hostname.
func (*Client) ExecInContainer ¶
func (c *Client) ExecInContainer(ctx context.Context, containerID string, opts ExecOpts) (*ExecResult, error)
ExecInContainer runs a command in a running container and captures output.
func (*Client) ExecStreaming ¶
func (c *Client) ExecStreaming(ctx context.Context, containerID string, opts ExecOpts, outWriter, errWriter io.Writer) (int, error)
ExecStreaming runs a command and streams output line-by-line via callbacks.
func (*Client) ImageExists ¶
ImageExists checks if an image is available locally.
func (*Client) OpenInteractiveShell ¶
OpenInteractiveShell starts an interactive bash session in the container.
func (*Client) Raw ¶
func (c *Client) Raw() *dockerclient.Client
Raw returns the underlying Docker client (for advanced operations).
func (*Client) RemoveNetwork ¶
RemoveNetwork removes a Docker network by ID.
func (*Client) StartContainer ¶
StartContainer starts a container by ID.
func (*Client) StopAndRemove ¶
StopAndRemove stops and removes a container.
func (*Client) WaitContainer ¶
WaitContainer waits for a container to stop and returns its exit code.
type ContainerOpts ¶
type ContainerOpts struct {
Image string
Name string
Env []string // KEY=VALUE pairs
Binds []string // host:container[:options]
WorkDir string
Labels map[string]string
Network string // Docker network ID or name to attach to
}
ContainerOpts configures a new container.
type ExecOpts ¶
type ExecOpts struct {
Cmd []string
Env []string // KEY=VALUE pairs
WorkDir string
TTY bool
Stdin bool
}
ExecOpts configures an exec in a running container.
type ExecResult ¶
ExecResult holds the output of a completed exec.