Documentation ¶
Index ¶
- type Context
- func (ec *Context) AddFile(filename string, content []byte) error
- func (ec *Context) Exec(stdout, stderr io.Writer, cleanup func(), args ...string) (*Result, error)
- func (ec *Context) ExecSync(args ...string) (string, string, error)
- func (ec *Context) ExecWithLogFile(logPrefix string, args ...string) (*Result, string, error)
- func (ec *Context) ExecWithLogFileSync(logPrefix string, args ...string) (string, error)
- func (ec *Context) LogFile(logFilename string) (io.ReadCloser, error)
- func (ec *Context) SetEnvVars(envVars map[string]string)
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { WorkingDir *string LogPath *string // contains filtered or unexported fields }
Context is a set of information surrounding how to execute a certain executable. It provides utilities for executing the same executable multiple times with the same working directory and log path, and allows for adding files to the working directory, setting the environment, and retrieving log files.
func NewContext ¶
func (*Context) AddFile ¶
AddFile adds a new file with the contents to the working directory of the Context.
func (*Context) Exec ¶
Exec begins executing the executable, and returns a Result containing the Pid of the process, as well as a function that will wait for the process to complete and clean up, returning an error if the process failed. Exec will forward stdout and stderr of the spawned process to the respective io.Writers passed in. cleanup should do any extra cleanup necessary required by the calling function (such as closing a log file that stdout/stderr are being piped to). If there is no cleanup to be done, nil may be passed.
func (*Context) ExecWithLogFile ¶
ExecWithLogFile runs Exec, piping stdout and stderr to a log file which is created in the LogPath of the exec context, whose filename will be logPrefix-<generated-UUID>.log. ExecWithLogFile returns the Result from Exec, along with the log's filename.
func (*Context) ExecWithLogFileSync ¶
ExecWithLogFileSync runs ExecWithLogFile but blocks until the process has completed, returning the log filename.
func (*Context) LogFile ¶
func (ec *Context) LogFile(logFilename string) (io.ReadCloser, error)
LogFile returns an io.ReadCloser for the log file with the given logFilename in the LogPath.
func (*Context) SetEnvVars ¶
SetEnvVars overrides the existing EnvVars for the