host

package
v16.6.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2020 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package host provides facilities for interfacing with the host operating system, logging activities performed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CombinedOutput

func CombinedOutput(name string, arg ...string) (combinedOutput string, err error)

CombinedOutput is equivalent to exec.Command(name, arg...).CombinedOutput() but with logging.

func ImmediateReboot

func ImmediateReboot()

func ImmediateShutdown

func ImmediateShutdown(cause string)

func Run

func Run(name string, arg ...string) (err error)

Run is equivalent to exec.Command(name, arg...).Run() but with logging.

func RunBatch

func RunBatch(allowFail bool, commands ...[]string) (err error)

RunBatch calls Run for each command in commands, in sequence. If allowFail is false it will return if an error is returned from Run. All errors are logged regardless of allowFail. The returned error is the result of the last Run call.

func RunCommand

func RunCommand(cmd *exec.Cmd) (combinedOutput string, err error)

RunCommand logs cmd.Args, calls cmd.CombinedOutput(), and if an error occurs, logs the command output. It does not log the error, it is expected that the caller takes care of logging error, if required. The caller is not expected to log the command output in the case of failure, since this function has already done that. The combined output is cast to a string and returned together with the error.

func RunIgnoreError

func RunIgnoreError(errString string, command string, args ...string) (found bool, err error)

RunIgnoreError calls CombinedOutput(comand, args...). If errString is found in the command output, found is true and err is nil. Otherwise found is false, and err is the error returned from CombinedOutput (possibly nil).

Types

This section is empty.

Jump to

Keyboard shortcuts

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