Documentation ¶
Overview ¶
Package genericexec provides a common interface to execute local commands and remote commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd interface { // Run runs an external command synchronously. // // extraArgs is appended to the base arguments passed to the constructor // of Cmd. stdin specifies the data sent to the standard input of the // process. The standard output/error of the process are written to // stdout/stderr. Run(ctx context.Context, extraArgs []string, stdin io.Reader, stdout, stderr io.Writer) error // Interact starts an external command asynchronously. // // extraArgs is appended to the base arguments passed to the constructor // of Cmd. Returned Process can be used to interact with the new // subprocess. // // When ctx is canceled, the subprocess is killed by a signal, or // stdin of the subprocess is closed, depending on implementation. // Therefore Interact is safe to be used only with external commands // that exit on closing stdin. Interact(ctx context.Context, extraArgs []string) (Process, error) // DebugCommand returns a new command that runs the existing command under a // debugger waiting on port debugPort, if debugPort is non-zero. // It will also ensure that the command is runnable, such as by killing // the old debugger. DebugCommand(ctx context.Context, debugPort int) (Cmd, error) }
Cmd is a common interface abstracting an external command to execute.
type ExecCmd ¶
type ExecCmd struct {
// contains filtered or unexported fields
}
ExecCmd represents a local command to execute.
func CommandExec ¶
CommandExec constructs a new ExecCmd representing a local command to execute.
func (*ExecCmd) DebugCommand ¶
DebugCommand returns a version of this command that will run under the debugger.
type ExecProcess ¶
type ExecProcess struct {
// contains filtered or unexported fields
}
ExecProcess represents a locally running process.
func (*ExecProcess) ProcessState ¶
func (p *ExecProcess) ProcessState() *os.ProcessState
ProcessState returns the os.ProcessState object for the process..
func (*ExecProcess) Stderr ¶
func (p *ExecProcess) Stderr() io.ReadCloser
Stderr returns stderr of the process.
func (*ExecProcess) Stdin ¶
func (p *ExecProcess) Stdin() io.WriteCloser
Stdin returns stdin of the process.
func (*ExecProcess) Stdout ¶
func (p *ExecProcess) Stdout() io.ReadCloser
Stdout returns stdout of the process.
type Process ¶
type Process interface { // Stdin returns stdin of the process. Stdin() io.WriteCloser // Stdout returns stdout of the process. Stdout() io.ReadCloser // Stderr returns stderr of the process. Stderr() io.ReadCloser // Wait waits for the process to exit. // // Wait also releases resources associated to the process, so it must // be always called when you are done with it. // // Upon Wait finishes, io.ReadCloser returned by Stdout and Stderr // might be closed. This means that it is wrong to call Wait before // finishing to read necessary data from stdout/stderr. // // When ctx is canceled, the subprocess is killed by a signal, or // stdin of the subprocess is closed, depending on implementation. Wait(ctx context.Context) error }
Process is a common interface abstracting a running external process.
type SSHCmd ¶
type SSHCmd struct {
// contains filtered or unexported fields
}
SSHCmd represents a remote command to execute via SSH.
func CommandSSH ¶
CommandSSH constructs a new SSHCmd representing a remote command to execute via SSH.
func (*SSHCmd) DebugCommand ¶
DebugCommand returns a version of this command that will run under the debugger.
type SSHProcess ¶
type SSHProcess struct {
// contains filtered or unexported fields
}
SSHProcess represents a remotely running process over SSH.
func (*SSHProcess) Stderr ¶
func (p *SSHProcess) Stderr() io.ReadCloser
Stderr returns stderr of the process.
func (*SSHProcess) Stdin ¶
func (p *SSHProcess) Stdin() io.WriteCloser
Stdin returns stdin of the process.
func (*SSHProcess) Stdout ¶
func (p *SSHProcess) Stdout() io.ReadCloser
Stdout returns stdout of the process.