Documentation
¶
Index ¶
- Constants
- Variables
- func IsInsideInstance() bool
- type GuestClient
- func (g *GuestClient) Config(key string) (string, error)
- func (g *GuestClient) Devices() (map[string]map[string]string, error)
- func (g *GuestClient) HasConfig(key string) (bool, error)
- func (g *GuestClient) Info() (*incus.InstanceInfo, error)
- func (g *GuestClient) ListConfig() ([]string, error)
- func (g *GuestClient) ListenForEvents(ctx context.Context, callback func(*incus.Event), events ...incus.EventType) error
- func (g *GuestClient) Metadata() (string, error)
- func (g *GuestClient) MustConfig(key string) string
Constants ¶
const ( SocketPath = "/dev/incus/sock" InstanceInfoPath = "/1.0/1.0" ListDevicesPath = "/1.0/1.0/devices" ConfigPath = "/1.0/1.0/config" MetadataPath = "/1.0/1.0/meta-data" EventsPath = "/1.0/1.0/events" )
Variables ¶
var UnexpectedStatusCode = errors.New("unexpected status code")
Functions ¶
func IsInsideInstance ¶
func IsInsideInstance() bool
IsIncus attempts to connect to /dev/incus/sock.
Types ¶
type GuestClient ¶
type GuestClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient() *GuestClient
func (*GuestClient) Config ¶
func (g *GuestClient) Config(key string) (string, error)
Config retrieves the value of the specified instance config key.
As instances only have access to user.* and cloud-init.* configuration, provided keys will be prefixed with `user.` unless explicitly specified.
See: https://linuxcontainers.org/incus/docs/main/dev-incus/#config-key
func (*GuestClient) Devices ¶
func (g *GuestClient) Devices() (map[string]map[string]string, error)
Devices returns a map of devices available to the instance.
See: https://linuxcontainers.org/incus/docs/main/dev-incus/#devices
func (*GuestClient) HasConfig ¶
func (g *GuestClient) HasConfig(key string) (bool, error)
HasConfig checks for the presence of the specified config key.
As instances only have access to user.* and cloud-init.* configuration, provided keys will be prefixed with `user.` unless explicitly specified.
See: https://linuxcontainers.org/incus/docs/main/dev-incus/#config-key
func (*GuestClient) Info ¶
func (g *GuestClient) Info() (*incus.InstanceInfo, error)
Info returns information about the API and instance state.
See: https://linuxcontainers.org/incus/docs/main/dev-incus/#id2
func (*GuestClient) ListConfig ¶
func (g *GuestClient) ListConfig() ([]string, error)
ListConfig returns a slice of all config keys available to the instance.
See: https://linuxcontainers.org/incus/docs/main/dev-incus/#config
func (*GuestClient) ListenForEvents ¶
func (g *GuestClient) ListenForEvents(ctx context.Context, callback func(*incus.Event), events ...incus.EventType) error
ListenForEvents opens a WebSocket connection to the guest events API, blocking the current goroutine. It takes a callback function and an optional list of events to subscribe to. If no events are provided, it will subscribe to all of them.
See the definition for incus.EventType for valid values.
func (*GuestClient) Metadata ¶
func (g *GuestClient) Metadata() (string, error)
Metadata returns the value of the `cloud-init.user-data` config key.
See: https://linuxcontainers.org/incus/docs/main/dev-incus/#meta-data
func (*GuestClient) MustConfig ¶
func (g *GuestClient) MustConfig(key string) string
MustConfig calls Config, panicking if there's any error or the key is empty.