Documentation
¶
Overview ¶
Package sandbox defines backend-agnostic interfaces for container lifecycle, execution, and network policy. Concrete implementations live in separate packages and register themselves via Register.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
Create(ctx context.Context, opts CreateOpts) (*Instance, error)
Get(ctx context.Context, name string) (*Instance, error)
List(ctx context.Context) ([]Instance, error)
Start(ctx context.Context, name string) error
Stop(ctx context.Context, name string) error
Delete(ctx context.Context, name string) error
CreateSnapshot(ctx context.Context, name, label string) error
ListSnapshots(ctx context.Context, name string) ([]Snapshot, error)
DeleteSnapshot(ctx context.Context, name, label string) error
RestoreSnapshot(ctx context.Context, name, label string) error
CloneFrom(ctx context.Context, source, label, newName string) error
Capabilities() Capabilities
Close() error
}
Backend manages the lifecycle of sandbox instances and their snapshots.
type Capabilities ¶
Capabilities advertises optional features a backend supports.
type ConsoleOpts ¶
ConsoleOpts holds parameters for attaching an interactive console.
type CreateOpts ¶
type CreateOpts struct {
Name string
Image string
CPU string
Memory int64
Bare bool // create instance only, skip provisioning and SSH wait
}
CreateOpts holds parameters for creating a new sandbox instance.
type EgressMode ¶
type EgressMode string
EgressMode controls what network traffic a sandbox may initiate.
const ( EgressUnrestricted EgressMode = "unrestricted" EgressAgent EgressMode = "agent" EgressAllowlist EgressMode = "allowlist" )
type Exec ¶
type Exec interface {
Run(ctx context.Context, name string, opts ExecOpts) (exitCode int, err error)
Output(ctx context.Context, name string, cmd []string) ([]byte, error)
Console(ctx context.Context, name string, opts ConsoleOpts) error
Ready(ctx context.Context, name string, timeout time.Duration) error
}
Exec runs commands and interactive sessions inside a sandbox instance.
type ExecOpts ¶
type ExecOpts struct {
Cmd []string
Env []string
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
Root bool // run as root instead of the configured sandbox user
}
ExecOpts holds parameters for running a command inside a sandbox.
type Factory ¶
Factory constructs a Sandbox from backend-specific configuration. The cfg map is interpreted by each backend (e.g. "host" and "api_key" for TrueNAS, "socket" for Incus).
type NetworkPolicy ¶
type NetworkPolicy interface {
SetEgressMode(ctx context.Context, name string, mode EgressMode) error
AllowDomain(ctx context.Context, name, domain string) error
DenyDomain(ctx context.Context, name, domain string) error
GetPolicy(ctx context.Context, name string) (*Policy, error)
}
NetworkPolicy controls egress filtering for a sandbox instance.
type Policy ¶
type Policy struct {
Mode EgressMode
Domains []string
}
Policy describes the current egress policy for a sandbox instance.
type Sandbox ¶
type Sandbox interface {
Backend
Exec
NetworkPolicy
}
Sandbox composes all sandbox capabilities into a single interface.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package incus implements the sandbox.Sandbox interface using a native Incus daemon connection (local unix socket or remote HTTPS).
|
Package incus implements the sandbox.Sandbox interface using a native Incus daemon connection (local unix socket or remote HTTPS). |
|
Package truenas implements the sandbox.Sandbox interface using TrueNAS Incus containers via the WebSocket API.
|
Package truenas implements the sandbox.Sandbox interface using TrueNAS Incus containers via the WebSocket API. |