incus

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package incus implements the sandbox.Sandbox interface using a native Incus daemon connection (local unix socket or remote HTTPS).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Incus

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

Incus implements sandbox.Sandbox using a native Incus daemon connection.

func New

func New(cfg map[string]string) (*Incus, error)

New creates an Incus sandbox backend from a flat config map.

func (*Incus) AllowDomain

func (i *Incus) AllowDomain(ctx context.Context, name, domain string) error

AllowDomain adds a domain to the egress allowlist and re-resolves.

func (*Incus) Capabilities

func (i *Incus) Capabilities() sandbox.Capabilities

Capabilities advertises that the Incus backend supports all optional features.

func (*Incus) CloneFrom

func (i *Incus) CloneFrom(ctx context.Context, source, label, newName string) error

CloneFrom copies an instance from a source snapshot into a new instance, then starts it. Volatile keys (notably volatile.eth0.hwaddr) are stripped so Incus regenerates them on the destination — otherwise the clone would boot with a duplicate MAC and fail eth0 validation.

func (*Incus) Close

func (i *Incus) Close() error

Close is a no-op for the Incus backend (no persistent connection to close).

func (*Incus) Console

func (i *Incus) Console(ctx context.Context, name string, opts sandbox.ConsoleOpts) error

Console attaches an interactive console session to a container.

func (*Incus) Create

func (i *Incus) Create(ctx context.Context, opts sandbox.CreateOpts) (*sandbox.Instance, error)

Create creates a new container instance with the full provisioning flow. When opts.Bare is true, only the instance is created (no provisioning).

func (*Incus) CreateSnapshot

func (i *Incus) CreateSnapshot(ctx context.Context, name, label string) error

CreateSnapshot creates a snapshot for the named instance.

func (*Incus) Delete

func (i *Incus) Delete(ctx context.Context, name string) error

Delete stops (if running) and deletes an instance.

func (*Incus) DeleteFile added in v0.6.0

func (i *Incus) DeleteFile(ctx context.Context, name, p string) error

DeleteFile removes a single file via the native Incus file API.

func (*Incus) DeleteSnapshot

func (i *Incus) DeleteSnapshot(ctx context.Context, name, label string) error

DeleteSnapshot deletes a snapshot by label.

func (*Incus) DenyDomain

func (i *Incus) DenyDomain(ctx context.Context, name, domain string) error

DenyDomain removes a domain from the egress allowlist and re-resolves.

func (*Incus) Get

func (i *Incus) Get(ctx context.Context, name string) (*sandbox.Instance, error)

Get returns a single instance by bare name.

func (*Incus) GetPolicy

func (i *Incus) GetPolicy(ctx context.Context, name string) (*sandbox.Policy, error)

GetPolicy returns the current egress policy for an instance.

func (*Incus) List

func (i *Incus) List(ctx context.Context) ([]sandbox.Instance, error)

List returns all px- prefixed instances with the prefix stripped.

func (*Incus) ListFiles added in v0.6.0

func (i *Incus) ListFiles(ctx context.Context, name, p string, recursive bool) ([]sandbox.FileEntry, error)

ListFiles enumerates entries via shell `find -printf` since the Incus file API doesn't expose size in directory listings.

func (*Incus) ListSnapshots

func (i *Incus) ListSnapshots(ctx context.Context, name string) ([]sandbox.Snapshot, error)

ListSnapshots returns all snapshots for the named instance.

func (*Incus) Output

func (i *Incus) Output(ctx context.Context, name string, cmd []string) ([]byte, error)

Output executes a command and returns its stdout.

func (*Incus) ReadFile added in v0.6.0

func (i *Incus) ReadFile(ctx context.Context, name, p string, maxBytes int64) ([]byte, bool, error)

ReadFile streams the file (or first maxBytes) into memory via the native Incus file API. If maxBytes>0 and the file is larger, returns truncated=true.

func (*Incus) Ready

func (i *Incus) Ready(ctx context.Context, name string, timeout time.Duration) error

Ready waits until the instance is running and reachable.

func (*Incus) RestoreSnapshot

func (i *Incus) RestoreSnapshot(ctx context.Context, name, label string) error

RestoreSnapshot rolls back to the given snapshot: stop, restore, start.

func (*Incus) Run

func (i *Incus) Run(ctx context.Context, name string, opts sandbox.ExecOpts) (int, error)

Run executes a command inside a sandbox instance and returns its exit code.

func (*Incus) SetEgressMode

func (i *Incus) SetEgressMode(ctx context.Context, name string, mode sandbox.EgressMode) error

SetEgressMode sets the egress filtering mode for a container.

func (*Incus) Start

func (i *Incus) Start(ctx context.Context, name string) error

Start starts a stopped instance.

func (*Incus) Stop

func (i *Incus) Stop(ctx context.Context, name string) error

Stop stops a running instance.

func (*Incus) WriteFile added in v0.6.0

func (i *Incus) WriteFile(ctx context.Context, name, p string, content []byte, mode os.FileMode, uid, gid int) error

WriteFile writes content to path inside the container via the native Incus file API. Parents are created as 0o755 directories (mkdir-p semantics). uid/gid set ownership; pass sandbox.NoOwner (negative) to leave the file root-owned (the filesystem-API default).

Jump to

Keyboard shortcuts

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