Documentation ¶
Overview ¶
Package exec contains an interface for executing commands, along with helpers TODO(bentheelder): add standardized timeout functionality & a default timeout so that commands cannot hang indefinitely (!)
Index ¶
- Variables
- func CombinedOutputLines(cmd Cmd) (lines []string, err error)
- func RunLoggingOutputOnFail(cmd Cmd) error
- func RunWithStdinWriter(cmd Cmd, writerFunc func(io.Writer) error) error
- func RunWithStdoutReader(cmd Cmd, readerFunc func(io.Reader) error) error
- type Cmd
- type Cmder
- type LocalCmd
- type LocalCmder
Constants ¶
This section is empty.
Variables ¶
var DefaultCmder = &LocalCmder{}
DefaultCmder is a LocalCmder instance used for convienience, packages originally using os/exec.Command can instead use pkg/kind/exec.Command which forwards to this instance TODO(bentheelder): swap this for testing TODO(bentheelder): consider not using a global for this :^)
Functions ¶
func CombinedOutputLines ¶
CombinedOutputLines is like os/exec's cmd.CombinedOutput(), but over our Cmd interface, and instead of returning the byte buffer of stderr + stdout, it scans these for lines and returns a slice of output lines
func RunLoggingOutputOnFail ¶
RunLoggingOutputOnFail runs the cmd, logging error output if Run returns an error
func RunWithStdinWriter ¶ added in v0.5.0
RunWithStdinWriter runs cmd with writerFunc piped to stdin
Types ¶
type Cmd ¶
type Cmd interface { Run() error // Each entry should be of the form "key=value" SetEnv(...string) Cmd SetStdin(io.Reader) Cmd SetStdout(io.Writer) Cmd SetStderr(io.Writer) Cmd }
Cmd abstracts over running a command somewhere, this is useful for testing
func InheritOutput ¶
InheritOutput sets cmd's output to write to the current process's stdout and stderr