Documentation
¶
Index ¶
- Constants
- func ContainerName(workspaceID string) string
- func ImageName(workspaceID, tag string) string
- func WorkspaceLabel(workspaceID string) string
- type Helper
- func (h *Helper) Command() string
- func (h *Helper) Inspect(ctx context.Context, ids []string, inspectType string, result any) error
- func (h *Helper) Output(ctx context.Context, args ...string) ([]byte, error)
- func (h *Helper) Run(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error
- type OCIDriver
- func (d *OCIDriver) BuildImage(ctx context.Context, workspaceID string, opts *driver.BuildOptions) error
- func (d *OCIDriver) CommitContainer(ctx context.Context, _, containerID, imageName string) error
- func (d *OCIDriver) ContainerLogs(ctx context.Context, _, containerID string, stdout, stderr io.Writer, ...) error
- func (d *OCIDriver) DeleteContainer(ctx context.Context, _, containerID string) error
- func (d *OCIDriver) ExecContainer(ctx context.Context, _, containerID string, cmd []string, stdin io.Reader, ...) error
- func (d *OCIDriver) FindContainer(ctx context.Context, workspaceID string) (*driver.ContainerDetails, error)
- func (d *OCIDriver) InspectImage(ctx context.Context, imageName string) (*driver.ImageDetails, error)
- func (d *OCIDriver) ListContainers(ctx context.Context) ([]driver.ContainerDetails, error)
- func (d *OCIDriver) ListVolumes(ctx context.Context, nameFilter string) ([]driver.VolumeInfo, error)
- func (d *OCIDriver) RemoveImage(ctx context.Context, imageName string) error
- func (d *OCIDriver) RemoveVolume(ctx context.Context, name string) error
- func (d *OCIDriver) RestartContainer(ctx context.Context, _, containerID string) error
- func (d *OCIDriver) RunContainer(ctx context.Context, workspaceID string, options *driver.RunOptions) error
- func (d *OCIDriver) Runtime() Runtime
- func (d *OCIDriver) StartContainer(ctx context.Context, _, containerID string) error
- func (d *OCIDriver) StopContainer(ctx context.Context, _, containerID string) error
- func (d *OCIDriver) TargetArchitecture(ctx context.Context) (string, error)
- type Runtime
Constants ¶
const LabelWorkspace = "crib.workspace"
LabelWorkspace is the container label key used for workspace discovery.
Variables ¶
This section is empty.
Functions ¶
func ContainerName ¶
ContainerName returns the container name for a workspace.
func WorkspaceLabel ¶
WorkspaceLabel returns the label filter string for finding workspace containers.
Types ¶
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper wraps the docker/podman CLI binary for executing commands.
func NewHelper ¶
NewHelper creates a Helper that shells out to the given command (e.g. "docker" or "podman").
func (*Helper) Inspect ¶
Inspect runs `<cmd> inspect --type <inspectType>` on the given IDs and unmarshals the JSON result into the provided pointer.
type OCIDriver ¶
type OCIDriver struct {
// contains filtered or unexported fields
}
OCIDriver implements driver.Driver using docker or podman CLI commands.
func NewOCIDriver ¶
NewOCIDriver creates an OCIDriver by auto-detecting the container runtime.
func (*OCIDriver) BuildImage ¶
func (d *OCIDriver) BuildImage(ctx context.Context, workspaceID string, opts *driver.BuildOptions) error
BuildImage builds a container image from a Dockerfile. For Docker, it tries `docker buildx build --load` first, falling back to `docker build`. For Podman, it uses `podman build` directly.
func (*OCIDriver) CommitContainer ¶ added in v0.5.0
CommitContainer creates an image from a container's changes.
func (*OCIDriver) ContainerLogs ¶
func (d *OCIDriver) ContainerLogs(ctx context.Context, _, containerID string, stdout, stderr io.Writer, opts *driver.LogsOptions) error
ContainerLogs returns the logs from a container. opts may be nil for default behavior (all logs, no follow).
func (*OCIDriver) DeleteContainer ¶
DeleteContainer removes a container forcefully with no grace period.
func (*OCIDriver) ExecContainer ¶
func (d *OCIDriver) ExecContainer(ctx context.Context, _, containerID string, cmd []string, stdin io.Reader, stdout, stderr io.Writer, env []string, user string) error
ExecContainer runs a command inside a container with attached I/O. env is injected as -e KEY=VALUE flags. user overrides the exec user (e.g. "root"); empty string uses the container default.
func (*OCIDriver) FindContainer ¶
func (d *OCIDriver) FindContainer(ctx context.Context, workspaceID string) (*driver.ContainerDetails, error)
FindContainer locates a container by workspace ID using label filtering. Returns nil if no container is found. Skips containers in "removing" state.
func (*OCIDriver) InspectImage ¶
func (d *OCIDriver) InspectImage(ctx context.Context, imageName string) (*driver.ImageDetails, error)
InspectImage returns details about a container image.
func (*OCIDriver) ListContainers ¶ added in v0.5.0
ListContainers returns all containers with the crib.workspace label.
func (*OCIDriver) ListVolumes ¶ added in v0.5.0
func (d *OCIDriver) ListVolumes(ctx context.Context, nameFilter string) ([]driver.VolumeInfo, error)
ListVolumes returns volumes whose names start with nameFilter.
func (*OCIDriver) RemoveImage ¶ added in v0.5.0
RemoveImage removes a container image.
func (*OCIDriver) RemoveVolume ¶ added in v0.5.0
RemoveVolume removes a named volume.
func (*OCIDriver) RestartContainer ¶ added in v0.2.0
RestartContainer restarts a running or stopped container.
func (*OCIDriver) RunContainer ¶
func (d *OCIDriver) RunContainer(ctx context.Context, workspaceID string, options *driver.RunOptions) error
RunContainer creates and starts a new container for the workspace. The workspace label is injected automatically.
func (*OCIDriver) StartContainer ¶
StartContainer starts a stopped container.
func (*OCIDriver) StopContainer ¶
StopContainer stops a running container.