Documentation ¶
Index ¶
- Constants
- func CurrentEnvironment() []string
- func Execute(program string, args ...string) (stdout, stderr string, err error)
- func ExecuteAndLogToFile(filepath string, command string, args ...string)
- func ExecuteLive(squashErrors bool, program string, args ...string) (err error)
- func ExecuteLiveWithErr(stderrLines int, program string, args ...string) (err error)
- func ExecuteWithStdin(input, program string, args ...string) (stdout, stderr string, err error)
- func MustExecuteLive(command string, args ...string)
- func PermanentlyStopAllChildProcesses(signal unix.Signal)
- func SetEnvironment(env []string)
- func StopAllChildProcesses(signal unix.Signal)
- type ExecBuilder
- func (b ExecBuilder) Callbacks(stdoutCallback LogCallback, stderrCallback LogCallback) ExecBuilder
- func (b ExecBuilder) EnvironmentVariables(environmentVariables []string) ExecBuilder
- func (b ExecBuilder) ErrorStderrLines(lines int) ExecBuilder
- func (b ExecBuilder) Execute() error
- func (b ExecBuilder) ExecuteCaptureOuput() (string, string, error)
- func (b ExecBuilder) LogLevel(stdoutLogLevel logrus.Level, stderrLogLevel logrus.Level) ExecBuilder
- func (b ExecBuilder) StderrCallback(stderrCallback LogCallback) ExecBuilder
- func (b ExecBuilder) StderrLogLevel(stderrLogLevel logrus.Level) ExecBuilder
- func (b ExecBuilder) Stdin(value string) ExecBuilder
- func (b ExecBuilder) StdoutCallback(stdoutCallback LogCallback) ExecBuilder
- func (b ExecBuilder) StdoutLogLevel(stdoutLogLevel logrus.Level) ExecBuilder
- func (b ExecBuilder) WarnLogLines(lines int) ExecBuilder
- func (b ExecBuilder) WorkingDirectory(path string) ExecBuilder
- type LogCallback
Constants ¶
const ( // LogDisabledLevel is a fake logrus log level, that is used by ExecBuilder to represent that logging should be // disabled. LogDisabledLevel logrus.Level = math.MaxUint32 // DefaultWarnLogLines is a default value that can be used with the WarnLogLines function. DefaultWarnLogLines int = 1500 )
const ShellProgram = "/bin/bash"
ShellProgram is the default shell program used by the tooling.
Variables ¶
This section is empty.
Functions ¶
func CurrentEnvironment ¶
func CurrentEnvironment() []string
CurrentEnvironment returns the current environment variables that are being used for all processes launched from this package.
func ExecuteAndLogToFile ¶
ExecuteAndLogToFile runs a command in the shell and redirects stdout to the given file
func ExecuteLive ¶
ExecuteLive runs a command in the shell and logs it in real-time
func ExecuteLiveWithErr ¶
ExecuteLiveWithErr runs a command in the shell and logs it in real-time. In addition, if there is an error, the last x lines of stderr will be attached to the err object.
func ExecuteWithStdin ¶
ExecuteWithStdin - Run the command and use Stdin to pass input during execution
func MustExecuteLive ¶
MustExecuteLive executes the shell command. Panics on failure.
func PermanentlyStopAllChildProcesses ¶
PermanentlyStopAllChildProcesses will send the provided signal to all processes spawned by this package, and all of those process's children. Invoking this will also block future process creation, causing the Execute methods to return an error. Be aware that this will block the gpg-agent cleanup mechanism from running, which may cause chroots to not unmount properly. Consider using StopAllChildProcesses instead.
func SetEnvironment ¶
func SetEnvironment(env []string)
SetEnvironment sets the default environment variables to be used for all processes launched from this package.
func StopAllChildProcesses ¶
StopAllChildProcesses will stop all currently running processes spawned by this package, but will not block future process creation.
Types ¶
type ExecBuilder ¶
type ExecBuilder struct {
// contains filtered or unexported fields
}
func NewExecBuilder ¶
func NewExecBuilder(command string, args ...string) ExecBuilder
NewExecBuilder initializes a new execution builder object.
func (ExecBuilder) Callbacks ¶
func (b ExecBuilder) Callbacks(stdoutCallback LogCallback, stderrCallback LogCallback) ExecBuilder
Callbacks sets the callback functions for both stdout and stderr.
func (ExecBuilder) EnvironmentVariables ¶
func (b ExecBuilder) EnvironmentVariables(environmentVariables []string) ExecBuilder
EnvironmentVariables sets the complete list of environment variables for the command to be executed.
func (ExecBuilder) ErrorStderrLines ¶
func (b ExecBuilder) ErrorStderrLines(lines int) ExecBuilder
ErrorStderrLines sets the number of stderr lines to add to the error object, if the execution fails.
func (ExecBuilder) Execute ¶
func (b ExecBuilder) Execute() error
func (ExecBuilder) ExecuteCaptureOuput ¶
func (b ExecBuilder) ExecuteCaptureOuput() (string, string, error)
func (ExecBuilder) LogLevel ¶
func (b ExecBuilder) LogLevel(stdoutLogLevel logrus.Level, stderrLogLevel logrus.Level) ExecBuilder
Sets the log level for stdout and stderr lines.
func (ExecBuilder) StderrCallback ¶
func (b ExecBuilder) StderrCallback(stderrCallback LogCallback) ExecBuilder
StderrCallback sets a callback function that it called for each line of stderr.
func (ExecBuilder) StderrLogLevel ¶
func (b ExecBuilder) StderrLogLevel(stderrLogLevel logrus.Level) ExecBuilder
Sets the log level for stderr lines.
func (ExecBuilder) Stdin ¶
func (b ExecBuilder) Stdin(value string) ExecBuilder
Stdin sets a string value to be passed to the process via stdin.
func (ExecBuilder) StdoutCallback ¶
func (b ExecBuilder) StdoutCallback(stdoutCallback LogCallback) ExecBuilder
StdoutCallback sets a callback function that it called for each line of stdout.
func (ExecBuilder) StdoutLogLevel ¶
func (b ExecBuilder) StdoutLogLevel(stdoutLogLevel logrus.Level) ExecBuilder
Sets the log level for stdout lines.
func (ExecBuilder) WarnLogLines ¶
func (b ExecBuilder) WarnLogLines(lines int) ExecBuilder
WarnLogLines sets the number of stdout/stderr lines that will be printed as warning logs if the process returns an error.
Note: This function exists for the sake of compatability with existing code. It is generally preferable to set the stdout and stderr log levels to an appropriate value.
func (ExecBuilder) WorkingDirectory ¶
func (b ExecBuilder) WorkingDirectory(path string) ExecBuilder
WorkingDirectory sets the working directory for the command to be executed.
type LogCallback ¶
type LogCallback func(line string)