Documentation
¶
Index ¶
Constants ¶
const DockerComposeProjectPrefix = "workstation-windsor-"
DockerComposeProjectPrefix is the prefix of the com.docker.compose.project label of a context.
const (
IncusNetworkName = "incusbr0"
)
const WindsorNetworkPrefix = "windsor-"
WindsorNetworkPrefix is the prefix of the Docker network of a context, for example windsor-local.
Variables ¶
var RETRY_WAIT = func() int { return map[bool]int{true: 0, false: 2}[os.Getenv("CI") == "true"] }()
RETRY_WAIT is the number of seconds between VM retries. It is 0 when CI is "true".
Functions ¶
This section is empty.
Types ¶
type BaseVirt ¶
type BaseVirt struct {
// contains filtered or unexported fields
}
BaseVirt holds the dependencies that every Virt implementation shares.
func NewBaseVirt ¶
NewBaseVirt returns a BaseVirt for rt. It panics when rt, its shell, or its config handler is nil.
type ColimaVirt ¶
type ColimaVirt struct {
*BaseVirt
}
ColimaVirt is the VirtualMachine for Colima.
func NewColimaVirt ¶
func NewColimaVirt(rt *runtime.Runtime) *ColimaVirt
NewColimaVirt returns a ColimaVirt for rt. It panics when rt is nil.
func (*ColimaVirt) Down ¶
func (v *ColimaVirt) Down(ctx context.Context) error
Down stops and deletes the Colima VM, ensuring resources are reclaimed. Attempts graceful shutdown, then deletes the VM. Returns an error if deletion fails.
func (*ColimaVirt) Up ¶
func (v *ColimaVirt) Up(ctx context.Context) error
Up starts the Colima VM and configures its network settings. It initializes the VM with the appropriate configuration and waits for it to become ready. If the VM is already running, it skips the start operation and reuses the existing VM. It returns an error with a remediation when the mounts of the running VM differ from colima.yaml. The VM address is set in the configuration handler for later use. Kills stuck processes before starting if VM is not already running to prevent vmnet/daemon issues. Returns an error if the VM fails to start or if the address cannot be set.
func (*ColimaVirt) WriteConfig ¶
func (v *ColimaVirt) WriteConfig() error
WriteConfig writes ~/.colima/windsor-<context>/colima.yaml from the context and the host resources. It writes a temporary file and then renames it to the final file. It does nothing when workstation.runtime is not colima.
type ContainerRuntime ¶
type ContainerRuntime interface {
Virt
}
ContainerRuntime is a Virt that runs containers.
type DockerVirt ¶
type DockerVirt struct {
*BaseVirt
}
DockerVirt is the ContainerRuntime for platform docker.
func NewDockerVirt ¶
func NewDockerVirt(rt *runtime.Runtime) *DockerVirt
NewDockerVirt returns a DockerVirt for rt. It panics when rt is nil.
func (*DockerVirt) Down ¶
func (v *DockerVirt) Down(ctx context.Context) error
Down removes the containers, the named volumes, and the network of the context, and nothing else. It finds the containers and volumes by the label com.docker.compose.project=workstation-windsor-<context>. It does nothing when DOCKER_HOST names a unix socket that does not exist, because the VM is gone. It shows each failure as a warning and always returns nil.
type IncusInstance ¶ added in v0.9.0
type IncusInstance struct {
Name string `json:"name"`
Status string `json:"status"`
StatusCode int `json:"status_code"`
Type string `json:"type"`
ExpandedDevices map[string]interface{} `json:"expanded_devices"`
}
IncusInstance represents an Incus instance parsed from JSON output. It contains the instance name, status information, type, and expanded device configurations as returned by the Incus CLI when listing instances.
type IncusInstanceConfig ¶ added in v0.9.0
type IncusInstanceConfig struct {
Name string
Type string
Image string
Config map[string]string
Devices map[string]map[string]string
Profiles []string
IPv4 string
Network string
Resources map[string]string
}
IncusInstanceConfig represents the complete configuration for creating an Incus instance. It contains all necessary parameters including instance name, type, image, network settings, device configurations, profiles, and resource limits required for instance creation.
type IncusOperation ¶ added in v0.9.0
type IncusOperation struct {
ID string `json:"id"`
Class string `json:"class"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Status string `json:"status"`
StatusCode int `json:"status_code"`
Resources map[string]any `json:"resources"`
Metadata map[string]any `json:"metadata"`
MayCancel bool `json:"may_cancel"`
Err string `json:"err"`
}
IncusOperation represents an Incus operation parsed from JSON output. It contains operation metadata including ID, status, timestamps, resources affected, and error information as returned by the Incus CLI when listing operations.
type IncusRemote ¶ added in v0.9.0
type IncusRemote struct {
Name string `json:"name"`
URL string `json:"url"`
Protocol string `json:"protocol"`
Public bool `json:"public"`
}
IncusRemote represents an Incus remote repository parsed from JSON output. It contains the remote name, URL, protocol type, and public access flag as returned by the Incus CLI when listing configured remotes.
type IncusVirt ¶ added in v0.9.0
type IncusVirt struct {
*ColimaVirt
// contains filtered or unexported fields
}
IncusVirt implements both the ContainerRuntime and VirtualMachine interfaces for Incus. It embeds ColimaVirt to inherit Colima VM functionality. Instance creation is handled by Terraform in the stack.
func NewIncusVirt ¶ added in v0.9.0
NewIncusVirt returns an IncusVirt for rt that embeds a ColimaVirt for the VM.
func (*IncusVirt) Down ¶ added in v0.9.0
Down stops the Colima daemon and deletes the VM. Off platform incus, it only deletes the VM.
type MockVirt ¶
type MockVirt struct {
UpFunc func(verbose ...bool) error
DownFunc func() error
WriteConfigFunc func() error
}
MockVirt is a struct that simulates a virt environment for testing purposes.
func (*MockVirt) Down ¶
Down stops the mock virt. If a custom DownFunc is provided, it will use that function instead.
func (*MockVirt) Up ¶
Up starts the mock virt. If a custom UpFunc is provided, it will use that function instead.
func (*MockVirt) WriteConfig ¶
WriteConfig writes the configuration of the mock virt. If a custom WriteConfigFunc is provided, it will use that function instead.
type Shims ¶
type Shims struct {
shims.Shims
GOARCH func() string
NumCPU func() int
VirtualMemory func() (*mem.VirtualMemoryStat, error)
NewYAMLEncoder func(w io.Writer, opts ...yaml.EncodeOption) YAMLEncoder
}
Shims holds the shared system call primitives and the host shims of the virt package.
type Virt ¶
type Virt interface {
Up(ctx context.Context) error
Down(ctx context.Context) error
WriteConfig() error
}
Virt starts, stops, and writes the configuration of a VM or a container runtime.
type VirtualMachine ¶
type VirtualMachine interface {
Virt
}
VirtualMachine is a Virt that runs a VM.
type YAMLEncoder ¶
YAMLEncoder is an interface for encoding YAML data.