sandboxlifecycle

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sandboxlifecycle decides whether the Docker sandbox needs starting and, when it does, brings it up — reporting whether the caller now owns it. The ownership signal lets callers tear down only the sandbox they started.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ensure

func Ensure(ctx context.Context, sb Sandbox) (startedByUs bool, err error)

Ensure makes sb running. If it is already running, Ensure does nothing and reports startedByUs=false (the caller must not tear it down). If it was not running, Ensure brings it up and applies the network policy, reporting startedByUs=true. Any failure is returned and startedByUs is false.

func NewExecutor

func NewExecutor(ctx context.Context, cfg *config.Config) (*container.ComposeExecutor, string, func(), error)

NewExecutor connects to Docker and builds a compose executor for cfg's sandbox project (named deterministically from the current directory). The returned cleanup closes the Docker client and must be called by the caller.

Types

type Result

type Result struct {
	Executor    *container.ComposeExecutor
	ProjectName string
	StartedByUs bool
	// contains filtered or unexported fields
}

Result carries the outcome of EnsureUp: the executor to run/tear down the sandbox, its project name, and whether this call started it.

func EnsureUp

func EnsureUp(ctx context.Context, cfg *config.Config) (*Result, error)

EnsureUp builds the executor for cfg and ensures the sandbox is running. On any failure it closes the Docker client and returns the error; Claude must not be launched in that case.

func (*Result) Close

func (r *Result) Close()

Close releases the Docker client. Safe to call multiple times.

func (*Result) Down

func (r *Result) Down(ctx context.Context) error

Down stops and removes the sandbox.

func (*Result) Started

func (r *Result) Started() bool

Started reports whether this call started the sandbox (and therefore owns it).

type Sandbox

type Sandbox interface {
	IsRunning(context.Context) (bool, error)
	Up(context.Context) error
	ApplyNetworkPolicy(context.Context) error
	Down(context.Context) error
}

Sandbox is the subset of the compose executor the lifecycle logic needs. *container.ComposeExecutor satisfies it.

Jump to

Keyboard shortcuts

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