virt

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func NewBaseVirt(injector di.Injector) *BaseVirt

NewBaseVirt creates a new BaseVirt instance

func (*BaseVirt) Initialize

func (v *BaseVirt) Initialize() error

Initialize is a method that initializes the virt environment

type ColimaVirt

type ColimaVirt struct {
	BaseVirt
}

ColimaVirt implements the VirtInterface and VMInterface for Colima

func NewColimaVirt

func NewColimaVirt(injector di.Injector) *ColimaVirt

NewColimaVirt creates a new instance of ColimaVirt using a DI injector

func (*ColimaVirt) Down

func (v *ColimaVirt) Down() error

Down stops and deletes the Colima VM

func (*ColimaVirt) GetVMInfo

func (v *ColimaVirt) GetVMInfo() (VMInfo, error)

GetVMInfo returns the information about the Colima VM

func (*ColimaVirt) PrintInfo

func (v *ColimaVirt) PrintInfo() error

PrintInfo prints the information about the Colima VM

func (*ColimaVirt) Up

func (v *ColimaVirt) Up() error

Up starts the Colima VM

func (*ColimaVirt) WriteConfig

func (v *ColimaVirt) WriteConfig() error

WriteConfig writes the Colima configuration file

type ContainerInfo

type ContainerInfo struct {
	Name    string
	Address string
	Labels  map[string]string
}

type ContainerRuntime

type ContainerRuntime interface {
	Virt
	GetContainerInfo(name ...string) ([]ContainerInfo, error)
}

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(injector di.Injector) *DockerVirt

NewDockerVirt creates a new instance of DockerVirt using a DI injector

func (*DockerVirt) Down

func (v *DockerVirt) Down() error

Down stops the Docker container

func (*DockerVirt) GetContainerInfo

func (v *DockerVirt) GetContainerInfo(name ...string) ([]ContainerInfo, error)

GetContainerInfo returns a list of information about the Docker containers, including their labels

func (*DockerVirt) Initialize

func (v *DockerVirt) Initialize() error

Initialize resolves the dependencies for DockerVirt

func (*DockerVirt) PrintInfo

func (v *DockerVirt) PrintInfo() error

PrintInfo prints the container information

func (*DockerVirt) Up

func (v *DockerVirt) Up() error

Up starts docker compose

func (*DockerVirt) WriteConfig

func (v *DockerVirt) WriteConfig() error

WriteConfig writes the Docker configuration file

type MockVirt

type MockVirt struct {
	InitializeFunc       func() error
	UpFunc               func(verbose ...bool) error
	DownFunc             func() error
	PrintInfoFunc        func() error
	WriteConfigFunc      func() error
	GetVMInfoFunc        func() (VMInfo, error)
	GetContainerInfoFunc func(name ...string) ([]ContainerInfo, error)
}

MockVirt is a struct that simulates a virt environment for testing purposes.

func NewMockVirt

func NewMockVirt() *MockVirt

NewMockVirt creates a new instance of MockVirt.

func (*MockVirt) Down

func (m *MockVirt) Down() error

Down stops the mock virt. If a custom DownFunc is provided, it will use that function instead.

func (*MockVirt) GetContainerInfo

func (m *MockVirt) GetContainerInfo(name ...string) ([]ContainerInfo, error)

GetContainerInfo retrieves information about the mock containers. If a custom GetContainerInfoFunc is provided, it will use that function instead.

func (*MockVirt) GetVMInfo

func (m *MockVirt) GetVMInfo() (VMInfo, error)

GetVMInfo retrieves information about the mock VM. If a custom GetVMInfoFunc is provided, it will use that function instead.

func (*MockVirt) Initialize

func (m *MockVirt) Initialize() error

Initialize initializes the mock virt. If a custom InitializeFunc is provided, it will use that function instead.

func (*MockVirt) PrintInfo

func (m *MockVirt) PrintInfo() error

PrintInfo prints information about the mock virt. If a custom PrintInfoFunc is provided, it will use that function instead.

func (*MockVirt) Up

func (m *MockVirt) Up() error

Up starts the mock virt. If a custom UpFunc is provided, it will use that function instead.

func (*MockVirt) WriteConfig

func (m *MockVirt) WriteConfig() error

WriteConfig writes the configuration of the mock virt. If a custom WriteConfigFunc is provided, it will use that function instead.

type VMInfo

type VMInfo struct {
	Address string
	Arch    string
	CPUs    int
	Disk    int
	Memory  int
	Name    string
}

VMInfo is a struct that holds the information about the VM

type Virt

type Virt interface {
	Initialize() error
	Up() error
	Down() error
	PrintInfo() error
	WriteConfig() error
}

Virt defines methods for the virt operations

type VirtualMachine

type VirtualMachine interface {
	Virt
	GetVMInfo() (VMInfo, error)
}

VirtualMachine defines methods for VirtualMachine operations

type YAMLEncoder

type YAMLEncoder interface {
	Encode(v interface{}) error
	Close() error
}

YAMLEncoder is an interface for encoding YAML data.

Jump to

Keyboard shortcuts

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