Documentation
¶
Overview ¶
Package incus implements the compute.Backend seam over the Incus API.
Index ¶
- type Client
- func (c *Client) AddACLRule(ctx context.Context, sandbox, network string, rule compute.ACLRule) (compute.ACLRule, error)
- func (c *Client) AttachNIC(ctx context.Context, ref compute.Ref, network, nic, ip, mac string) (compute.NIC, error)
- func (c *Client) BeginCreateInstance(ctx context.Context, req compute.CreateInstance) (compute.PendingInstance, error)
- func (c *Client) Close() error
- func (c *Client) CreateForward(ctx context.Context, sandbox, network string, ref compute.Ref, ...) (compute.Forward, error)
- func (c *Client) CreateNetwork(ctx context.Context, sandbox string, network compute.Network) (compute.Network, error)
- func (c *Client) CreateSandbox(ctx context.Context, sandbox compute.Sandbox) error
- func (c *Client) CreateSnapshot(ctx context.Context, ref compute.Ref, snapshot string) error
- func (c *Client) DeleteFile(ctx context.Context, ref compute.Ref, path string) error
- func (c *Client) DeleteInstance(ctx context.Context, ref compute.Ref) error
- func (c *Client) DeleteNetwork(ctx context.Context, sandbox, name string) error
- func (c *Client) DeleteSandbox(ctx context.Context, name string) error
- func (c *Client) DeleteSnapshot(ctx context.Context, ref compute.Ref, snapshot string) error
- func (c *Client) DetachNIC(ctx context.Context, ref compute.Ref, nic string) error
- func (c *Client) EnsureCatalog(ctx context.Context, images []compute.CatalogImage) ([]compute.CatalogImage, error)
- func (c *Client) Exec(ctx context.Context, req compute.ExecRequest, stdout, stderr io.Writer) (int64, error)
- func (c *Client) ExtendSandbox(ctx context.Context, name string, expires time.Time) (compute.Sandbox, error)
- func (c *Client) GetInstance(ctx context.Context, ref compute.Ref) (compute.Instance, error)
- func (c *Client) GetNetwork(ctx context.Context, sandbox, name string) (compute.Network, error)
- func (c *Client) GetSandbox(ctx context.Context, name string) (compute.Sandbox, error)
- func (c *Client) GetSandboxImage(ctx context.Context, sandbox, name string) (compute.CatalogImage, error)
- func (c *Client) InstanceForward(ctx context.Context, ref compute.Ref, targetPort int64, protocol string) (compute.Forward, error)
- func (c *Client) ListInstances(ctx context.Context, sandbox string) ([]compute.Instance, error)
- func (c *Client) ListNetworks(ctx context.Context, sandbox string) ([]compute.Network, error)
- func (c *Client) ListSandboxes(ctx context.Context) ([]compute.Sandbox, error)
- func (c *Client) ListSnapshots(ctx context.Context, ref compute.Ref) ([]compute.Snapshot, error)
- func (c *Client) OpenExec(ctx context.Context, req compute.ExecRequest) (io.ReadWriteCloser, error)
- func (c *Client) PeerNetworks(ctx context.Context, sandbox, network, peer string) error
- func (c *Client) PinSandbox(ctx context.Context, name string, pinned bool, subject string, since time.Time) (compute.Sandbox, error)
- func (c *Client) PublishInstance(ctx context.Context, ref compute.Ref, image string) (string, error)
- func (c *Client) ReadBinaryFile(ctx context.Context, ref compute.Ref, path string) (io.ReadCloser, error)
- func (c *Client) ReadFile(ctx context.Context, req compute.FileReadRequest) (compute.FileReadResult, error)
- func (c *Client) RemoteImage(ctx context.Context, name string) (incusclient.ImageServer, error)
- func (c *Client) RemoveACLRule(ctx context.Context, sandbox, network, ruleID string) error
- func (c *Client) RestartInstance(ctx context.Context, ref compute.Ref, force bool) (compute.Instance, error)
- func (c *Client) RestoreSnapshot(ctx context.Context, ref compute.Ref, snapshot string) error
- func (c *Client) Scoped(ctx context.Context, project, target string) incusclient.InstanceServer
- func (c *Client) StartInstance(ctx context.Context, ref compute.Ref, force bool) (compute.Instance, error)
- func (c *Client) StopInstance(ctx context.Context, ref compute.Ref, force bool) (compute.Instance, error)
- func (c *Client) WaitInstance(ctx context.Context, req compute.WaitRequest) (compute.WaitResult, error)
- func (c *Client) WriteFile(ctx context.Context, req compute.FileWriteRequest) (compute.FileWriteResult, error)
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the Incus adapter used by compute.Service.
func (*Client) AddACLRule ¶
func (*Client) AttachNIC ¶
func (c *Client) AttachNIC(ctx context.Context, ref compute.Ref, network, nic, ip, mac string) (compute.NIC, error)
AttachNIC adds a nic device on a metadata-resolved network.
func (*Client) BeginCreateInstance ¶
func (c *Client) BeginCreateInstance(ctx context.Context, req compute.CreateInstance) (compute.PendingInstance, error)
BeginCreateInstance copies the image if needed and accepts the create request.
func (*Client) CreateForward ¶
func (*Client) CreateNetwork ¶
func (c *Client) CreateNetwork(ctx context.Context, sandbox string, network compute.Network) (compute.Network, error)
CreateNetwork defines a bridge in the default project or an OVN network in the sandbox project.
func (*Client) CreateSandbox ¶
CreateSandbox creates a restricted project and its default network.
func (*Client) CreateSnapshot ¶
CreateSnapshot creates a stateless instance snapshot.
func (*Client) DeleteFile ¶
DeleteFile removes a guest file through the Incus agent.
func (*Client) DeleteInstance ¶
DeleteInstance force-stops and deletes one guest, including snapshots.
func (*Client) DeleteNetwork ¶
DeleteNetwork removes an owned network after dependents are gone.
func (*Client) DeleteSandbox ¶
DeleteSandbox removes sandbox resources in dependency order.
Partial failures are returned so the reaper can retry. The project is never deleted while owned networks still exist.
func (*Client) DeleteSnapshot ¶
DeleteSnapshot deletes one instance snapshot.
func (*Client) EnsureCatalog ¶
func (c *Client) EnsureCatalog(ctx context.Context, images []compute.CatalogImage) ([]compute.CatalogImage, error)
EnsureCatalog imports catalog images into the image-build project and returns copies with derived fingerprints.
Lab-built imgoci digest references are fetched, verified, imported, and promoted to a local alias only after a successful smoke launch. A matching agentcompute.digest on the current alias skips import and smoke. Upstream remote:alias references only ensure the Incus remote exists. Returned entries keep the original Reference.
func (*Client) Exec ¶
func (c *Client) Exec(ctx context.Context, req compute.ExecRequest, stdout, stderr io.Writer) (int64, error)
Exec runs a command and drains stdout/stderr. Cancellation sends SIGKILL over the exec control websocket and then waits a bounded teardown.
func (*Client) ExtendSandbox ¶
func (c *Client) ExtendSandbox(ctx context.Context, name string, expires time.Time) (compute.Sandbox, error)
ExtendSandbox writes a new expiry with an ETag update.
func (*Client) GetInstance ¶
GetInstance returns observed guest state from GetInstanceFull.
func (*Client) GetNetwork ¶
GetNetwork returns one owned agent-facing network.
func (*Client) GetSandbox ¶
GetSandbox returns one owned sandbox.
func (*Client) GetSandboxImage ¶
func (c *Client) GetSandboxImage(ctx context.Context, sandbox, name string) (compute.CatalogImage, error)
GetSandboxImage returns a published sandbox-local image as a catalog entry.
func (*Client) InstanceForward ¶
func (c *Client) InstanceForward( ctx context.Context, ref compute.Ref, targetPort int64, protocol string, ) (compute.Forward, error)
InstanceForward observes the scalar forward shape created by net.forward.
func (*Client) ListInstances ¶
ListInstances returns guests in a sandbox project.
func (*Client) ListNetworks ¶
ListNetworks returns agent-facing networks owned by the sandbox.
Ownership is resolved from network metadata and project reservations, never by parsing physical names.
func (*Client) ListSandboxes ¶
ListSandboxes returns owned sandbox projects.
func (*Client) ListSnapshots ¶
ListSnapshots returns snapshots for one guest.
func (*Client) OpenExec ¶
func (c *Client) OpenExec(ctx context.Context, req compute.ExecRequest) (io.ReadWriteCloser, error)
OpenExec starts a guest command and returns attached stdin/stdout. Close sends SIGKILL and waits a bounded teardown. The start context does not bound a successful stream.
func (*Client) PeerNetworks ¶
func (*Client) PinSandbox ¶ added in v0.1.5
func (c *Client) PinSandbox( ctx context.Context, name string, pinned bool, subject string, since time.Time, ) (compute.Sandbox, error)
PinSandbox persists pin metadata with an ETag update, preserving expiry.
func (*Client) PublishInstance ¶
func (c *Client) PublishInstance(ctx context.Context, ref compute.Ref, image string) (string, error)
PublishInstance creates a project-local image alias from a guest.
The image stays in the sandbox project. Catalog copies already in the project are left untouched and nothing is published to a remote or the default project.
func (*Client) ReadBinaryFile ¶
func (c *Client) ReadBinaryFile(ctx context.Context, ref compute.Ref, path string) (io.ReadCloser, error)
ReadBinaryFile opens a guest file without passing bytes through exec or text conversion. The caller must close the stream and enforce its own byte bound.
func (*Client) ReadFile ¶
func (c *Client) ReadFile(ctx context.Context, req compute.FileReadRequest) (compute.FileReadResult, error)
ReadFile pulls a bounded guest file through the Incus agent.
func (*Client) RemoteImage ¶
func (c *Client) RemoteImage(ctx context.Context, name string) (incusclient.ImageServer, error)
RemoteImage returns an image server for an existing client remote.
The default images simplestreams remote is ensured in memory and is not written back to the on-disk Incus config.
func (*Client) RemoveACLRule ¶
func (*Client) RestartInstance ¶
func (c *Client) RestartInstance(ctx context.Context, ref compute.Ref, force bool) (compute.Instance, error)
RestartInstance restarts a guest and waits until it is running.
func (*Client) RestoreSnapshot ¶
RestoreSnapshot recreates a guest from a snapshot without relaxing project restrictions.
func (*Client) Scoped ¶
func (c *Client) Scoped(ctx context.Context, project, target string) incusclient.InstanceServer
Scoped returns a request-scoped Incus client.
Incus WithContext mutates the receiver, so Scoped always clones with UseProject then UseTarget before WithContext.
func (*Client) StartInstance ¶
func (c *Client) StartInstance(ctx context.Context, ref compute.Ref, force bool) (compute.Instance, error)
StartInstance starts a guest and waits until it is running.
func (*Client) StopInstance ¶
func (c *Client) StopInstance(ctx context.Context, ref compute.Ref, force bool) (compute.Instance, error)
StopInstance stops a guest and waits until it is stopped.
func (*Client) WaitInstance ¶
func (c *Client) WaitInstance(ctx context.Context, req compute.WaitRequest) (compute.WaitResult, error)
WaitInstance polls guest state until the requested stage is reached.
func (*Client) WriteFile ¶
func (c *Client) WriteFile(ctx context.Context, req compute.FileWriteRequest) (compute.FileWriteResult, error)
WriteFile pushes a bounded guest file through the Incus agent.
type Options ¶
type Options struct {
// Remote is an existing Incus client remote name from the local config.
Remote string
// URL is an explicit daemon URL. When set it overrides Remote.
URL string
// ClientCert is a PEM document or path to the client certificate.
ClientCert string
// ClientKey is a PEM document or path to the client key.
ClientKey string
// ServerCert is a PEM document or path to the remote server certificate.
ServerCert string
// Host is the slice-1 cluster member that owns bridge-backed sandboxes.
Host string
// Pool is the storage pool used for explicit root disks.
Pool string
// OVNUplink is the default-project physical network for sandbox OVN networks.
OVNUplink string
// OVNRanges is the external subnet authorization on the physical uplink.
OVNRanges string
}
Options configures an Incus API client.