executor

package
v1.21.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 17 Imported by: 5 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cmd *exec.Cmd) error

Run starts the command, waits for it to complete, and returns the error. The child PID is registered in the global process registry while the process is running so that a PID-1 zombie reaper does not steal it.

Types

type CmdUsage

type CmdUsage struct {
	Sys    time.Duration
	User   time.Duration
	MaxRss int64
}

type Executor added in v1.5.2

type Executor struct {
	// contains filtered or unexported fields
}

func NewExecutor added in v1.5.2

func NewExecutor(dir string, entrypoint string, args []string, envs []string) *Executor

func (*Executor) Output added in v1.5.2

func (e *Executor) Output() ([]byte, error)

func (*Executor) RunAndLogLines added in v1.5.2

func (e *Executor) RunAndLogLines(ctx context.Context, logLabels map[string]string) (*CmdUsage, error)

func (*Executor) WithCMDStderr added in v1.5.2

func (e *Executor) WithCMDStderr(w io.Writer) *Executor

func (*Executor) WithCMDStdout added in v1.5.2

func (e *Executor) WithCMDStdout(w io.Writer) *Executor

func (*Executor) WithChroot added in v1.6.0

func (e *Executor) WithChroot(path string) *Executor

func (*Executor) WithLogProxyHookJSON added in v1.5.2

func (e *Executor) WithLogProxyHookJSON(logProxyHookJSON bool) *Executor

func (*Executor) WithLogProxyHookJSONKey added in v1.5.2

func (e *Executor) WithLogProxyHookJSONKey(logProxyHookJSONKey string) *Executor

func (*Executor) WithLogger added in v1.5.2

func (e *Executor) WithLogger(logger *log.Logger) *Executor

func (*Executor) WithRunner added in v1.21.2

func (e *Executor) WithRunner(runner Runner) *Executor

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.

func (ProcessRunner) Run added in v1.21.2

func (ProcessRunner) Run(_ context.Context, cmd *exec.Cmd) (*CmdUsage, error)

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

type Runner interface {
	Run(ctx context.Context, cmd *exec.Cmd) (*CmdUsage, error)
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL