shared

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2015 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecProgram

func ExecProgram(report *Report, stdin []byte, command string, arguments ...string) (output []byte, err error)

ExecProgram is a wrapper around exec.Command that reports any stderr output of the child process to the given Report automatically.

func ExecProgramOrMock

func ExecProgramOrMock(report *Report, stdin []byte, command string, arguments ...string) (output []byte, err error)

ExecProgramOrMock works like ExecProgram, but when the environment variable HOLO_MOCK=1 is set, it will only print the command name and return success and empty stdout without executing the command.

func GetCurrentDistribution

func GetCurrentDistribution() map[string]bool

GetCurrentDistribution returns a set of distribution IDs, drawing on the ID= and ID_LIKE= fields of os-release(5).

func ReportUnsupportedDistribution added in v0.8.0

func ReportUnsupportedDistribution(isDist map[string]bool)

ReportUnsupportedDistribution prints the standard warning that the current executable is running on an unsupported distribution.

func Version added in v0.8.0

func Version() string

Version returns the plain version (without release codename).

func VersionString added in v0.8.0

func VersionString() string

VersionString returns a string including the version and the release codename.

Types

type Report

type Report struct {
	Action string
	Target string
	State  string
	// contains filtered or unexported fields
}

Report formats information for an action taken on a single target, including warning and error messages.

func (*Report) AddError

func (r *Report) AddError(text string, args ...interface{})

AddError adds an error message to the given Report. If args... are given, fmt.Sprintf() is applied.

func (*Report) AddLine

func (r *Report) AddLine(key, value string)

AddLine adds an information line to the given Report.

func (*Report) AddLog added in v0.9.0

func (r *Report) AddLog(text string)

AddLog adds log text to the given Report. Log text is unstructured, and is printed as a separate paragraph after everything else.

func (*Report) AddWarning

func (r *Report) AddWarning(text string, args ...interface{})

AddWarning adds a warning message to the given Report. If args... are given, fmt.Sprintf() is applied.

func (*Report) Print

func (r *Report) Print()

Print prints the full report on stdout.

func (*Report) PrintUnlessEmpty

func (r *Report) PrintUnlessEmpty()

PrintUnlessEmpty prints the full report on stdout if it has any warnings or errors.

func (*Report) ReplaceLine

func (r *Report) ReplaceLine(index uint, key, value string)

ReplaceLine replaces the index-th existing report line with a new one.

Jump to

Keyboard shortcuts

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