driver

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOptions

type BuildOptions struct {
	PrebuildHash string
	Image        string
	Dockerfile   string
	Context      string
	Args         map[string]string
	Target       string
	CacheFrom    []string
	Options      []string // Extra CLI flags from build.options
	Stdout       io.Writer
	Stderr       io.Writer
}

BuildOptions holds parameters for building a container image.

type ContainerConfig

type ContainerConfig struct {
	Labels map[string]string
	User   string
}

ContainerConfig holds container configuration metadata.

type ContainerDetails

type ContainerDetails struct {
	ID      string
	Created string
	State   ContainerState
	Config  ContainerConfig
	Ports   []PortBinding
}

ContainerDetails describes a running or stopped container.

type ContainerState

type ContainerState struct {
	Status    string
	StartedAt string
}

ContainerState holds the runtime state of a container.

func (ContainerState) IsRemoving

func (s ContainerState) IsRemoving() bool

IsRemoving reports whether the container is in the process of being removed.

func (ContainerState) IsRunning

func (s ContainerState) IsRunning() bool

IsRunning reports whether the container is in the running state.

type Driver

type Driver interface {
	// FindContainer locates a container by workspace ID.
	// Returns nil if no container is found.
	FindContainer(ctx context.Context, workspaceID string) (*ContainerDetails, error)

	// RunContainer creates and starts a container with the given options.
	RunContainer(ctx context.Context, workspaceID string, options *RunOptions) error

	// StartContainer starts a stopped container.
	StartContainer(ctx context.Context, workspaceID, containerID string) error

	// StopContainer stops a running container.
	StopContainer(ctx context.Context, workspaceID, containerID string) error

	// RestartContainer restarts a running or stopped container.
	RestartContainer(ctx context.Context, workspaceID, containerID string) error

	// DeleteContainer removes a container.
	DeleteContainer(ctx context.Context, workspaceID, containerID string) error

	// ExecContainer runs a command inside a container with attached I/O.
	// env is a list of KEY=VALUE pairs injected via -e flags.
	// user overrides the exec user (e.g. "root"); pass "" to use the container default.
	ExecContainer(ctx context.Context, workspaceID, containerID string, cmd []string, stdin io.Reader, stdout, stderr io.Writer, env []string, user string) error

	// ContainerLogs returns the logs from a container.
	// opts may be nil for default behavior (all logs, no follow).
	ContainerLogs(ctx context.Context, workspaceID, containerID string, stdout, stderr io.Writer, opts *LogsOptions) error

	// BuildImage builds a container image.
	BuildImage(ctx context.Context, workspaceID string, options *BuildOptions) error

	// InspectImage returns details about a container image.
	InspectImage(ctx context.Context, imageName string) (*ImageDetails, error)

	// TargetArchitecture returns the architecture of the container runtime (e.g. "amd64", "arm64").
	TargetArchitecture(ctx context.Context) (string, error)

	// ListContainers returns all containers with the crib.workspace label.
	ListContainers(ctx context.Context) ([]ContainerDetails, error)

	// CommitContainer creates an image from a container's changes.
	CommitContainer(ctx context.Context, workspaceID, containerID, imageName string) error

	// RemoveImage removes a container image.
	RemoveImage(ctx context.Context, imageName string) error

	// ListVolumes returns volumes whose names match the given filter prefix.
	ListVolumes(ctx context.Context, nameFilter string) ([]VolumeInfo, error)

	// RemoveVolume removes a named volume.
	RemoveVolume(ctx context.Context, name string) error
}

Driver abstracts the container runtime (Docker or Podman).

type ImageConfig

type ImageConfig struct {
	User       string
	Env        []string
	Labels     map[string]string
	Entrypoint []string
	Cmd        []string
}

ImageConfig holds image configuration metadata.

type ImageDetails

type ImageDetails struct {
	ID     string
	Config ImageConfig
}

ImageDetails describes a container image.

type LogsOptions added in v0.5.0

type LogsOptions struct {
	Follow bool   // stream logs as they are produced
	Tail   string // number of lines from the end ("all" or a number)
}

LogsOptions controls container log output.

type PortBinding added in v0.4.0

type PortBinding struct {
	ContainerPort int    // Port inside the container
	HostPort      int    // Port on the host
	HostIP        string // Host bind address (e.g. "0.0.0.0")
	Protocol      string // "tcp" or "udp"
	RawSpec       string // Original spec when ports can't be represented as ints (e.g. ranges)
}

PortBinding describes a published port mapping.

type RunOptions

type RunOptions struct {
	Image          string
	User           string
	Entrypoint     string
	Cmd            []string
	Env            []string
	CapAdd         []string
	SecurityOpt    []string
	Labels         map[string]string
	Privileged     bool
	Init           bool
	WorkspaceMount config.Mount
	Mounts         []config.Mount
	Ports          []string // Publish specs (e.g. "8080:8080")
	ExtraArgs      []string // Raw CLI args passed through from runArgs
}

RunOptions holds parameters for creating and starting a container.

type VolumeInfo added in v0.5.0

type VolumeInfo struct {
	Name string
	Size string // human-readable, best-effort (may be empty)
}

VolumeInfo describes a named Docker/Podman volume.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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