unit

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2016 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SYSTEMD_LINE_MAX mimics the maximum line length that systemd can use.
	// On typical systemd platforms (i.e. modern Linux), this will most
	// commonly be 2048, so let's use that as a sanity check.
	// Technically, we should probably pull this at runtime:
	//    SYSTEMD_LINE_MAX = int(C.sysconf(C.__SC_LINE_MAX))
	// but this would introduce an (unfortunate) dependency on cgo
	SYSTEMD_LINE_MAX = 2048

	// characters that systemd considers indicate a newline
	SYSTEMD_NEWLINE = "\r\n"
)

Variables

View Source
var (
	ErrLineTooLong = fmt.Errorf("line too long (max %d bytes)", SYSTEMD_LINE_MAX)
)

Functions

func AllMatch

func AllMatch(u1 []*UnitOption, u2 []*UnitOption) bool

func Serialize

func Serialize(opts []*UnitOption) io.Reader

Serialize encodes all of the given UnitOption objects into a unit file. When serialized the options are sorted in their supplied order but grouped by section.

func UnitNameEscape added in v1.2.0

func UnitNameEscape(unescaped string) string

UnitNameEscape escapes a string as `systemd-escape` would

func UnitNamePathEscape added in v1.2.0

func UnitNamePathEscape(unescaped string) string

UnitNamePathEscape escapes a string as `systemd-escape --path` would

func UnitNamePathUnescape added in v1.2.0

func UnitNamePathUnescape(escaped string) string

UnitNamePathUnescape unescapes a string as `systemd-escape --path --unescape` would

func UnitNameUnescape added in v1.2.0

func UnitNameUnescape(escaped string) string

UnitNameUnescape unescapes a string as `systemd-escape --unescape` would

Types

type UnitOption

type UnitOption struct {
	Section string
	Name    string
	Value   string
}

func Deserialize

func Deserialize(f io.Reader) (opts []*UnitOption, err error)

Deserialize parses a systemd unit file into a list of UnitOption objects.

func NewUnitOption added in v1.2.0

func NewUnitOption(section, name, value string) *UnitOption

func (*UnitOption) Match

func (uo *UnitOption) Match(other *UnitOption) bool

func (*UnitOption) String

func (uo *UnitOption) String() string

Jump to

Keyboard shortcuts

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