vcfg

package
v0.0.0-...-79a645e Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BootstrapWaitFile       = "WAIT_FILE"
	BootstrapWaitPort       = "WAIT_PORT"
	BootstrapSleep          = "SLEEP"
	BootstrapFindAndReplace = "FIND_AND_REPLACE"
	BootstrapGetRequest     = "GET"
)

Bootstrap commands

Variables

View Source
var (
	Ext2FS = Filesystem("ext2")
	Ext4FS = Filesystem("ext4")
	XFS    = Filesystem("xfs")
)

Supported filesystem types

View Source
var (
	//RootPrivilege: root privilege level, has full rights to everything and will run as the 'root' suer
	RootPrivilege = Privilege("root")
	//SuperuserPrivilege: sudo user level privileges, and will run as the configured user
	SuperuserPrivilege = Privilege("superuser")
	//SuperuserPrivilege: non-root level privileges, and will run as the configured user
	UserPrivilege = Privilege("user")
)
View Source
var TerminateSignals = map[TerminateSignal]syscall.Signal{
	"SIGINT":  syscall.Signal(0x2),
	"SIGKILL": syscall.Signal(0x9),
	"SIGQUIT": syscall.Signal(0x3),
	"SIGPWR":  syscall.Signal(0x1e),
	"SIGSTOP": syscall.Signal(0x13),
	"SIGTERM": syscall.Signal(0xf),
	"SIGUSR1": syscall.Signal(0xa),
	"SIGUSR2": syscall.Signal(0xc),
}

TerminateSignals : Supported Signals

Functions

func WithDefaults

func WithDefaults(v *VCFG, logger elog.View) error

WithDefaults sets default values for certain fields if they are not set

Types

type Bytes

type Bytes Size

Bytes is a wrapper around Size used to easily parse, marshal, and convert different equivalent representations of size in bytes. Its only real difference compared to Size is in how strings and created and parsed.

const (
	Byte Bytes = 0x1        // a single byte
	KiB  Bytes = 0x400      // a kibibyte (1024 bytes)
	MiB  Bytes = 0x100000   // a mibibyte (1024 kibibytes)
	GiB  Bytes = 0x40000000 // a gibibyte (1024 mibibytes)
)

Common byte constants

func ParseBytes

func ParseBytes(s string) (Bytes, error)

ParseBytes resolves a string into a Bytes object.

func (*Bytes) Align

func (x *Bytes) Align(unit Bytes)

Align increases the number of bytes if necessary to make it aligned to the unit.

func (*Bytes) ApplyDelta

func (x *Bytes) ApplyDelta(delta Bytes)

ApplyDelta adds the delta provided to the Bytes object.

func (Bytes) IsAligned

func (x Bytes) IsAligned(unit Bytes) bool

IsAligned returns true if the number of bytes is an integer multiple of the unit.

func (Bytes) IsDelta

func (x Bytes) IsDelta() bool

IsDelta returns true if the underlying size is a relative value.

func (Bytes) MarshalJSON

func (x Bytes) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Bytes) MarshalText

func (x Bytes) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler. This interface is used by toml processing packages based on github.com/BurntSushi/toml.

func (Bytes) String

func (x Bytes) String() string

String returns a string representation of a Bytes object.

func (Bytes) Units

func (x Bytes) Units(unit Bytes) int

Units returns the number of units the size fills, truncated.

func (*Bytes) UnmarshalJSON

func (x *Bytes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Bytes) UnmarshalText

func (x *Bytes) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler. This interface is used by toml processing packages based on github.com/BurntSushi/toml.

type Command

type Command string

Command ...

type Duration

type Duration time.Duration

Duration specifies the a duration of time.

func DurationFromString

func DurationFromString(s string) (Duration, error)

DurationFromString ..

func (Duration) Duration

func (x Duration) Duration() time.Duration

Duration ..

func (Duration) MarshalJSON

func (x Duration) MarshalJSON() ([]byte, error)

MarshalJSON ..

func (Duration) MarshalText

func (x Duration) MarshalText() (text []byte, err error)

MarshalText ..

func (Duration) String

func (x Duration) String() string

String ..

