{"modulePath":"github.com/windsorcli/cli","version":"v0.7.1","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package virt\n\n## Variables\n\n```go\nvar RETRY_WAIT = func() int {\n\treturn map[bool]int{true: 0, false: 2}[os.Getenv(\"CI\") == \"true\"]\n}()\n```\nRETRY\\_WAIT is the number of seconds to wait between retries when starting or stopping a VM If running in CI, no wait is performed\n\n## Types\n\n```go\ntype BaseVirt struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewBaseVirt(injector di.Injector) *BaseVirt\n```\nNewBaseVirt creates a new BaseVirt instance\n\n```go\nfunc (v *BaseVirt) Initialize() error\n```\nInitialize is a method that initializes the virt environment\n\n```go\ntype ColimaVirt struct {\n\t*BaseVirt\n}\n```\nColimaVirt implements the VirtInterface and VMInterface for Colima\n\n```go\nfunc NewColimaVirt(injector di.Injector) *ColimaVirt\n```\nNewColimaVirt creates a new instance of ColimaVirt using a DI injector\n\n```go\nfunc (v *ColimaVirt) Down() error\n```\nDown stops and deletes the Colima VM First stops the VM and then deletes it to ensure a clean shutdown Returns an error if either the stop or delete operation fails\n\n```go\nfunc (v *ColimaVirt) GetVMInfo() (VMInfo, error)\n```\nGetVMInfo returns the information about the Colima VM Retrieves the VM details from the Colima CLI and parses the JSON output Converts memory and disk values from bytes to gigabytes for easier consumption Returns a VMInfo struct with the parsed information or an error if retrieval fails\n\n```go\nfunc (v *ColimaVirt) PrintInfo() error\n```\nPrintInfo prints the information about the Colima VM Retrieves the VM information and formats it in a tabular display Shows the VM name, architecture, CPU count, memory, disk size, and IP address Returns an error if the VM information cannot be retrieved\n\n```go\nfunc (v *ColimaVirt) Up() error\n```\nUp starts the Colima VM and configures its network settings Initializes the VM with the appropriate configuration and waits for it to be ready Sets the VM address in the configuration handler for later use Returns an error if the VM fails to start or if the address cannot be set\n\n```go\nfunc (v *ColimaVirt) WriteConfig() error\n```\nWriteConfig writes the Colima configuration file with VM settings Generates a configuration based on the current context and system properties Creates a temporary file and then renames it to the final configuration file Returns an error if any step of the configuration process fails\n\n```go\ntype ContainerInfo struct {\n\tName    string\n\tAddress string\n\tLabels  map[string]string\n}\n```\n\n```go\ntype ContainerRuntime interface {\n\tVirt\n\tGetContainerInfo(name ...string) ([]ContainerInfo, error)\n}\n```\nContainerRuntime defines methods for container operations\n\n```go\ntype DockerVirt struct {\n\tBaseVirt\n\t// contains filtered or unexported fields\n}\n```\nDockerVirt implements the ContainerInterface for Docker\n\n```go\nfunc NewDockerVirt(injector di.Injector) *DockerVirt\n```\nNewDockerVirt creates a new instance of DockerVirt using a DI injector\n\n```go\nfunc (v *DockerVirt) Down() error\n```\nDown stops all Docker containers managed by Windsor and removes associated volumes. It ensures a clean shutdown by verifying Docker is enabled, checking the daemon status, and executing docker compose down with --remove-orphans and --volumes flags. If the compose file is missing, the operation is idempotent and exits without error.\n\n```go\nfunc (v *DockerVirt) GetContainerInfo(name ...string) ([]ContainerInfo, error)\n```\nGetContainerInfo retrieves detailed information about Docker containers managed by Windsor, including their names, IP addresses, and labels. It filters containers by Windsor-managed labels and context, and optionally by service name if provided. For each container, it retrieves network settings to determine IP addresses.\n\n```go\nfunc (v *DockerVirt) Initialize() error\n```\nInitialize resolves all dependencies for DockerVirt, including services from the DI container, Docker configuration status, and determines the appropriate docker compose command to use. It alphabetizes services and verifies Docker is enabled.\n\n```go\nfunc (v *DockerVirt) PrintInfo() error\n```\nPrintInfo displays a formatted table of running Docker containers with their names, IP addresses, and roles. It retrieves container information using GetContainerInfo and presents it in a tabular format for easy reading. If no containers are running, it displays an appropriate message.\n\n```go\nfunc (v *DockerVirt) Up() error\n```\nUp starts docker compose in detached mode with retry logic for reliability. It verifies Docker is enabled, checks the daemon is running, sets the compose file path, and attempts to start services with up to 3 retries if initial attempts fail.\n\n```go\nfunc (v *DockerVirt) WriteConfig() error\n```\nWriteConfig generates and writes the Docker Compose configuration file by combining settings from all services. It creates the necessary directory structure, retrieves the full compose configuration, serializes it to YAML, and writes it to the .windsor directory with appropriate permissions.\n\n```go\ntype MockVirt struct {\n\tInitializeFunc       func() error\n\tUpFunc               func(verbose ...bool) error\n\tDownFunc             func() error\n\tPrintInfoFunc        func() error\n\tWriteConfigFunc      func() error\n\tGetVMInfoFunc        func() (VMInfo, error)\n\tGetContainerInfoFunc func(name ...string) ([]ContainerInfo, error)\n}\n```\nMockVirt is a struct that simulates a virt environment for testing purposes.\n\n```go\nfunc NewMockVirt() *MockVirt\n```\nNewMockVirt creates a new instance of MockVirt.\n\n```go\nfunc (m *MockVirt) Down() error\n```\nDown stops the mock virt. If a custom DownFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockVirt) GetContainerInfo(name ...string) ([]ContainerInfo, error)\n```\nGetContainerInfo retrieves information about the mock containers. If a custom GetContainerInfoFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockVirt) GetVMInfo() (VMInfo, error)\n```\nGetVMInfo retrieves information about the mock VM. If a custom GetVMInfoFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockVirt) Initialize() error\n```\nInitialize initializes the mock virt. If a custom InitializeFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockVirt) PrintInfo() error\n```\nPrintInfo prints information about the mock virt. If a custom PrintInfoFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockVirt) Up() error\n```\nUp starts the mock virt. If a custom UpFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockVirt) WriteConfig() error\n```\nWriteConfig writes the configuration of the mock virt. If a custom WriteConfigFunc is provided, it will use that function instead.\n\n```go\ntype Shims struct {\n\tSetenv         func(key, value string) error\n\tUnmarshalJSON  func(data []byte, v any) error\n\tUserHomeDir    func() (string, error)\n\tMkdirAll       func(path string, perm os.FileMode) error\n\tWriteFile      func(name string, data []byte, perm os.FileMode) error\n\tRename         func(oldpath, newpath string) error\n\tStat           func(name string) (os.FileInfo, error)\n\tGOARCH         func() string\n\tNumCPU         func() int\n\tVirtualMemory  func() (*mem.VirtualMemoryStat, error)\n\tMarshalYAML    func(v any) ([]byte, error)\n\tNewYAMLEncoder func(w io.Writer, opts ...yaml.EncodeOption) YAMLEncoder\n}\n```\nShims provides mockable wrappers around system and runtime functions\n\n```go\nfunc NewShims() *Shims\n```\nNewShims creates a new Shims instance with default implementations\n\n```go\ntype VMInfo struct {\n\tAddress string\n\tArch    string\n\tCPUs    int\n\tDisk    int\n\tMemory  int\n\tName    string\n}\n```\nVMInfo is a struct that holds the information about the VM\n\n```go\ntype Virt interface {\n\tInitialize() error\n\tUp() error\n\tDown() error\n\tPrintInfo() error\n\tWriteConfig() error\n}\n```\nVirt defines methods for the virt operations\n\n```go\ntype VirtualMachine interface {\n\tVirt\n\tGetVMInfo() (VMInfo, error)\n}\n```\nVirtualMachine defines methods for VirtualMachine operations\n\n```go\ntype YAMLEncoder interface {\n\tEncode(v any) error\n\tClose() error\n}\n```\nYAMLEncoder is an interface for encoding YAML data.\n\n","path":"github.com/windsorcli/cli/pkg/virt","name":"virt","synopsis":"","isRedistributable":true}
