unit

package
v0.0.0-...-ac74c47 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ServiceSuffix is the suffix for service files. This includes the dot.
	ServiceSuffix = ".service"
)

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.

Types

type File

type File struct {
	Contents map[string]map[string][]string
	Options  []*unit.UnitOption
}

A File represents a systemd configuration which encodes information about any of the unit types that fleet supports (as defined in SupportedUnitTypes()).

func NewFile

func NewFile(raw string) (*File, error)

NewFile returns a new unit file parsed from raw.

func (*File) Delete

func (u *File) Delete(section, name string) *File

Delete deletes name in the named section and returns a new File.

func (*File) Description

func (u *File) 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 (*File) Insert

func (u *File) Insert(section, name string, value ...string) *File

Insert adds name=value to section and returns a newly parsed pointer to File.

func (*File) Overwrite

func (u *File) Overwrite(section, name string, value ...string) *File

Overwrite overwrites name=value in the section and returns a new File.

func (*File) String

func (u *File) String() string

type Manager

type Manager interface {
	// this is an interface mostly for testing.
	Disable(name string) error
	Load(name string, u File) error
	Mask(name string) error
	Properties(name string) (map[string]interface{}, error)
	Property(name, property string) string
	Reload() error
	ServiceProperty(name, property string) string
	State(name string) (*State, error)
	States(prefix string) (map[string]*State, error)
	TriggerStart(name string) error
	TriggerStop(name string) error
	Unit(name string) string
	Units() ([]string, error)
	Unload(name string) error
}

Manager owns the management of systemd units.

func NewManager

func NewManager(uDir string) (Manager, error)

NewManager returns an initialized dBus unit manager.

func NewMockManager

func NewMockManager() (Manager, error)

type State

type State struct {
	dbus.UnitStatus
	UnitData string // the unit file as written to disk
}

State encodes the current state of a unit loaded into a systemk agent

Jump to

Keyboard shortcuts

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