func (*Duration) UnmarshalJSON

func (x *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Duration) UnmarshalText

func (x *Duration) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Filesystem

type Filesystem string

Filesystem instructs the compiler to use a specific filesystem format

type InodesQuota

type InodesQuota int

InodesQuota specifies the minimum number of inodes that must exist on a compiled file-system.

func (*InodesQuota) TextUnmarshaler

func (x *InodesQuota) TextUnmarshaler(text []byte) error

TextUnmarshaler implements encoding.TextUnmarshaler.

func (*InodesQuota) UnmarshalJSON

func (x *InodesQuota) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Logging

type Logging struct {
	Config []string `toml:"config,omitempty" json:"config,omitempty"`
	Type   string   `toml:"type,omitempty" json:"type,omitempty"`
}

Logging ..

type NFSSettings

type NFSSettings struct {
	MountPoint string `toml:"mount,omitempty" json:"mount"`
	Server     string `toml:"server,omitempty" json:"server"`
	Arguments  string `toml:"options,omitempty" json:"options"`
}

NFSSettings ..

type NetworkInterface

type NetworkInterface struct {
	IP                               string   `toml:"ip,omitempty" json:"ip"`
	Mask                             string   `toml:"mask,omitempty" json:"mask,omitempty"`
	Gateway                          string   `toml:"gateway,omitempty" json:"gateway,omitempty"`
	UDP                              []string `toml:"udp,omitempty" json:"udp,omitempty"`
	TCP                              []string `toml:"tcp,omitempty" json:"tcp,omitempty"`
	HTTP                             []string `toml:"http,omitempty" json:"http,omitempty"`
	HTTPS                            []string `toml:"https,omitempty" json:"https,omitempty"`
	MTU                              uint     `toml:"mtu,omitzero" json:"mtu,omitempty"`
	DisableTCPSegmentationOffloading bool     `toml:"disable-tso,omitempty" json:"disable-tso,omitempty"`
	TCPDUMP                          bool     `toml:"tcpdump,omitempty" json:"tcpdump"`
}

NetworkInterface ..

type PackageInfo

type PackageInfo struct {
	Name        string    `toml:"name,omitempty" json:"name,omitempty"`
	Author      string    `toml:"author,omitempty" json:"author,omitempty"`
	Summary     string    `toml:"summary,omitempty" json:"summary,omitempty"`
	Description string    `toml:"description,omitempty" json:"description,omitempty"`
	URL         URL       `toml:"url,omitempty" json:"url,omitempty"`
	Date        Timestamp `toml:"date,omitempty,omitzero" json:"date,omitempty"`
	Version     string    `toml:"version,omitempty" json:"version,omitempty"`
}

PackageInfo ..

type Privilege

type Privilege string

Privilege: The privilege level that the machine user will bet set with.

Additional information can be found @ https://support.vorteil.io/docs/VCFG-Reference/program/privilege

type Program

type Program struct {
	Binary    string          `toml:"binary,omitempty" json:"binary"`
	Args      string          `toml:"args,omitempty" json:"args"`
	Env       []string        `toml:"env,omitempty" json:"env"`
	Cwd       string          `toml:"cwd,omitempty" json:"cwd"`
	Stdout    string          `toml:"stdout,omitempty" json:"stdout"`
	Stderr    string          `toml:"stderr,omitempty" json:"stderr"`
	Bootstrap []string        `toml:"bootstrap,ommitempty" json:"bootstrap"`
	LogFiles  []string        `toml:"logfiles,omitempty" json:"logfiles"`
	Privilege Privilege       `toml:"privilege,omitempty" json:"privilege"`
	Strace    bool            `toml:"strace,omitempty" json:"strace"`
	Terminate TerminateSignal `toml:"terminate,omitempty" json:"terminate"`
}

Program ..

func (*Program) ProgramArgs

func (p *Program) ProgramArgs() ([]string, error)

type Route

type Route struct {
	Interface   string `toml:"interface,omitempty" json:"interface,omitempty"`
	Destination string `toml:"destination,omitempty" json:"destination,omitempty"`
	Gateway     string `toml:"gateway,omitempty" json:"gateway,omitempty"`
}

