engine

package
v0.0.0-...-8776f88 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImageNotFound                = errors.New("engine: image not found")
	ErrInvalidChecksum              = errors.New("engine: invalid checksum")
	ErrInvalidSSHPort               = errors.New("engine: invalid ssh port")
	ErrUnsupportedArchitecture      = errors.New("engine: unsupported architecture")
	ErrVirtualMachineAlreadyExist   = errors.New("engine: virtual machine already exist")
	ErrVirtualMachineAlreadyRunning = errors.New("engine: virtual machine is already running")
	ErrVirtualMachineNotRunning     = errors.New("engine: virtual machine is not running")
)

Functions

This section is empty.

Types

type CreateVirtualMachineOptions

type CreateVirtualMachineOptions struct {
	CPU          int
	Image        string
	Memory       int
	Name         string
	DiskSize     int
	PortForwards map[string]string
}

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func New

func New(opts *NewOptions) (*Engine, error)

func (*Engine) CreateVirtualMachine

func (e *Engine) CreateVirtualMachine(opts CreateVirtualMachineOptions) (*VirtualMachine, error)

CreateVirtualMachine creates and start a new virtual machine

func (*Engine) FindImage

func (e *Engine) FindImage(name string) *Image

func (*Engine) FindVirtualMachine

func (e *Engine) FindVirtualMachine(name string) *VirtualMachine

FindVirtualMachine returns the virtual machine if exist

func (*Engine) ListImages

func (eng *Engine) ListImages() []*Image

func (*Engine) ListVirtualMachines

func (e *Engine) ListVirtualMachines() []*VirtualMachine

ListVirtualMachines returns a slice of loaded virtual machines

func (*Engine) Printf

func (e *Engine) Printf(format string, a ...interface{}) (n int, err error)

func (*Engine) RandomLocallyAdministeredMacAddress

func (e *Engine) RandomLocallyAdministeredMacAddress() (string, error)

type Image

type Image struct {
	Description string
	Name        string
	Version     string
	Archs       map[string]ImageArch
	// contains filtered or unexported fields
}

func (*Image) Pull

func (i *Image) Pull() error

func (*Image) Pulled

func (i *Image) Pulled() (bool, error)

type ImageArch

type ImageArch struct {
	Checksum string
	URL      string
}

type NewOptions

type NewOptions struct {
	QEMUExecutableName string
	Path               string
	Writer             io.Writer
}

type SSHConnectionDetails

type SSHConnectionDetails struct {
	Host       string
	Port       int
	Username   string
	PrivateKey string
}

type VirtualMachine

type VirtualMachine struct {
	Name   string
	Config VirtualMachineConfig
	// contains filtered or unexported fields
}

func (*VirtualMachine) Exec

func (v *VirtualMachine) Exec(cmd string) error

func (*VirtualMachine) Remove

func (v *VirtualMachine) Remove() error

Remove stops and remove the virtual machine

func (*VirtualMachine) SSHConnectionDetails

func (v *VirtualMachine) SSHConnectionDetails() (*SSHConnectionDetails, error)

func (*VirtualMachine) SSHSessionWithXterm

func (v *VirtualMachine) SSHSessionWithXterm() error

func (*VirtualMachine) Start

func (v *VirtualMachine) Start() error

Start starts the virtual machine

func (*VirtualMachine) Status

func (v *VirtualMachine) Status() (VirtualMachineStatus, error)

Status returns the status of the virtual machine

func (*VirtualMachine) Stop

func (v *VirtualMachine) Stop() error

Stop stops the virtual machine

type VirtualMachineConfig

type VirtualMachineConfig struct {
	CPU          int
	Memory       int
	DiskSize     int
	Image        string
	SSHUser      string
	MacAddress   string
	PortForwards map[string]string
}

type VirtualMachineStatus

type VirtualMachineStatus string
const (
	VirtualMachineStatusStopped VirtualMachineStatus = "stopped"
	VirtualMachineStatusRunning VirtualMachineStatus = "running"
	VirtualMachineStatusError   VirtualMachineStatus = "error"
)

Jump to

Keyboard shortcuts

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