Documentation
¶
Overview ¶
Package execx locates and runs the external tools lo still shells out to. Lookup prefers the project's b-managed toolchain (.bin) over PATH, so lo works without the caller having prepared any environment.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("executable not found")
ErrNotFound is the Runner's error when a tool name resolves nowhere (wrapped as `<name>: executable not found`); errors.Is matches it.
Functions ¶
func ExitCode ¶
ExitCode maps a Runner error to the subprocess exit code: nil → 0, an *exec.ExitError or anything carrying ExitCode() → its code, anything else (the tool was not found, the context ended) → 1. A child that died of a signal reports 128+n, which is what bash's `$?` shows for it (130 for SIGINT, 143 for SIGTERM); exec.ExitError.ExitCode alone reports -1 there, and -1 reaches os.Exit as 255.
func Look ¶
Look resolves tool to an executable path: $PATH_BIN/<tool> when present and executable, else the first PATH hit. ok is false when the tool is nowhere. A nil p skips the .bin step (PATH only — the runner for code that has no project, like the toolchain doctor).
func Output ¶
Output runs c through r and returns its stdout — the `$(cmd 2>/dev/null)` shape of the bash ports (and of exec.Cmd.Output, whose stderr capture none of the call sites ever read). Stdin is closed and stderr is discarded unless c sets them. Stdout must be unset.
func PrependPATH ¶
PrependPATH returns the process PATH with dirs prepended, in the given order, each only when it is not on PATH already; an empty dir is skipped. It is the one spelling of "the PATH lo prepares for a child" (the bash shim, the provider bridge, recover, the render children).
func TrimNewlines ¶
TrimNewlines drops the trailing newlines of s, as a bash command substitution (`$(…)`) does with a tool's output or a file's content.
Types ¶
type Cmd ¶
type Cmd struct {
// Name is the tool name, resolved via Look (b-managed .bin first, then
// PATH). A value containing a path separator is used as-is.
Name string
Args []string
// Dir is the working directory ("" = inherit). The kubeone driver
// depends on this: `kubeone apply` writes <name>-kubeconfig into its
// CWD, so the apply MUST run inside the work dir.
Dir string
// Env entries are appended to the inherited environment.
Env []string
// Stdin/Stdout/Stderr default to the process's own when nil.
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
}
Cmd describes one external process invocation.