Route ..

type Size

type Size int

Size is a wrapper around int used to easily parse, marshal, and convert different equivalent representations of quantities.

const (
	Unit Size = 0x1
	Ki   Size = 0x400
	Mi   Size = 0x100000
	Gi   Size = 0x40000000
)

Unit constants

func ParseSize

func ParseSize(s string) (Size, error)

ParseSize resolves a string into a Size.

func (*Size) Align

func (x *Size) Align(unit Size)

Align increases the size (if necessary) to make it aligned to the unit.

func (*Size) ApplyDelta

func (x *Size) ApplyDelta(delta Size)

ApplyDelta adds the delta provided to the Size object.

func (Size) IsAligned

func (x Size) IsAligned(unit Size) bool

IsAligned returns true if the size is an integer multiple of the unit.

func (Size) IsDelta

func (x Size) IsDelta() bool

IsDelta returns true if the underlying size is a relative value.

func (Size) MarshalJSON

func (x Size) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Size) MarshalText

func (x Size) MarshalText() (text []byte, err error)

MarshalText implements encoding.TextMarshaler.

func (Size) String

func (x Size) String() string

String returns a string representation of a Size object.

func (Size) Units

func (x Size) Units(unit Size) int

Units returns the number of units the size fills, truncated.

func (*Size) UnmarshalJSON

func (x *Size) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Size) UnmarshalText

func (x *Size) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type StdoutMode

type StdoutMode int

StdoutMode ..

const (
	StdoutModeDefault StdoutMode = iota
	StdoutModeStandard
	StdoutModeScreenOnly
	StdoutModeSerialOnly
	StdoutModeDisabled
	StdoutModeUnknown
)

..

func StdoutModeFromString

func StdoutModeFromString(s string) StdoutMode

StdoutModeFromString ..

func (StdoutMode) MarshalJSON

func (x StdoutMode) MarshalJSON() ([]byte, error)

MarshalJSON ..

func (StdoutMode) MarshalText

func (x StdoutMode) MarshalText() (text []byte, err error)

MarshalText ..

func (StdoutMode) String

func (x StdoutMode) String() string

String ..

func (*StdoutMode) UnmarshalJSON

func (x *StdoutMode) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*StdoutMode) UnmarshalText

func (x *StdoutMode) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type SystemSettings

type SystemSettings struct {
	DNS           []string   `toml:"dns,omitempty" json:"dns,omitempty"`
	NTP           []string   `toml:"ntp,omitempty" json:"ntp,omitempty"`
	Hostname      string     `toml:"hostname,omitempty" json:"hostname,omitempty"`
	MaxFDs        uint       `toml:"max-fds,omitzero" json:"max-fds,omitempty"`
	StdoutMode    StdoutMode `toml:"output-mode,omitzero" json:"stdout-mode,omitempty"`
	KernelArgs    string     `toml:"kernel-args,omitempty" json:"kernel-args,omitempty"`
	Filesystem    Filesystem `toml:"filesystem,omitempty" json:"filesystem,omitempty"`
	User          string     `toml:"user,omitempty" json:"user,omitempty"` // Note: should we validate against regex ^[a-z]*$
	TerminateWait uint       `toml:"terminate-wait,omitzero" json:"terminate-wait,omitzero"`
}

SystemSettings ..

type TerminateSignal

type TerminateSignal string

TerminateSignal : The Signal to send to a program on termination

Additional information can be found @ https://support.vorteil.io/docs/VCFG-Reference/program/terminate
const DefaultTerminateSignal TerminateSignal = "SIGTERM"

DefaultTerminateSignal : Default Terminate Signal to be used on programs

func (*TerminateSignal) Signal

func (tSig *TerminateSignal) Signal() (syscall.Signal, error)

Signal : Return syscall Signal

func (*TerminateSignal) Validate

func (tSig *TerminateSignal) Validate() (err error)

Validate : Check if TerminateSignal is a supported signal

type Timestamp

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

Timestamp specifies the a date and time.

func TimestampFromString

func TimestampFromString(s string) (Timestamp, error)

TimestampFromString ..

func TimestampFromTime

