driver

package
v0.0.0-...-743f219 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExists         = errors.New("Already exists")
	ErrNotExists      = errors.New("Doesn't exist")
	ErrNotImplemented = errors.New("Not implemented by current driver")
)

Functions

func RegisterDriver

func RegisterDriver(name string, d DriverInitialiser)

func RegisterDriverCmds

func RegisterDriverCmds(cmd *cobra.Command) error

func WaitUntil

func WaitUntil(m Machine, timeout time.Duration, target *MachineState,
	failOn *MachineState) error

Types

type AttachOptions

type AttachOptions struct{}

type Driver

type Driver interface {
	// Setup the driver using config map
	SetupDriver(conf map[string]interface{}) (err error)

	// Get a Machine instance within a specified namespace
	Machine(name, namespace string) (Machine, error)
	// Get a list of all machines within a specified namespace,
	// or all machines if all is true.
	// If all is true, the namespace parameter will be ignored
	ListMachines(namespace string, all bool) ([]MachineInfo, error)

	// Get a Network instance within a specified namespace
	Network(name, namespace string) (Network, error)
	// Get a list of all networks within a specified namespace,
	// or all networks if all is true.
	// If all is true, the namespace parameter will be ignored
	ListNetworks(namespace string, all bool) (networks []NetInfo, err error)

	// Return a list of all namespaces
	ListAllNamespaces() ([]string, error)
	// Return a Cobra CLI command which can be added to an existing CLI
	// as a subcommand
	GetCLICommand() (command *cobra.Command, err error)
}

func GetDriver

func GetDriver(name string, conf map[string]interface{}) (d Driver,
	err error)

type DriverInitialiser

type DriverInitialiser func() Driver

type ExecOptions

type ExecOptions struct {
	User    string
	Detach  bool
	Workdir string
}

type LogOptions

type LogOptions struct {
	Follow bool
	Tail   int
}

type Machine

type Machine interface {
	Name() string
	Id() string
	Exists() (bool, error)
	Running() bool
	Info() (MachineInfo, error)
	State() (MachineState, error)
	Networks() ([]Network, error)
	Start(*MachineConfig) error
	Stop(force bool) error
	Remove() error
	Attach(opts *AttachOptions) error
	Exec(command string,
		opts *ExecOptions) error
	Shell(opts *ShellOptions) error
	Logs(opts *LogOptions) error
	WaitUntil(timeout time.Duration, target, failOn *MachineState) error
}

type MachineConfig

type MachineConfig struct {
	Image        string                 `default:"" mapstructure:"image,omitempty"`
	HostHome     bool                   `default:"false" mapstructure:"hosthome,omitempty"`
	Hostlab      bool                   `default:"" mapstructure:"hostlab,omitempty" validate:"dir"`
	Networks     []string               `default:"[]" mapstructure:"networks,omitempty"`
	Volumes      []spec.Mount           `default:"[]" mapstructure:"volumes,omitempty"`
	Ports        []ocicni.PortMapping   `default:"[]" mapstructure:"ports"`
	Dependencies []string               `default:"[]" mapstructure:"depends_on,omitempty"`
	DriverExtra  map[string]interface{} `default:"{}" mapstructure:"driver,omitempty"`
	Lab          string                 `default:"" mapstructure:"-"`
}

type MachineInfo

type MachineInfo struct {
	Name      string               `json:"name"`
	Namespace string               `json:"namespace"`
	Lab       string               `json:"lab,omitempty"`
	Image     string               `json:"image"`
	Pid       int                  `json:"pid,omitempty"`
	State     string               `json:"state"`
	Status    string               `json:"status,omitempty"`
	Running   bool                 `json:"running"`
	StartedAt time.Time            `json:"started_at,omitempty"`
	CreatedAt time.Time            `json:"created_at,omitempty"`
	Mounts    []string             `json:"mounts"`
	Networks  []string             `json:"networks"`
	Ports     []ocicni.PortMapping `json:"ports"`
	Uptime    string               `json:"uptime,omitempty"`
	ExitCode  int32                `json:"exit_code,omitempty"`
	ExitedAt  int64                `json:"exited_at,omitempty"`
}

Information about a machine available from the driver

type MachineState

type MachineState struct {
	Exists   bool
	State    *string
	Running  *bool
	ExitCode *int32
}

func BootedState

func BootedState() *MachineState

func BootingState

func BootingState() *MachineState

func ExitedState

func ExitedState() *MachineState

type NetConfig

type NetConfig struct {
	External bool   `default:"false" mapstructure:"external,omitempty"`
	Gateway  string `default:"" mapstructure:"gateway,omitempty"`
	IpRange  string `default:"" mapstructure:"iprange,omitempty"`
	Subnet   string `default:"" mapstructure:"subnet,omitempty"`
	IPv6     string `default:"" mapstructure:"ipv6,omitempty"`
}

type NetInfo

type NetInfo struct {
	Name      string
	Namespace string
	External  bool
	Gateway   string
	IpRange   string
	Subnet    string
	IPv6      string
}

Information about a network available from the driver

type Network

type Network interface {
	Name() string
	Id() string
	Create(opts *NetConfig) error
	Start() error
	Stop() error
	Remove() error
	Exists() (bool, error)
	Running() (bool, error)
	Info() (NetInfo, error)
}

type ShellOptions

type ShellOptions struct {
	User    string
	Workdir string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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