unit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2016 License: Apache-2.0 Imports: 13 Imported by: 897

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultUnitType added in v0.3.1

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 added in v0.13.0

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

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

func RecognizedUnitType added in v0.3.1

func RecognizedUnitType(name string) bool

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

Types

type FakeUnitManager added in v0.4.0

type FakeUnitManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewFakeUnitManager added in v0.4.0

func NewFakeUnitManager() *FakeUnitManager

func (*FakeUnitManager) GetUnitState added in v0.4.0

func (fum *FakeUnitManager) GetUnitState(name string) (us *UnitState, err error)

func (*FakeUnitManager) GetUnitStates added in v0.6.0

func (fum *FakeUnitManager) GetUnitStates(filter pkg.Set) (map[string]*UnitState, error)

func (*FakeUnitManager) Load added in v0.4.0

func (fum *FakeUnitManager) Load(name string, u UnitFile) error

func (*FakeUnitManager) MarshalJSON added in v0.4.0

func (fum *FakeUnitManager) MarshalJSON() ([]byte, error)

func (*FakeUnitManager) ReloadUnitFiles added in v0.9.2

func (fum *FakeUnitManager) ReloadUnitFiles() error

func (*FakeUnitManager) TriggerStart added in v0.8.2

func (fum *FakeUnitManager) TriggerStart(string) error

func (*FakeUnitManager) TriggerStop added in v0.8.2

func (fum *FakeUnitManager) TriggerStop(string) error

func (*FakeUnitManager) Units added in v0.4.0

func (fum *FakeUnitManager) Units() ([]string, error)

func (*FakeUnitManager) Unload added in v0.4.0

func (fum *FakeUnitManager) Unload(name string) error

type Hash added in v0.3.0

type Hash [sha1.Size]byte

SHA1 sum

func HashFromHexString added in v0.12.0

func HashFromHexString(key string) (Hash, error)

func (*Hash) Empty added in v0.3.0

func (h *Hash) Empty() bool

func (Hash) Short added in v0.4.0

func (h Hash) Short() string

func (Hash) String added in v0.3.0

func (h Hash) String() string

type UnitFile added in v0.7.0

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 added in v0.7.0

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

func NewUnitFromOptions added in v0.7.0

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

func (*UnitFile) Bytes added in v0.7.0

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

func (*UnitFile) Description added in v0.7.0

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 added in v0.7.0

func (u *UnitFile) Hash() Hash

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

func (*UnitFile) String added in v0.7.0

func (u *UnitFile) String() string

func (*UnitFile) ToPB added in v1.0.0

func (unitFile *UnitFile) ToPB() pb.UnitFile

type UnitManager added in v0.4.0

type UnitManager interface {
	Load(string, UnitFile) error
	Unload(string) error
	ReloadUnitFiles() error

	TriggerStart(string) error
	TriggerStop(string) error

	Units() ([]string, error)
	GetUnitStates(pkg.Set) (map[string]*UnitState, error)
	GetUnitState(string) (*UnitState, error)
}

type UnitNameInfo added in v0.5.0

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 added in v0.5.0

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 added in v0.5.0

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 added in v0.11.0

func (nu UnitNameInfo) IsTemplate() bool

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

type UnitState added in v0.3.0

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 added in v0.3.0

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

func (UnitState) ToPB added in v1.0.0

func (s UnitState) ToPB() *pb.UnitState

type UnitStateGenerator added in v0.6.0

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

func NewUnitStateGenerator added in v0.6.0

func NewUnitStateGenerator(mgr UnitManager) *UnitStateGenerator

func (*UnitStateGenerator) Generate added in v0.6.0

func (g *UnitStateGenerator) Generate() (<-chan *UnitStateHeartbeat, error)

Generate returns and fills a channel with *UnitStateHeartbeat objects. Objects will only be returned for units to which this generator is currently subscribed.

func (*UnitStateGenerator) MarshalJSON added in v0.8.1

func (g *UnitStateGenerator) MarshalJSON() ([]byte, error)

func (*UnitStateGenerator) Run added in v0.6.0

func (g *UnitStateGenerator) Run(receiver chan<- *UnitStateHeartbeat, stop <-chan struct{})

Run periodically calls Generate and sends received *UnitStateHeartbeat objects to the provided channel.

func (*UnitStateGenerator) Subscribe added in v0.6.0

func (g *UnitStateGenerator) Subscribe(name string)

Subscribe adds a unit to the internal state filter

func (*UnitStateGenerator) Unsubscribe added in v0.6.0

func (g *UnitStateGenerator) Unsubscribe(name string)

Unsubscribe removes a unit from the internal state filter

type UnitStateHeartbeat added in v0.6.0

type UnitStateHeartbeat struct {
	Name  string
	State *UnitState
}

Jump to

Keyboard shortcuts

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