func TimestampFromTime(t time.Time) Timestamp

TimestampFromTime ..

func (Timestamp) MarshalJSON

func (x Timestamp) MarshalJSON() ([]byte, error)

MarshalJSON ..

func (Timestamp) MarshalText

func (x Timestamp) MarshalText() (text []byte, err error)

MarshalText ..

func (Timestamp) String

func (x Timestamp) String() string

func (Timestamp) Time

func (x Timestamp) Time() time.Time

Time ..

func (Timestamp) Unix

func (x Timestamp) Unix() int64

Unix ..

func (*Timestamp) UnmarshalJSON

func (x *Timestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Timestamp) UnmarshalText

func (x *Timestamp) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type URL

type URL string

URL is a customized string for validating urls unmarshalled from json or toml.

func URLFromString

func URLFromString(s string) (URL, error)

URLFromString resolves a string into Args.

func (*URL) UnmarshalJSON

func (x *URL) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*URL) UnmarshalText

func (x *URL) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type VCFG

type VCFG struct {
	Programs []Program          `toml:"program,omitempty" json:"program,omitempty"`
	Networks []NetworkInterface `toml:"network,omitempty" json:"network,omitempty"`
	System   SystemSettings     `toml:"system,omitempty" json:"system,omitempty"`
	Info     PackageInfo        `toml:"info,omitempty" json:"info,omitempty"`
	VM       VMSettings         `toml:"vm,omitempty" json:"vm,omitempty"`
	NFS      []NFSSettings      `toml:"nfs,omitempty" json:"nfs,omitempty"`
	Routing  []Route            `toml:"route,omitempty" json:"route,omitempty"`
	Logging  []Logging          `toml:"logging,omitempty" json:"logging,omitempty"`
	Sysctl   map[string]string  `toml:"sysctl,omitempty" json:"sysctl,omitempty"`
	// contains filtered or unexported fields
}

VCFG ..

func Load

func Load(data []byte) (*VCFG, error)

Load ..

func LoadFile

func LoadFile(f vio.File) (*VCFG, error)

LoadFile ..

func Merge

func Merge(a, b *VCFG) (*VCFG, error)

Merge ..

func (*VCFG) File

func (vcfg *VCFG) File() (vio.File, error)

File ..

func (*VCFG) Format

func (vcfg *VCFG) Format(f fmt.State, c rune)

Format ..

func (*VCFG) Load

func (vcfg *VCFG) Load(data []byte) error

Load ..

func (*VCFG) LoadFile

func (vcfg *VCFG) LoadFile(f vio.File) error

LoadFile ..

func (*VCFG) LoadFilepath

func (vcfg *VCFG) LoadFilepath(path string) error

LoadFilepath ..

func (*VCFG) Marshal

func (vcfg *VCFG) Marshal() ([]byte, error)

Marshal ..

func (*VCFG) Merge

func (vcfg *VCFG) Merge(x *VCFG) error

Merge ..

func (*VCFG) ModTime

func (vcfg *VCFG) ModTime() time.Time

ModTime ..

func (*VCFG) SaltedHostname

func (vcfg *VCFG) SaltedHostname() string

type VMSettings

type VMSettings struct {
	CPUs     uint        `toml:"cpus,omitzero" json:"cpus,omitempty"`
	RAM      Bytes       `toml:"ram,omitzero" json:"ram,omitempty"`
	Inodes   InodesQuota `toml:"inodes,omitzero" json:"inodes,omitempty"`
	Kernel   string      `toml:"kernel,omitempty" json:"kernel,omitempty"`
	DiskSize Bytes       `toml:"disk-size,omitzero" json:"disk-size,omitempty"`
}

VMSettings ..

type ZerothArg

type ZerothArg string

A ZerothArg is a customized string with checks for compatibility with image-building logic.

func ZerothArgFromString

func ZerothArgFromString(s string) (ZerothArg, error)

ZerothArgFromString resolves a string into a ZerothArg.

func (*ZerothArg) UnmarshalJSON

func (x *ZerothArg) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*ZerothArg) UnmarshalText

func (x *ZerothArg) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

Jump to

Keyboard shortcuts

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