container

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBaseImage

func BuildBaseImage(client LXDClient, cfg config.Config) error

BuildBaseImage creates a temporary container, installs deps and agents, then publishes as the base image.

func ContainerExists

func ContainerExists(client LXDClient, name string) bool

ContainerExists checks if a container with the given name exists.

func ContainerRunning

func ContainerRunning(client LXDClient, name string) bool

ContainerRunning checks if a container is in the Running state.

func CreateContainer

func CreateContainer(client LXDClient, name, projectDir string, cfg config.Config) error

CreateContainer creates a new project container from the base image.

func DeriveContainerName

func DeriveContainerName(dir string) string

DeriveContainerName computes the container name from the given directory path. The result is a valid LXD instance name: starts with a letter, 1-63 chars, containing only [a-zA-Z0-9-].

func DestroyContainer

func DestroyContainer(client LXDClient, name string) error

DestroyContainer force-deletes a container.

func ExecInteractive

func ExecInteractive(client LXDClient, name string, cmd []string, opts *ExecOpts) error

ExecInteractive runs an interactive command with TTY in the container.

func ExecSimple

func ExecSimple(client LXDClient, name string, cmd []string) (string, int, error)

ExecSimple runs a command in the container and returns combined output + exit code.

func ForwardCredentialEnv

func ForwardCredentialEnv(client LXDClient, name string, cfg config.Config)

ForwardCredentialEnv sets credential environment variables on the container and writes them to a shell profile so they survive su -l.

func LaunchInstance

func LaunchInstance(client LXDClient, name, imageSpec string) error

LaunchInstance creates an instance from a local or remote image. Image spec can be "alias" (local) or "remote:alias" (e.g. "ubuntu:24.04").

func ListLBContainers

func ListLBContainers(client LXDClient) ([]api.Instance, error)

ListLBContainers returns all instances created by lincubate.

func PushContent

func PushContent(client LXDClient, containerName, containerPath, content string, uid, gid int64, mode int) error

PushContent writes content directly into a file in the container.

func PushFile

func PushFile(client LXDClient, containerName, hostPath, containerPath string, uid, gid int64) error

PushFile copies a host file into the container.

func RunUpdaters

func RunUpdaters(client LXDClient, name string, cfg config.Config)

RunUpdaters runs the updater commands on an existing container.

func SetupGUI

func SetupGUI(client LXDClient, name string, cfg config.Config)

SetupGUI configures GPU, X11, and display environment if GUI mode is active.

func StartExisting

func StartExisting(client LXDClient, name string, cfg config.Config) error

StartExisting starts an existing container and runs setup.

func StopContainer

func StopContainer(client LXDClient, name string) error

StopContainer force-stops a container.

func WaitCloudInit

func WaitCloudInit(client LXDClient, name string)

WaitCloudInit waits for cloud-init to finish if it exists in the container.

func WaitFull

func WaitFull(client LXDClient, name string) error

WaitFull does the full wait sequence: basic ready + cloud-init + network.

func WaitNetwork

func WaitNetwork(client LXDClient, name string)

WaitNetwork polls for network connectivity.

func WaitQuiet

func WaitQuiet(client LXDClient, name string) bool

WaitQuiet does a quiet wait with fewer retries, no cloud-init/network.

func WaitReady

func WaitReady(client LXDClient, name string, maxRetries int, quiet bool) bool

WaitReady polls until exec works in the container (up to maxRetries, 1s apart).

Types

type ExecOpts

type ExecOpts struct {
	User        uint32
	Group       uint32
	Cwd         string
	Environment map[string]string
}

ExecOpts configures optional fields for interactive exec.

type LXDClient

type LXDClient interface {
	GetInstance(name string) (*api.Instance, string, error)
	GetInstances(args lxd.GetInstancesArgs) ([]api.Instance, error)
	CreateInstance(instance api.InstancesPost) (lxd.Operation, error)
	CreateInstanceFromImage(source lxd.ImageServer, image api.Image, req api.InstancesPost) (lxd.RemoteOperation, error)
	UpdateInstance(name string, instance api.InstancePut, ETag string) (lxd.Operation, error)
	DeleteInstance(name string, force bool) (lxd.Operation, error)
	UpdateInstanceState(name string, state api.InstanceStatePut, ETag string) (lxd.Operation, error)
	ExecInstance(name string, exec api.InstanceExecPost, args *lxd.InstanceExecArgs) (lxd.Operation, error)
	CreateInstanceFile(name string, path string, args lxd.InstanceFileArgs) error
	GetImageAlias(name string) (*api.ImageAliasesEntry, string, error)
	CreateImage(image api.ImagesPost, args *lxd.ImageCreateArgs) (lxd.Operation, error)
	DeleteImage(fingerprint string) (lxd.Operation, error)
}

LXDClient abstracts LXD operations for testing.

func ConnectLXD

func ConnectLXD() (LXDClient, error)

ConnectLXD connects to the local LXD daemon.

Jump to

Keyboard shortcuts

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