sandbox

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	User   = "org.set-io.boots.user"
	Cipher = "org.set-io.boots.cipher"
	Addr   = "org.set-io.boots.addr"
)

Variables

View Source
var (
	ErrExist      = errors.New("sandbox with given ID already exists")
	ErrInvalidID  = errors.New("invalid sandbox ID format")
	ErrNotExist   = errors.New("sandbox does not exist")
	ErrRunning    = errors.New("sandbox still running")
	ErrNotRunning = errors.New("sandbox not running")
)

Functions

func CleanPath

func CleanPath(path string) string

func KnownHookNames

func KnownHookNames() []string

func SetParams

func SetParams(params *string, args []string, name string)

func ValidateID

func ValidateID(id string) error

Types

type BaseState

type BaseState struct {
	ID                   string    `json:"id"`
	InitProcessPid       int       `json:"init_process_pid"`
	InitProcessStartTime uint64    `json:"init_process_start"`
	Created              time.Time `json:"created"`
	Config               Config    `json:"config"`
}

type Config

type Config struct {
	Debug                bool
	RootDir              string
	Labels               []string `json:"labels"`
	Version              string   `json:"version"`
	Rootfs               string   `json:"rootfs"`
	Hostname             string   `json:"hostname"`
	HypervisorPath       string   `json:"hypervisor_path"`
	HypervisorParameters []string `json:"hypervisor_parameters,omitempty"`
	KernelPath           string   `json:"kernel_path"`
	KernelParameters     []string `json:"kernel_parameters,omitempty"`
	InitRD               string   `json:"initrd,omitempty"`
	Probe                bool     `json:"probe,omitempty"`
	Stable               bool     `json:"stable,omitempty"`
	Net                  Net      `json:"net"`
	Hooks                Hooks    `json:"-"`
}

func (*Config) GetHypervisorParameters

func (c *Config) GetHypervisorParameters(key string) string

func (*Config) Validate

func (c *Config) Validate() error

type ExecProcess

type ExecProcess struct {
	Args     []string
	Env      []string
	UID, GID int
	Cwd      string
	Stdout   io.Writer
	Stderr   io.Writer
	Init     bool
	Terminal bool
	// contains filtered or unexported fields
}

type Hook

type Hook interface {
	Run(*specs.State) error
}

type HookList

type HookList []Hook

type HookName

type HookName string
const (
	PreStart      HookName = "preStart"
	CreateRuntime HookName = "createRuntime"
	CreateSandbox HookName = "createSandbox"
	StartSandbox  HookName = "startSandbox"
	PostStart     HookName = "postStart"
	PostStop      HookName = "postStop"
)

type Hooks

type Hooks map[HookName]HookList

func (Hooks) Register

func (hooks Hooks) Register(name HookName, hook Hook) error

func (Hooks) Run

func (hooks Hooks) Run(name HookName, state *specs.State) error

type InitProcess

type InitProcess struct {
	*ExecProcess
	// contains filtered or unexported fields
}

type Net

type Net struct {
	IPAddress string `json:"ip_address"`
	Gateway   string `json:"gateway"`
	Subnet    string `json:"subnet"`
	Eth       string `json:"eth"`
}

func (*Net) String

func (n *Net) String() string

func (*Net) Validate

func (n *Net) Validate() error

type Sandbox

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

func Create

func Create(root, id string, config *Config) (*Sandbox, error)

func Load

func Load(root, id string, debugOpts bool) (*Sandbox, error)

func (*Sandbox) Boot

func (s *Sandbox) Boot(config *specs.Process) (int, error)

func (*Sandbox) Config

func (s *Sandbox) Config() Config

func (*Sandbox) Destroy

func (s *Sandbox) Destroy() error

func (*Sandbox) ID

func (s *Sandbox) ID() string

func (*Sandbox) NewExecProcess

func (s *Sandbox) NewExecProcess(config *specs.Process) (*InitProcess, error)

func (*Sandbox) NewInitProcess

func (s *Sandbox) NewInitProcess(config *specs.Process) (*InitProcess, error)

func (*Sandbox) PipeName

func (s *Sandbox) PipeName() string

func (*Sandbox) RegisterInitHooks

func (s *Sandbox) RegisterInitHooks() error

func (*Sandbox) Run

func (s *Sandbox) Run(process *InitProcess) error

func (*Sandbox) SetProbe

func (s *Sandbox) SetProbe(probe bool)

func (*Sandbox) SetStable

func (s *Sandbox) SetStable(stable bool)

func (*Sandbox) Signal

func (s *Sandbox) Signal(sig os.Signal) error

func (*Sandbox) Start

func (s *Sandbox) Start(process *InitProcess) error

func (*Sandbox) State

func (s *Sandbox) State() (*State, error)

func (*Sandbox) Status

func (s *Sandbox) Status() (Status, error)

func (*Sandbox) Step

func (s *Sandbox) Step() error

type State

type State struct {
	BaseState
	ExternalDescriptors []string `json:"external_descriptors,omitempty"`
}

func LoadState

func LoadState(root string) (*State, error)

type Status

type Status int
const (
	Created Status = iota
	Running
	Stopped
)

func (Status) String

func (s Status) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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