unit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2014 License: Apache-2.0 Imports: 6 Imported by: 0

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 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) Load added in v0.4.0

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

func (*FakeUnitManager) MarshalJSON added in v0.4.0

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

func (*FakeUnitManager) Start added in v0.4.0

func (fum *FakeUnitManager) Start(string)

func (*FakeUnitManager) Stop added in v0.4.0

func (fum *FakeUnitManager) Stop(string)

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)

type Hash added in v0.3.0

type Hash [sha1.Size]byte

SHA1 sum

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

type InstanceUnit struct {
	FullName string // Original name of the template unit (e.g. foo@bar.service)
	Template string // Name of the canonical template unit (e.g. foo@.service)
	Prefix   string // Prefix of the template unit (e.g. foo)
	Instance string // Instance name (e.g. bar)
}

InstanceUnit represents a Unit that has been instantiated from a template unit

func UnitNameToInstance added in v0.4.0

func UnitNameToInstance(name string) *InstanceUnit

UnitNameToInstance determines whether the given unit name appears to be an instance of a template unit. If so, it returns a non-nil *InstanceUnit; otherwise, nil.

type Unit added in v0.3.0

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

	// Raw represents the entire contents of the unit file.
	Raw string
}

A Unit represents a systemd configuration which encodes information about any of the unit types that fleet supports (as defined in SupportedUnitTypes()). Units are linked to Jobs by the Hash of their contents. Similar to systemd, a Unit 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 job that references this Unit.

func NewUnit added in v0.3.0

func NewUnit(raw string) *Unit

func NewUnitFromLegacyContents added in v0.3.0

func NewUnitFromLegacyContents(contents map[string]map[string]string) *Unit

NewUnitFromLegacyContents creates a Unit object from an obsolete unit file datastructure. This should only be used to remain backwards-compatible where necessary.

func (*Unit) Description added in v0.3.0

func (u *Unit) 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 (*Unit) Hash added in v0.3.0

func (u *Unit) Hash() Hash

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

func (*Unit) String added in v0.3.0

func (u *Unit) String() string

type UnitManager added in v0.4.0

type UnitManager interface {
	Load(string, Unit) error
	Unload(string)

	Start(string)
	Stop(string)

	Units() ([]string, error)
	GetUnitState(string) (*UnitState, error)

	MarshalJSON() ([]byte, error)
}

type UnitState added in v0.3.0

type UnitState struct {
	LoadState    string                `json:"loadState"`
	ActiveState  string                `json:"activeState"`
	SubState     string                `json:"subState"`
	MachineState *machine.MachineState `json:"machineState"`
}

UnitState encodes the current state of a unit loaded into systemd

func NewUnitState added in v0.3.0

func NewUnitState(loadState, activeState, subState string, ms *machine.MachineState) *UnitState

Jump to

Keyboard shortcuts

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