unit

package
v0.0.0-...-8f2f122 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultUnitType

func DefaultUnitType(name string) string

DefaultUnitType appends the default unit type to a given unit name, ignoring any file extensions that already exist.

func MatchUnitFiles

func MatchUnitFiles(a *UnitFile, b *UnitFile) bool

MatchUnitFiles compares two unitFiles Returns true if the units match, false otherwise.

func RecognizedUnitType

func RecognizedUnitType(name string) bool

RecognizedUnitType determines whether or not the given unit name represents a recognized unit type.

Types

type Hash

type Hash [sha1.Size]byte

SHA1 sum

func HashFromHexString

func HashFromHexString(key string) (Hash, error)

func (*Hash) Empty

func (h *Hash) Empty() bool

func (Hash) Short

func (h Hash) Short() string

func (Hash) String

func (h Hash) String() string

type UnitFile

type UnitFile struct {
	// Contents represents the parsed unit file.
	// This field must be considered readonly.
	Contents map[string]map[string][]string

	Options []*unit.UnitOption
}

A UnitFile represents a systemd configuration which encodes information about any of the unit types that fleet supports (as defined in SupportedUnitTypes()). UnitFiles are linked to Units by the Hash of their contents. Similar to systemd, a UnitFile configuration has no inherent name, but is rather named through the reference to it; in the case of systemd, the reference is the filename, and in the case of fleet, the reference is the name of the Unit that references this UnitFile.

func NewUnitFile

func NewUnitFile(raw string) (*UnitFile, error)

func NewUnitFromOptions

func NewUnitFromOptions(opts []*unit.UnitOption) *UnitFile

func (*UnitFile) Bytes

func (u *UnitFile) Bytes() []byte

func (*UnitFile) Description

func (u *UnitFile) Description() string

Description returns the first Description option found in the [Unit] section. If the option is not defined, an empty string is returned.

func (*UnitFile) Hash

func (u *UnitFile) Hash() Hash

Hash returns the SHA1 hash of the raw contents of the Unit

func (*UnitFile) String

func (u *UnitFile) String() string

type UnitNameInfo

type UnitNameInfo struct {
	FullName string // Original complete name of the unit (e.g. foo.socket, foo@bar.service)
	Name     string // Name of the unit without suffix (e.g. foo, foo@bar)
	Prefix   string // Prefix of the template unit (e.g. foo)

	// If the unit represents an instance or a template, the following values are set
	Template string // Name of the canonical template unit (e.g. foo@.service)
	Instance string // Instance name (e.g. bar)
}

UnitNameInfo exposes certain interesting items about a Unit based on its name. For example, a unit with the name "foo@.service" constitutes a template unit, and a unit named "foo@1.service" would represent an instance unit of that template.

func NewUnitNameInfo

func NewUnitNameInfo(un string) *UnitNameInfo

NewUnitNameInfo generates a UnitNameInfo from the given name. If the given string is not a correct unit name, nil is returned.

func (UnitNameInfo) IsInstance

func (nu UnitNameInfo) IsInstance() bool

IsInstance returns a boolean indicating whether the UnitNameInfo appears to be an Instance of a Template unit

func (UnitNameInfo) IsTemplate

func (nu UnitNameInfo) IsTemplate() bool

IsTemplate returns a boolean indicating whether the UnitNameInfo appears to be a Template unit

type UnitState

type UnitState struct {
	LoadState   string
	ActiveState string
	SubState    string
	MachineID   string
	UnitHash    string
	UnitName    string
}

UnitState encodes the current state of a unit loaded into a fleet agent

func NewUnitState

func NewUnitState(loadState, activeState, subState, mID string) *UnitState

Jump to

Keyboard shortcuts

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