Documentation
¶
Index ¶
- Variables
- func GetCommandArgsToLog(cmd *exec.Cmd) string
- func Redact(items []string) func(text string) string
- func Run(cmd *exec.Cmd) (string, error)
- func RunCommand(name string, opts CmdOpts, arg ...string) (string, error)
- func RunCommandExt(cmd *exec.Cmd, opts CmdOpts) (string, error)
- func RunWithExecRunOpts(cmd *exec.Cmd, opts ExecRunOpts) (string, error)
- func RunWithRedactor(cmd *exec.Cmd, redactor func(text string) string) (string, error)
- type CmdError
- type CmdOpts
- type ExecRunOpts
- type TimeoutBehavior
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultCmdOpts = CmdOpts{ Timeout: time.Duration(0), FatalTimeout: time.Duration(0), Redactor: Unredacted, TimeoutBehavior: TimeoutBehavior{syscall.SIGKILL, false}, SkipErrorLogging: false, CaptureStderr: false, }
View Source
var (
Unredacted = Redact(nil)
)
Functions ¶
func GetCommandArgsToLog ¶
GetCommandArgsToLog represents the given command in a way that we can copy-and-paste into a terminal
func RunCommand ¶ added in v3.1.0
func RunCommandExt ¶ added in v3.1.0
RunCommandExt is a convenience function to run/log a command and return/log stderr in an error upon failure.
func RunWithExecRunOpts ¶
func RunWithExecRunOpts(cmd *exec.Cmd, opts ExecRunOpts) (string, error)
Types ¶
type CmdOpts ¶ added in v3.1.0
type CmdOpts struct {
// Timeout determines how long to wait for the command to exit
Timeout time.Duration
// FatalTimeout is the amount of additional time to wait after Timeout before fatal SIGKILL
FatalTimeout time.Duration
// Redactor redacts tokens from the output
Redactor func(text string) string
// TimeoutBehavior configures what to do in case of timeout
TimeoutBehavior TimeoutBehavior
// SkipErrorLogging defines whether to skip logging of execution errors (rc > 0)
SkipErrorLogging bool
// CaptureStderr defines whether to capture stderr in addition to stdout
CaptureStderr bool
}
type ExecRunOpts ¶
type ExecRunOpts struct {
// Redactor redacts tokens from the output
Redactor func(text string) string
// TimeoutBehavior configures what to do in case of timeout
TimeoutBehavior TimeoutBehavior
// SkipErrorLogging determines whether to skip logging of execution errors (rc > 0)
SkipErrorLogging bool
// CaptureStderr determines whether to capture stderr in addition to stdout
CaptureStderr bool
}
type TimeoutBehavior ¶ added in v3.1.0
type TimeoutBehavior struct {
// Signal determines the signal to send to the process
Signal syscall.Signal
// ShouldWait determines whether to wait for the command to exit once timeout is reached
ShouldWait bool
}
TimeoutBehavior defines behavior for when the command takes longer than the passed in timeout to exit By default, SIGKILL is sent to the process and it is not waited upon
Click to show internal directories.
Click to hide internal directories.