Documentation
¶
Index ¶
Constants ¶
This section is empty.
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 to wait between retries when starting or stopping a VM If running in CI, no wait is performed
Functions ¶
This section is empty.
Types ¶
type BaseVirt ¶
type BaseVirt struct {
// contains filtered or unexported fields
}
func NewBaseVirt ¶
NewBaseVirt creates a new BaseVirt instance
type ColimaVirt ¶
type ColimaVirt struct {
*BaseVirt
}
ColimaVirt implements the VirtInterface and VMInterface for Colima
func NewColimaVirt ¶
func NewColimaVirt(rt *runtime.Runtime) *ColimaVirt
NewColimaVirt creates a new instance of ColimaVirt
func (*ColimaVirt) Down ¶
func (v *ColimaVirt) Down() error
Down 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
func (*ColimaVirt) Up ¶
func (v *ColimaVirt) Up() error
Up 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
func (*ColimaVirt) WriteConfig ¶
func (v *ColimaVirt) WriteConfig() error
WriteConfig 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
type ContainerInfo ¶
type ContainerRuntime ¶
type ContainerRuntime interface {
Virt
}
ContainerRuntime defines methods for container operations
type DockerVirt ¶
type DockerVirt struct {
BaseVirt
// contains filtered or unexported fields
}
DockerVirt implements the ContainerInterface for Docker
func NewDockerVirt ¶
func NewDockerVirt(rt *runtime.Runtime, serviceList []services.Service) *DockerVirt
NewDockerVirt creates a new instance of DockerVirt
func (*DockerVirt) Down ¶
func (v *DockerVirt) Down() error
Down 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.
func (*DockerVirt) Up ¶
func (v *DockerVirt) Up() error
Up starts Docker Compose in detached mode with retry logic. It checks if Docker is enabled, verifies the Docker daemon is running, regenerates the Docker Compose configuration when running in a Colima VM to ensure network and driver options are compatible with Colima's requirements, sets the COMPOSE_FILE environment variable, and attempts to start services with up to 3 retries. Returns an error if all attempts fail or if prerequisites are not met.
func (*DockerVirt) WriteConfig ¶
func (v *DockerVirt) WriteConfig() error
WriteConfig 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.
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 {
Setenv func(key, value string) error
UnmarshalJSON func(data []byte, v any) error
UserHomeDir func() (string, error)
MkdirAll func(path string, perm os.FileMode) error
WriteFile func(name string, data []byte, perm os.FileMode) error
Rename func(oldpath, newpath string) error
Stat func(name string) (os.FileInfo, error)
GOARCH func() string
NumCPU func() int
VirtualMemory func() (*mem.VirtualMemoryStat, error)
MarshalYAML func(v any) ([]byte, error)
NewYAMLEncoder func(w io.Writer, opts ...yaml.EncodeOption) YAMLEncoder
}
Shims provides mockable wrappers around system and runtime functions
type VirtualMachine ¶
type VirtualMachine interface {
Virt
}
VirtualMachine defines methods for VirtualMachine operations
type YAMLEncoder ¶
YAMLEncoder is an interface for encoding YAML data.