Documentation
¶
Overview ¶
Package execx runs external tools such as terragrunt, terraform, tofu and mise. It handles timeouts, one interrupt and then a kill on cancellation, an environment allowlist, and debug logs with secrets redacted.
Index ¶
Constants ¶
const DefaultTimeout = 30 * time.Minute
DefaultTimeout is the per-command timeout when neither WithTimeout nor Cmd.Timeout sets one.
const DefaultWaitDelay = 10 * time.Second
DefaultWaitDelay is how long a child gets between the interrupt and the kill.
const Redacted = "***"
Redacted replaces secret values in logged command lines.
Variables ¶
var ErrNotFound = errors.New("executable not found")
ErrNotFound is returned when the executable isn't on the child's PATH or isn't executable.
var ErrTimeout = errors.New("command timed out")
ErrTimeout is returned when a command runs longer than its timeout.
Functions ¶
func DefaultEnvAllow ¶
func DefaultEnvAllow() []string
DefaultEnvAllow lists the environment variables passed to child processes. Entries ending in "*" are prefixes. Names match case-insensitively on Windows, where PATH is often spelled Path.
Types ¶
type Cmd ¶
type Cmd struct {
Name string // looked up on the child's PATH unless it contains a path separator
Args []string
Dir string
Env []string // extra KEY=VALUE pairs, passed regardless of the allowlist; only keys are logged
Stdin io.Reader
Stdout io.Writer // nil captures into Result.Stdout
Stderr io.Writer // also receives stderr, which is captured either way
Timeout time.Duration // overrides the Runner default; negative disables it
}
Cmd describes one invocation.
type Option ¶
type Option func(*Runner)
Option configures a Runner.
func WithEnvAllow ¶
WithEnvAllow replaces the environment allowlist.
func WithEnviron ¶
WithEnviron sets the parent environment the allowlist is applied to (default os.Environ).
func WithTimeout ¶
WithTimeout sets the default per-command timeout.
func WithWaitDelay ¶
WithWaitDelay sets how long a child gets between the interrupt and the kill.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner starts commands. The zero value is not usable; use NewRunner.