Documentation
¶
Index ¶
- func Run(cmd *exec.Cmd) error
- type CmdUsage
- type Executor
- func (e *Executor) Output() ([]byte, error)
- func (e *Executor) RunAndLogLines(ctx context.Context, logLabels map[string]string) (*CmdUsage, error)
- func (e *Executor) WithCMDStderr(w io.Writer) *Executor
- func (e *Executor) WithCMDStdout(w io.Writer) *Executor
- func (e *Executor) WithChroot(path string) *Executor
- func (e *Executor) WithLogProxyHookJSON(logProxyHookJSON bool) *Executor
- func (e *Executor) WithLogProxyHookJSONKey(logProxyHookJSONKey string) *Executor
- func (e *Executor) WithLogger(logger *log.Logger) *Executor
- func (e *Executor) WithRunner(runner Runner) *Executor
- type ProcessRunner
- type ProcessTracker
- type Runner
- type StderrError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Executor ¶ added in v1.5.2
type Executor struct {
// contains filtered or unexported fields
}
func NewExecutor ¶ added in v1.5.2
func (*Executor) RunAndLogLines ¶ added in v1.5.2
func (*Executor) WithCMDStderr ¶ added in v1.5.2
func (*Executor) WithCMDStdout ¶ added in v1.5.2
func (*Executor) WithChroot ¶ added in v1.6.0
func (*Executor) WithLogProxyHookJSON ¶ added in v1.5.2
func (*Executor) WithLogProxyHookJSONKey ¶ added in v1.5.2
func (*Executor) WithLogger ¶ added in v1.5.2
func (*Executor) WithRunner ¶ added in v1.21.2
WithRunner sets how RunAndLogLines runs the command. A nil runner keeps ProcessRunner. Output, used for the --config call, always starts a process.
type ProcessRunner ¶ added in v1.21.2
type ProcessRunner struct{}
ProcessRunner runs a hook command as a child process. The context is not used to stop the process: a hook runs to completion, as it always has.
type ProcessTracker ¶ added in v1.17.5
type ProcessTracker interface {
// IsActive reports whether pid is currently tracked as a running process.
IsActive(pid int) bool
}
ProcessTracker is a read-only view into the process registry. It is intended for consumers (such as a PID-1 zombie reaper) that need to check whether a PID is managed by the executor but must not modify the registry.
func Tracker ¶ added in v1.17.5
func Tracker() ProcessTracker
Tracker returns a read-only view of the global process registry. The zombie reaper should call this once and use the returned ProcessTracker to check whether a PID is managed by the executor.
type Runner ¶ added in v1.21.2
Runner starts a prepared hook command and waits for it to finish.
cmd carries what the hook is run with: Path, Args, Env, Dir, and the writers its stdout and stderr go to. A Runner must leave the other fields alone. Run returns an error when the hook could not be run or exited with a non-zero code; whatever the hook wrote to stderr is turned into a StderrError by the caller.
ProcessRunner, the default, starts cmd as a child process. An application embedding shell-operator may supply its own Runner, for example one that hands the command to a long-lived interpreter instead of starting a fresh one for every event, and fall back to ProcessRunner for the rest.
type StderrError ¶ added in v1.16.4
type StderrError struct {
Message string
}
StderrError is returned by RunAndLogLines when a command fails and produces output on stderr. Callers can use errors.As to access the raw stderr content.
func (*StderrError) Error ¶ added in v1.16.4
func (e *StderrError) Error() string