types

package
v0.0.0-...-97c9703 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDriveSize = "30000" // Mb
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine string
const (
	VBox   Engine = "vbox"
	QEMU   Engine = "qemu"
	Docker Engine = "docker"
)

type Machine

type Machine interface {
	Config() MachineConfig
	Create(ctx context.Context) (context.Context, error)
	Stop() error
	Clean() error
	Screenshot() (string, error)
	CreateDisk(diskname, size string) error
	Command(cmd string) (string, error)
	DetachCD() error
	ReceiveFile(src, dst string) error
	SendFile(src, dst, permissions string) error
}

type MachineConfig

type MachineConfig struct {
	StateDir    string `yaml:"state,omitempty"`
	Image       string `yaml:"image,omitempty"`
	ISO         string `yaml:"iso,omitempty"`
	ISOChecksum string `yaml:"isoChecksum,omitempty"`

	DataSource     string   `yaml:"datasource,omitempty"`
	Drives         []string `yaml:"drives,omitempty"`
	DriveSizes     []string `yaml:"driveSizes,omitempty"`
	AutoDriveSetup bool     `yaml:"auto_drive,omitempty"`
	ID             string   `yaml:"id,omitempty"`
	Memory         string   `yaml:"memory,omitempty"`
	CPU            string   `yaml:"cpu,omitempty"`
	Process        string   `yaml:"bin,omitempty"`
	Args           []string `yaml:"args,omitempty"`
	// only for qemu
	Display string `yaml:"display,omitempty"`

	CPUType string `yaml:"cpu,omitempty"`

	// Network configuration
	DisableDefaultNetworking bool `yaml:"disable_default_networking,omitempty"`

	SSH    *SSH   `yaml:"ssh,omitempty"`
	Engine Engine `yaml:"engine,omitempty"`
	Arch   string `yaml:"arch,omitempty"`

	OnFailure func(*process.Process)
}

func DefaultMachineConfig

func DefaultMachineConfig() *MachineConfig

func (*MachineConfig) Apply

func (m *MachineConfig) Apply(opts ...MachineOption) error

type MachineOption

type MachineOption func(*MachineConfig) error
var DisableAutoDriveSetup MachineOption = func(mc *MachineConfig) error {
	mc.AutoDriveSetup = false
	return nil
}

DisableAutoDriveSetup disables automatic disk setup.

var DisableDefaultNetworking MachineOption = func(mc *MachineConfig) error {
	mc.DisableDefaultNetworking = true
	return nil
}

DisableDefaultNetworking disables the default -nic networking setup. This allows for custom network configuration without conflicts.

var EnableAutoDriveSetup MachineOption = func(mc *MachineConfig) error {
	mc.AutoDriveSetup = true
	return nil
}

EnableAutoDriveSetup automatically setup a VM disk if nothing is specified.

var EnableDefaultNetworking MachineOption = func(mc *MachineConfig) error {
	mc.DisableDefaultNetworking = false
	return nil
}

EnableDefaultNetworking enables the default -nic networking setup (default behavior).

var QEMUEngine MachineOption = func(mc *MachineConfig) error {
	mc.Engine = QEMU
	return nil
}

QEMUEngine sets the machine engine to QEMU.

var VBoxEngine MachineOption = func(mc *MachineConfig) error {
	mc.Engine = VBox
	return nil
}

VBoxEngine sets the machine engine to VBox.

func FromFile

func FromFile(path string) MachineOption

func OnFailure

func OnFailure(f func(*process.Process)) MachineOption

func WithArch

func WithArch(arch string) MachineOption

func WithCPU

func WithCPU(cpu string) MachineOption

func WithCPUType

func WithCPUType(cpu string) MachineOption

func WithDataSource

func WithDataSource(ds string) MachineOption

func WithDisplay

func WithDisplay(display string) MachineOption

func WithDrive

func WithDrive(drive string) MachineOption

func WithDriveSize

func WithDriveSize(drivesize string) MachineOption

func WithID

func WithID(id string) MachineOption

func WithISO

func WithISO(iso string) MachineOption

func WithISOChecksum

func WithISOChecksum(iso string) MachineOption

func WithImage

func WithImage(img string) MachineOption

func WithMemory

func WithMemory(mem string) MachineOption

func WithProcessName

func WithProcessName(proc string) MachineOption

func WithSSHPass

func WithSSHPass(sshpass string) MachineOption

func WithSSHPort

func WithSSHPort(sshport string) MachineOption

func WithSSHUser

func WithSSHUser(sshuser string) MachineOption

func WithStateDir

func WithStateDir(dir string) MachineOption

type SSH

type SSH struct {
	User string `yaml:"user,omitempty"`
	Port string `yaml:"port,omitempty"`
	Pass string `yaml:"pass,omitempty"`
}

Jump to

Keyboard shortcuts

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