Documentation ¶
Index ¶
- func ExecProgram(report *Report, stdin []byte, command string, arguments ...string) (output []byte, err error)
- func ExecProgramOrMock(report *Report, stdin []byte, command string, arguments ...string) (output []byte, err error)
- func GetCurrentDistribution() map[string]bool
- func ReportUnsupportedDistribution(isDist map[string]bool)
- func Version() string
- func VersionString() string
- type Report
- func (r *Report) AddError(text string, args ...interface{})
- func (r *Report) AddLine(key, value string)
- func (r *Report) AddLog(text string)
- func (r *Report) AddWarning(text string, args ...interface{})
- func (r *Report) Print()
- func (r *Report) PrintUnlessEmpty()
- func (r *Report) ReplaceLine(index uint, key, value string)
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 ¶
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
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 ¶
AddError adds an error message to the given Report. If args... are given, fmt.Sprintf() is applied.
func (*Report) AddLog ¶ added in v0.9.0
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 ¶
AddWarning adds a warning message to the given Report. If args... are given, fmt.Sprintf() is applied.
func (*Report) PrintUnlessEmpty ¶
func (r *Report) PrintUnlessEmpty()
PrintUnlessEmpty prints the full report on stdout if it has any warnings or errors.
func (*Report) ReplaceLine ¶
ReplaceLine replaces the index-th existing report line with a new one.