Documentation ¶
Index ¶
- func DefaultUnitType(name string) string
- func RecognizedUnitType(name string) bool
- type FakeUnitManager
- func (fum *FakeUnitManager) GetUnitState(name string) (us *UnitState, err error)
- func (fum *FakeUnitManager) GetUnitStates(filter pkg.Set) (map[string]*UnitState, error)
- func (fum *FakeUnitManager) Load(name string, u UnitFile) error
- func (fum *FakeUnitManager) MarshalJSON() ([]byte, error)
- func (fum *FakeUnitManager) TriggerStart(string)
- func (fum *FakeUnitManager) TriggerStop(string)
- func (fum *FakeUnitManager) Units() ([]string, error)
- func (fum *FakeUnitManager) Unload(name string)
- type Hash
- type UnitFile
- type UnitManager
- type UnitNameInfo
- type UnitState
- type UnitStateGenerator
- func (g *UnitStateGenerator) Generate() (<-chan *UnitStateHeartbeat, error)
- func (g *UnitStateGenerator) MarshalJSON() ([]byte, error)
- func (g *UnitStateGenerator) Run(receiver chan<- *UnitStateHeartbeat, stop chan bool)
- func (g *UnitStateGenerator) Subscribe(name string)
- func (g *UnitStateGenerator) Unsubscribe(name string)
- type UnitStateHeartbeat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultUnitType ¶
DefaultUnitType appends the default unit type to a given unit name, ignoring any file extensions that already exist.
func RecognizedUnitType ¶
RecognizedUnitType determines whether or not the given unit name represents a recognized unit type.
Types ¶
type FakeUnitManager ¶
func NewFakeUnitManager ¶
func NewFakeUnitManager() *FakeUnitManager
func (*FakeUnitManager) GetUnitState ¶
func (fum *FakeUnitManager) GetUnitState(name string) (us *UnitState, err error)
func (*FakeUnitManager) GetUnitStates ¶
func (*FakeUnitManager) MarshalJSON ¶
func (fum *FakeUnitManager) MarshalJSON() ([]byte, error)
func (*FakeUnitManager) TriggerStart ¶
func (fum *FakeUnitManager) TriggerStart(string)
func (*FakeUnitManager) TriggerStop ¶
func (fum *FakeUnitManager) TriggerStop(string)
func (*FakeUnitManager) Units ¶
func (fum *FakeUnitManager) Units() ([]string, error)
func (*FakeUnitManager) Unload ¶
func (fum *FakeUnitManager) Unload(name 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 NewUnitFromOptions ¶
func NewUnitFromOptions(opts []*unit.UnitOption) *UnitFile
func (*UnitFile) Description ¶
Description returns the first Description option found in the [Unit] section. If the option is not defined, an empty string is returned.
type UnitManager ¶
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
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 ¶
type UnitStateGenerator ¶
type UnitStateGenerator struct {
// contains filtered or unexported fields
}
func NewUnitStateGenerator ¶
func NewUnitStateGenerator(mgr UnitManager) *UnitStateGenerator
func (*UnitStateGenerator) Generate ¶
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 ¶
func (g *UnitStateGenerator) MarshalJSON() ([]byte, error)
func (*UnitStateGenerator) Run ¶
func (g *UnitStateGenerator) Run(receiver chan<- *UnitStateHeartbeat, stop chan bool)
Run periodically calls Generate and sends received *UnitStateHeartbeat objects to the provided channel.
func (*UnitStateGenerator) Subscribe ¶
func (g *UnitStateGenerator) Subscribe(name string)
Subscribe adds a unit to the internal state filter
func (*UnitStateGenerator) Unsubscribe ¶
func (g *UnitStateGenerator) Unsubscribe(name string)
Unsubscribe removes a unit from the internal state filter