Documentation ¶
Overview ¶
Package executers contains general purpose (shell) command executing objects.
Package executers contains general purpose (shell) command executing objects. executers_deps contains platform dependencies that should be mockable in tests
Index ¶
- func CreateScriptFile(scriptPath string, commands []string) (err error)
- func ExecuteCommand(log log.T, cancelFlag task.CancelFlag, workingDir string, ...) (exitCode int, err error)
- func StartCommand(log log.T, cancelFlag task.CancelFlag, workingDir string, ...) (process *os.Process, exitCode int, err error)
- type MockCommandExecuter
- func (m *MockCommandExecuter) Execute(log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, ...) (stdout io.Reader, stderr io.Reader, exitCode int, errs []error)
- func (m *MockCommandExecuter) StartExe(log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, ...) (process *os.Process, exitCode int, errs []error)
- type ShellCommandExecuter
- func (ShellCommandExecuter) Execute(log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, ...) (stdout io.Reader, stderr io.Reader, exitCode int, errs []error)
- func (ShellCommandExecuter) StartExe(log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, ...) (process *os.Process, exitCode int, errs []error)
- type T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateScriptFile ¶
CreateScriptFile creates a script containing the given commands.
func ExecuteCommand ¶
func ExecuteCommand(log log.T, cancelFlag task.CancelFlag, workingDir string, stdoutWriter io.Writer, stderrWriter io.Writer, executionTimeout int, commandName string, commandArguments []string, ) (exitCode int, err error)
ExecuteCommand executes the given commands using the given working directory. Standard output and standard error are sent to the given writers.
func StartCommand ¶
func StartCommand(log log.T, cancelFlag task.CancelFlag, workingDir string, stdoutWriter io.Writer, stderrWriter io.Writer, commandName string, commandArguments []string, ) (process *os.Process, exitCode int, err error)
StartCommand starts the given commands using the given working directory. Standard output and standard error are sent to the given writers.
Types ¶
type MockCommandExecuter ¶
MockCommandExecuter mocks a command executer.
func (*MockCommandExecuter) Execute ¶
func (m *MockCommandExecuter) Execute(log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, cancelFlag task.CancelFlag, executionTimeout int, commandName string, commandArguments []string, ) (stdout io.Reader, stderr io.Reader, exitCode int, errs []error)
Execute is a mocked method that just returns what mock tells it to.
func (*MockCommandExecuter) StartExe ¶
func (m *MockCommandExecuter) StartExe(log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, cancelFlag task.CancelFlag, commandName string, commandArguments []string, ) (process *os.Process, exitCode int, errs []error)
StartExe is a mocked method that just returns what mock tells it to.
type ShellCommandExecuter ¶
type ShellCommandExecuter struct { }
ShellCommandExecuter is specially added for testing purposes
func (ShellCommandExecuter) Execute ¶
func (ShellCommandExecuter) Execute( log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, cancelFlag task.CancelFlag, executionTimeout int, commandName string, commandArguments []string, ) (stdout io.Reader, stderr io.Reader, exitCode int, errs []error)
Execute executes a list of shell commands in the given working directory. The orchestration directory specifies where to create the script file and where to save stdout and stderr. The orchestration directory will be created if it doesn't exist. Returns readers for the standard output and standard error streams and a set of errors. The errors need not be fatal - the output streams may still have data even though some errors are reported. For example, if the command got killed while executing, the streams will have whatever data was printed up to the kill point, and the errors will indicate that the process got terminated.
func (ShellCommandExecuter) StartExe ¶
func (ShellCommandExecuter) StartExe( log log.T, workingDir string, stdoutFilePath string, stderrFilePath string, cancelFlag task.CancelFlag, commandName string, commandArguments []string, ) (process *os.Process, exitCode int, errs []error)
StartExe starts a list of shell commands in the given working directory. The orchestration directory specifies where to create the script file and where to save stdout and stderr. The orchestration directory will be created if it doesn't exist. Returns readers for the standard output and standard error streams and a set of errors. The errors need not be fatal - the output streams may still have data even though some errors are reported. For example, if the command got killed while executing, the streams will have whatever data was printed up to the kill point, and the errors will indicate that the process got terminated.