Help us shape the future of Go! Take the 2026 Go Developer Survey

sandbox

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBoundary = errors.New("sandbox request violates execution boundary")
View Source
var ErrUnavailable = errors.New("sandbox isolation or resource controls unavailable")

Functions

func ImageDigest

func ImageDigest(root string) (string, error)

func SnapshotDigest

func SnapshotDigest(files []guest.File) (string, error)

Types

type Artifact

type Artifact struct {
	Name      string
	MediaType string
	Data      []byte
	SHA256    string
}

type Command

type Command struct {
	Args           []string
	Directory      string
	Timeout        time.Duration
	MaxOutputBytes int64
	NetworkProfile string
	Stdin          []byte
}

type CommandResult

type CommandResult struct {
	ExitCode  int
	Output    []byte
	Truncated bool
	Duration  time.Duration
	TimedOut  bool
}

type CommandSetupError

type CommandSetupError struct {
	Result CommandResult
}

func (*CommandSetupError) Error

func (e *CommandSetupError) Error() string

type KubernetesRuntimeConfig

type KubernetesRuntimeConfig struct {
	Namespace              string            `json:"namespace"`
	RunnerID               string            `json:"-"`
	RuntimeClassName       string            `json:"runtime_class_name,omitempty"`
	ImagePullSecrets       []string          `json:"image_pull_secrets,omitempty"`
	Images                 map[string]string `json:"images"`
	Toolchains             map[string]string `json:"toolchains"`
	BrokerListenAddress    string            `json:"broker_listen_address,omitempty"`
	BrokerAdvertiseAddress string            `json:"broker_advertise_address,omitempty"`
}

type Patch

type Patch struct {
	Path    string `json:"path"`
	Content []byte `json:"content"`
	Delete  bool   `json:"delete,omitempty"`
}

type Runtime

type Runtime struct {
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime(cfg RuntimeConfig) (*Runtime, error)

func (*Runtime) ApplyPatch

func (r *Runtime) ApplyPatch(ctx context.Context, workspace Workspace, patches []Patch) error

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) CollectArtifact

func (r *Runtime) CollectArtifact(ctx context.Context, workspace Workspace, name string) (Artifact, error)

func (*Runtime) Destroy

func (r *Runtime) Destroy(ctx context.Context, workspace Workspace) error

func (*Runtime) ExecuteBoundedCommand

func (r *Runtime) ExecuteBoundedCommand(ctx context.Context, workspace Workspace, command Command) (CommandResult, error)

func (*Runtime) PreparePinnedWorkspace

func (r *Runtime) PreparePinnedWorkspace(ctx context.Context, in WorkspaceRequest) (Workspace, error)

type RuntimeConfig

type RuntimeConfig struct {
	Backend        string                                                    `json:"backend,omitempty"`
	Kubernetes     *KubernetesRuntimeConfig                                  `json:"kubernetes,omitempty"`
	Runsc          string                                                    `json:"runsc"`
	RunscSHA256    string                                                    `json:"runsc_sha256"`
	Tool           string                                                    `json:"tool"`
	ToolSHA256     string                                                    `json:"tool_sha256"`
	StateRoot      string                                                    `json:"state_root"`
	DependencyRoot string                                                    `json:"dependency_root,omitempty"`
	CgroupRoot     string                                                    `json:"cgroup_root"`
	Images         map[string]string                                         `json:"images"`
	Development    bool                                                      `json:"development"`
	Rootless       bool                                                      `json:"rootless"`
	MemoryBytes    int64                                                     `json:"memory_bytes"`
	DiskBytes      int64                                                     `json:"disk_bytes"`
	CPUs           int64                                                     `json:"cpus"`
	MaxProcesses   int64                                                     `json:"max_processes"`
	Fetch          func(context.Context, WorkspaceRequest) (Snapshot, error) `json:"-"`
}

type SandboxRuntime

type SandboxRuntime interface {
	PreparePinnedWorkspace(context.Context, WorkspaceRequest) (Workspace, error)
	ExecuteBoundedCommand(context.Context, Workspace, Command) (CommandResult, error)
	ApplyPatch(context.Context, Workspace, []Patch) error
	CollectArtifact(context.Context, Workspace, string) (Artifact, error)
	Destroy(context.Context, Workspace) error
}

type Snapshot

type Snapshot struct {
	CommitSHA      string       `json:"commit_sha"`
	Complete       bool         `json:"complete"`
	ManifestSHA256 string       `json:"manifest_sha256"`
	Files          []guest.File `json:"files"`
}

type Workspace

type Workspace struct {
	ID        string
	CommitSHA string
	Root      string
	Image     string
}

type WorkspaceRequest

type WorkspaceRequest struct {
	JobID         string
	AttemptID     string
	RepositoryURL string
	CommitSHA     string
	Image         string
	Trust         string
	Timeout       time.Duration
	Dependencies  string
	Egress        string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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