Documentation
¶
Overview ¶
Package backend abstracts the sandbox runtime so callers don't care whether a sandbox is a Docker container or a Kubernetes Pod.
Index ¶
- func Export(ctx context.Context, id, destDir string) error
- type Backend
- type Docker
- func (d *Docker) AttachPTY(ctx context.Context, id string, s PTYStream) error
- func (d *Docker) CopyFiles(ctx context.Context, id string, files []profile.File) error
- func (d *Docker) Create(ctx context.Context, spec Spec) (*Sandbox, error)
- func (d *Docker) Exec(ctx context.Context, id string, req ExecRequest) (*ExecResult, error)
- func (d *Docker) ExportWorkspace(ctx context.Context, id string, w io.Writer) error
- func (d *Docker) Kill(ctx context.Context, id string) error
- func (d *Docker) List(ctx context.Context) ([]Sandbox, error)
- func (d *Docker) Name() string
- func (d *Docker) Restore(ctx context.Context, ref SnapshotRef) (*Sandbox, error)
- func (d *Docker) RestoreWithSpec(ctx context.Context, ref SnapshotRef, spec Spec) (*Sandbox, error)
- func (d *Docker) Snapshot(ctx context.Context, id, name string) (*SnapshotRef, error)
- type ExecRequest
- type ExecResult
- type K8s
- func (k *K8s) AttachPTY(ctx context.Context, id string, s PTYStream) error
- func (k *K8s) CopyFiles(ctx context.Context, id string, files []profile.File) error
- func (k *K8s) Create(ctx context.Context, spec Spec) (*Sandbox, error)
- func (k *K8s) Exec(ctx context.Context, id string, req ExecRequest) (*ExecResult, error)
- func (k *K8s) ExportWorkspace(ctx context.Context, id string, w io.Writer) error
- func (k *K8s) Kill(ctx context.Context, id string) error
- func (k *K8s) List(ctx context.Context) ([]Sandbox, error)
- func (k *K8s) Name() string
- func (k *K8s) Restore(ctx context.Context, ref SnapshotRef) (*Sandbox, error)
- func (k *K8s) RestoreWithSpec(ctx context.Context, ref SnapshotRef, spec Spec) (*Sandbox, error)
- func (k *K8s) Snapshot(ctx context.Context, id, name string) (*SnapshotRef, error)
- type PTYStream
- type Resources
- type Sandbox
- type SnapshotRef
- type Spec
- type TermSize
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
Name() string
Create(ctx context.Context, spec Spec) (*Sandbox, error)
Exec(ctx context.Context, id string, req ExecRequest) (*ExecResult, error)
AttachPTY(ctx context.Context, id string, io PTYStream) error
CopyFiles(ctx context.Context, id string, files []profile.File) error
ExportWorkspace(ctx context.Context, id string, w io.Writer) error
Snapshot(ctx context.Context, id, name string) (*SnapshotRef, error)
Restore(ctx context.Context, ref SnapshotRef) (*Sandbox, error)
Kill(ctx context.Context, id string) error
List(ctx context.Context) ([]Sandbox, error)
}
Backend provisions and controls sandboxes for a given execution host.
type Docker ¶
type Docker struct {
// contains filtered or unexported fields
}
Docker provisions one container per sandbox. It drives the docker CLI rather than the SDK; the CLI contract is more stable across
func NewDocker ¶
NewDocker returns a Docker backend, verifying the CLI is present and the engine is actually reachable so misconfig fails fast with a clear message.
func (*Docker) Exec ¶
func (d *Docker) Exec(ctx context.Context, id string, req ExecRequest) (*ExecResult, error)
func (*Docker) ExportWorkspace ¶
ExportWorkspace streams a tar of the container workdir contents to w.
func (*Docker) RestoreWithSpec ¶
type ExecRequest ¶
type ExecRequest struct {
Command []string
Workdir string
Env map[string]string
Timeout time.Duration
}
ExecRequest is a one-shot command execution.
type ExecResult ¶
ExecResult captures the outcome of an Exec.
type K8s ¶
type K8s struct {
// contains filtered or unexported fields
}
K8s provisions one Pod (plus a workspace PVC) per sandbox via client-go, managing Pods directly rather than through a controller.
func NewK8s ¶
NewK8s builds the Kubernetes backend from the ambient kubeconfig. $RUNEWARD_KUBE_CONTEXT pins the context; $RUNEWARD_K8S_NAMESPACE overrides the default "runeward" namespace.
func (*K8s) Exec ¶
func (k *K8s) Exec(ctx context.Context, id string, req ExecRequest) (*ExecResult, error)
func (*K8s) ExportWorkspace ¶
ExportWorkspace streams a tar of the pod workdir contents to w.
func (*K8s) RestoreWithSpec ¶
type PTYStream ¶
type PTYStream struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
TTY bool
Command []string
Resize <-chan TermSize
}
PTYStream carries the interactive terminal I/O for AttachPTY.
type Sandbox ¶
type Sandbox struct {
ID string
Profile string
Backend string
Image string
Status string
CreatedAt time.Time
Endpoint string
}
Sandbox is a handle to a provisioned sandbox.
func RestoreSnapshot ¶
RestoreSnapshot restores a snapshot using the full spec path when supported.
type SnapshotRef ¶
type SnapshotRef struct {
ID string `json:"id"`
Name string `json:"name"`
Profile string `json:"profile"`
Backend string `json:"backend"`
Location string `json:"location"`
Sha256 string `json:"sha256,omitempty"`
Created time.Time `json:"created"`
}
SnapshotRef identifies a captured workspace snapshot.
type Spec ¶
type Spec struct {
Profile string
Image string
Workdir string
User string
Env map[string]string
Labels map[string]string
Files []profile.File
SeedDir string
Network profile.Network
Resources Resources
RuntimeClass string
// ReadOnly mounts the container root filesystem read-only.
ReadOnly bool
// Seccomp is a seccomp profile path (Docker: --security-opt seccomp=;
// k8s: Localhost profile path). Empty means the backend default.
Seccomp string
// AppArmor is an AppArmor profile name.
AppArmor string
}
Spec is the resolved, backend-agnostic description of a sandbox to create.