device

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

nolint: dupl

nolint: dupl

Index

Constants

View Source
const (
	// ProtocolUndefined is not a valid protocol
	ProtocolUndefined = Protocol(0)
	// ProtocolTCP makes the endpoint use TCP
	ProtocolTCP = Protocol(1)
	// ProtocolUDP makes the endpoint use UDP
	ProtocolUDP = Protocol(2)
)
View Source
const (
	BlockType = "unix-block"
)
View Source
const (
	CharType = "unix-char"
)
View Source
const (
	DiskType = "disk"
)
View Source
const (
	NicType = "nic"
)
View Source
const (
	NoneType = "none"
)
View Source
const (
	ProxyType = "proxy"
)

Variables

View Source
var (
	ErrNotSupported = errors.New("not supported")
	ErrNotValid     = errors.New("not valid")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	KeyName string
	Path    string
	Source  string
}

Block device representation https://lxd.readthedocs.io/en/latest/containers/#type-unix-block

func (*Block) FromMap

func (d *Block) FromMap(name string, options map[string]string) error

FromMap loads assigned name (can be empty) and options

func (*Block) ToMap

func (d *Block) ToMap() (string, map[string]string)

ToMap returns assigned name or if unset the type specific unique name and serializes the options into a lxd device map

type Char

type Char struct {
	KeyName string
	Path    string
	Source  string
}

Char device representation https://lxd.readthedocs.io/en/latest/containers/#type-unix-char

func (*Char) FromMap

func (d *Char) FromMap(name string, options map[string]string) error

FromMap loads assigned name (can be empty) and options

func (*Char) ToMap

func (d *Char) ToMap() (string, map[string]string)

ToMap returns assigned name or if unset the type specific unique name and serializes the options into a lxd device map

type Device

type Device interface {
	// ToMap returns assigned name or if unset the type specific unique name and serializes the options into a lxd device map. The key name must be passed through trimKeyName function to guarantee length compatibility.
	ToMap() (name string, options map[string]string)
	// FromMap loads assigned name (can be empty) and options
	FromMap(name string, options map[string]string) error
	// contains filtered or unexported methods
}

Device must support mapping from lxd device map bidirectional

func Detect

func Detect(name string, options map[string]string) (Device, error)

Detects and loads device by type

type Devices

type Devices []Device

Devices allows having a list of devices unique by name

func (*Devices) Upsert

func (d *Devices) Upsert(a Device)

Upsert adds a device or overrides an entry if the key name exists

type Disk

type Disk struct {
	KeyName  string
	Path     string
	Source   string
	Pool     string
	Size     string
	Readonly bool
	Optional bool
}

Disk device representation https://lxd.readthedocs.io/en/latest/containers/#type-disk

func (*Disk) FromMap

func (d *Disk) FromMap(name string, options map[string]string) error

FromMap loads assigned name (can be empty) and options

func (*Disk) ToMap

func (d *Disk) ToMap() (string, map[string]string)

ToMap returns assigned name or if unset the type specific unique name and serializes the options into a lxd device map

type Nic

type Nic struct {
	KeyName     string
	Name        string
	NicType     string
	Parent      string
	IPv4Address string
}

Nic device representation https://lxd.readthedocs.io/en/latest/containers/#type-nic

func (*Nic) FromMap

func (d *Nic) FromMap(name string, options map[string]string) error

FromMap loads assigned name (can be empty) and options

func (*Nic) ToMap

func (d *Nic) ToMap() (string, map[string]string)

ToMap returns assigned name or if unset the type specific unique name and serializes the options into a lxd device map

type None

type None struct {
	KeyName string
}

None device representation https://lxd.readthedocs.io/en/latest/containers/#type-none

func (*None) FromMap

func (d *None) FromMap(name string, options map[string]string) error

FromMap loads assigned name (can be empty) and options

func (*None) ToMap

func (d *None) ToMap() (string, map[string]string)

ToMap returns assigned name or if unset the type specific unique name and serializes the options into a lxd device map

type Protocol

type Protocol int

Protocol defines the type of a proxy endpoint

func (Protocol) String

func (p Protocol) String() string

type Proxy

type Proxy struct {
	KeyName     string
	Listen      *ProxyEndpoint
	Destination *ProxyEndpoint
}

Proxy device representation https://lxd.readthedocs.io/en/latest/containers/#type-proxy

func (*Proxy) FromMap

func (d *Proxy) FromMap(name string, options map[string]string) error

FromMap loads assigned name (can be empty) and options

func (*Proxy) ToMap

func (d *Proxy) ToMap() (string, map[string]string)

ToMap returns assigned name or if unset the type specific unique name and serializes the options into a lxd device map

type ProxyEndpoint

type ProxyEndpoint struct {
	Protocol Protocol
	Address  string
	Port     int
}

ProxyEndpoint defines an enpoint with protocol, address and port

func NewProxyEndpoint

func NewProxyEndpoint(str string) (*ProxyEndpoint, error)

NewProxyEndpoint parses a string of the form protocol:address:port protocol: tcp|udp address: ip or empty port: uiint16 TODO verify and document allowed format values

func (*ProxyEndpoint) String

func (p *ProxyEndpoint) String() string

Jump to

Keyboard shortcuts

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