parser

package
v5.0.0-rc7 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const WhitespaceSeparators = " \t\n\r"

Variables

This section is empty.

Functions

This section is empty.

Types

type SplitFlags

type SplitFlags = uint64
const (
	SplitRelax                  SplitFlags = 1 << iota // Allow unbalanced quote and eat up trailing backslash.
	SplitCUnescape                                     // Unescape known escape sequences.
	SplitUnescapeRelax                                 // Allow and keep unknown escape sequences, allow and keep trailing backslash.
	SplitUnescapeSeparators                            // Unescape separators (those specified, or whitespace by default).
	SplitKeepQuote                                     // Ignore separators in quoting with "" and ”.
	SplitUnquote                                       // Ignore separators in quoting with "" and ”, and remove the quotes.
	SplitDontCoalesceSeparators                        // Don't treat multiple adjacent separators as one
	SplitRetainEscape                                  // Treat escape character '\' as any other character without special meaning
	SplitRetainSeparators                              // Do not advance the original string pointer past the separator(s) */
)

type UnitFile

type UnitFile struct {
	Filename string
	Path     string
	// contains filtered or unexported fields
}

func NewUnitFile

func NewUnitFile() *UnitFile

Create an empty unit file, with no filename or path

func ParseUnitFile

func ParseUnitFile(pathName string) (*UnitFile, error)

Load a unit file from disk, remembering the path and filename

func (*UnitFile) Add

func (f *UnitFile) Add(groupName string, key string, value string)

func (*UnitFile) AddCmdline

func (f *UnitFile) AddCmdline(groupName string, key string, args []string)

func (*UnitFile) AddComment

func (f *UnitFile) AddComment(groupName string, comments ...string)

Empty group name == first group

func (*UnitFile) Dup

func (f *UnitFile) Dup() *UnitFile

Create a copy of the unit file, copies filename but not path

func (*UnitFile) GetTemplateParts

func (f *UnitFile) GetTemplateParts() (string, string)

func (*UnitFile) HasGroup

func (f *UnitFile) HasGroup(groupName string) bool

func (*UnitFile) HasKey

func (f *UnitFile) HasKey(groupName string, key string) bool

func (*UnitFile) ListGroups

func (f *UnitFile) ListGroups() []string

func (*UnitFile) ListKeys

func (f *UnitFile) ListKeys(groupName string) []string

func (*UnitFile) Lookup

func (f *UnitFile) Lookup(groupName string, key string) (string, bool)

Look up the last instance of the named key in the group (if any) The result have no trailing whitespace and line continuations are applied

func (*UnitFile) LookupAll

func (f *UnitFile) LookupAll(groupName string, key string) []string

Look up every instance of the named key in the group The result can have trailing whitespace, but line continuations are applied

func (*UnitFile) LookupAllArgs

func (f *UnitFile) LookupAllArgs(groupName string, key string) []string

Look up every instance of the named key in the group, and for each, split space separated words (including handling quoted words) and combine them all into one array of words. The split code is exec-like, and both unquotes and applied c-style c escapes.

func (*UnitFile) LookupAllKeyVal

func (f *UnitFile) LookupAllKeyVal(groupName string, key string) map[string]string

Look up 'Environment' style key-value keys

func (*UnitFile) LookupAllRaw

func (f *UnitFile) LookupAllRaw(groupName string, key string) []string

Look up every instance of the named key in the group The result can have trailing whitespace, and Raw means it can contain line continuations (\ at end of line)

func (*UnitFile) LookupAllStrv

func (f *UnitFile) LookupAllStrv(groupName string, key string) []string

Look up every instance of the named key in the group, and for each, split space separated words (including handling quoted words) and combine them all into one array of words. The split code is compatible with the systemd config_parse_strv(). This is typically used by systemd keys like "RequiredBy" and "Aliases".

func (*UnitFile) LookupBoolean

func (f *UnitFile) LookupBoolean(groupName string, key string) (bool, bool)

Lookup the last instance of a key and convert the value to a bool

func (*UnitFile) LookupBooleanWithDefault

func (f *UnitFile) LookupBooleanWithDefault(groupName string, key string, defaultValue bool) bool

Lookup the last instance of a key and convert the value to a bool

func (*UnitFile) LookupGID

func (f *UnitFile) LookupGID(groupName string, key string, defaultValue uint32) (uint32, error)

Lookup the last instance of a key and convert a uid or a group name to an uint32 gid

func (*UnitFile) LookupInt

func (f *UnitFile) LookupInt(groupName string, key string, defaultValue int64) int64

Lookup the last instance of a key and convert the value to an int64

func (*UnitFile) LookupLast

func (f *UnitFile) LookupLast(groupName string, key string) (string, bool)

Look up the last instance of the named key in the group (if any) The result can have trailing whitespace, but line continuations are applied

func (*UnitFile) LookupLastArgs

func (f *UnitFile) LookupLastArgs(groupName string, key string) ([]string, bool)

Look up last instance of the named key in the group, and split space separated words (including handling quoted words) into one array of words. The split code is exec-like, and both unquotes and applied c-style c escapes. This is typically used for keys like ExecStart

func (*UnitFile) LookupLastRaw

func (f *UnitFile) LookupLastRaw(groupName string, key string) (string, bool)

Look up the last instance of the named key in the group (if any) The result can have trailing whitespace, and Raw means it can contain line continuations (\ at end of line)

func (*UnitFile) LookupUID

func (f *UnitFile) LookupUID(groupName string, key string, defaultValue uint32) (uint32, error)

Lookup the last instance of a key and convert a uid or a user name to an uint32 uid

func (*UnitFile) LookupUint32

func (f *UnitFile) LookupUint32(groupName string, key string, defaultValue uint32) uint32

Lookup the last instance of a key and convert the value to an uint32

func (*UnitFile) Merge

func (f *UnitFile) Merge(source *UnitFile)

func (*UnitFile) Parse

func (f *UnitFile) Parse(data string) error

Parse an already loaded unit file (in the form of a string)

func (*UnitFile) PrependComment

func (f *UnitFile) PrependComment(groupName string, comments ...string)

func (*UnitFile) RemoveGroup

func (f *UnitFile) RemoveGroup(groupName string)

func (*UnitFile) RenameGroup

func (f *UnitFile) RenameGroup(groupName string, newName string)

func (*UnitFile) Set

func (f *UnitFile) Set(groupName string, key string, value string)

func (*UnitFile) Setv

func (f *UnitFile) Setv(groupName string, keyvals ...string)

func (*UnitFile) ToString

func (f *UnitFile) ToString() (string, error)

Convert a UnitFile back to data, as a string

func (*UnitFile) Unset

func (f *UnitFile) Unset(groupName string, key string)

func (*UnitFile) Write

func (f *UnitFile) Write(w io.Writer) error

Convert a UnitFile back to data, writing to the io.Writer w

type UnitFileParser

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

Jump to

Keyboard shortcuts

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