Documentation
¶
Index ¶
- Constants
- func CheckNetworkConsistency(ctx context.Context, dockerCLI command.Cli, allowExternal bool, ...) error
- func DetectProjectNetwork(ctx context.Context, dockerCLI command.Cli, suffix string) string
- func DownProject(ctx context.Context, dockerCLI command.Cli, workingDir string) error
- func NormalizeProjectName(name string) string
- func ProjectSandboxName(cwd string) string
- type CleanResult
- type ContainerExecutor
- func (e *ContainerExecutor) CleanStale(ctx context.Context) (CleanResult, error)
- func (e *ContainerExecutor) Down(ctx context.Context) error
- func (e *ContainerExecutor) IsRunning(ctx context.Context) (bool, error)
- func (e *ContainerExecutor) RunContainer(ctx context.Context, argv []string, env []string, stdin io.Reader, ...) (int, error)
- func (e *ContainerExecutor) StartBackground(ctx context.Context)
- func (e *ContainerExecutor) Up(ctx context.Context) error
- func (e *ContainerExecutor) WaitReady(ctx context.Context) error
- type SandboxSpec
Constants ¶
const ( LabelManaged = "cr.managed" LabelProjectDir = "cr.project_dir" )
Variables ¶
This section is empty.
Functions ¶
func CheckNetworkConsistency ¶ added in v0.12.0
func CheckNetworkConsistency(ctx context.Context, dockerCLI command.Cli, allowExternal bool, projectNetwork string) error
CheckNetworkConsistency inspects projectNetwork and refuses attachment when it would leak egress. A blank projectNetwork is a no-op (nil).
func DetectProjectNetwork ¶
DetectProjectNetwork checks whether a Docker network named "<cwd-project>_<suffix>" exists. Returns the full network name if found, "" otherwise. If suffix is empty, "default" is used.
func DownProject ¶
DownProject stops and removes a sandbox by its project working directory, without needing a full spec.
func NormalizeProjectName ¶
NormalizeProjectName converts a directory name to a Docker Compose project name.
func ProjectSandboxName ¶
Types ¶
type CleanResult ¶
CleanResult reports how many containers and networks a prune removed.
type ContainerExecutor ¶ added in v0.12.0
type ContainerExecutor struct {
// contains filtered or unexported fields
}
ContainerExecutor manages one sandbox container through the Docker SDK.
func NewContainerExecutor ¶ added in v0.12.0
func NewContainerExecutor(dockerCLI command.Cli, spec *SandboxSpec) *ContainerExecutor
func (*ContainerExecutor) CleanStale ¶ added in v0.12.0
func (e *ContainerExecutor) CleanStale(ctx context.Context) (CleanResult, error)
CleanStale removes all agent-sandbox managed containers and cr-sandbox- networks.
func (*ContainerExecutor) Down ¶ added in v0.12.0
func (e *ContainerExecutor) Down(ctx context.Context) error
Down stops and removes the sandbox container and its network. The external project network is never touched.
func (*ContainerExecutor) IsRunning ¶ added in v0.12.0
func (e *ContainerExecutor) IsRunning(ctx context.Context) (bool, error)
IsRunning reports whether this project's sandbox container is running.
func (*ContainerExecutor) RunContainer ¶ added in v0.12.0
func (e *ContainerExecutor) RunContainer(ctx context.Context, argv []string, env []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)
RunContainer execs argv inside the running sandbox container, streaming stdout/stderr and optionally forwarding stdin, and returns the process exit code. It returns router.ErrSandboxNotRunning if the sandbox container is not currently running.
func (*ContainerExecutor) StartBackground ¶ added in v0.12.0
func (e *ContainerExecutor) StartBackground(ctx context.Context)
StartBackground runs Up in a goroutine; call WaitReady before issuing commands.
func (*ContainerExecutor) Up ¶ added in v0.12.0
func (e *ContainerExecutor) Up(ctx context.Context) error
Up runs the fail-closed consistency check, then ensures the image, sandbox network, and container exist, connects the project network (if any), and starts the container. It is idempotent: calling Up again on an already running sandbox succeeds without error.
type SandboxSpec ¶ added in v0.12.0
type SandboxSpec struct {
Name string
WorkingDir string
ImageTag string
BuildContext string
Dockerfile string
NetworkName string
ExternalNetwork string
UID int
GID int
Internal bool
Labels map[string]string
}
SandboxSpec fully describes the single sandbox container to create.
func NewSandboxSpec ¶ added in v0.12.0
func NewSandboxSpec(uid, gid int, buildContext, dockerfile, image string, allowExternal bool, externalNetwork string) (*SandboxSpec, error)
NewSandboxSpec derives the container spec from config for the current directory.