Documentation
¶
Overview ¶
Package proc runs external commands with a mandatory deadline.
allbctl inspects the host by shelling out to dozens of tools (package managers, cloud CLIs, ssh-add, gpg, ...). Any one of them can block forever: waiting on a locked agent socket, a credential prompt, or a dead network. Every external command therefore goes through this package, which guarantees that a command is killed once its deadline passes and that it can never read from the terminal.
Index ¶
- Constants
- Variables
- func CombinedOutput(ctx context.Context, name string, args ...string) ([]byte, error)
- func Environ(env []string) []string
- func Exists(name string) bool
- func Output(ctx context.Context, name string, args ...string) ([]byte, error)
- func OutputString(ctx context.Context, name string, args ...string) (string, error)
- func Run(ctx context.Context, name string, args ...string) error
Constants ¶
const DefaultTimeout = 10 * time.Second
DefaultTimeout bounds a command when the caller's context has no deadline.
Variables ¶
var ErrTimeout = errors.New("command timed out")
ErrTimeout is returned (wrapped) when a command is killed for exceeding its deadline.
Functions ¶
func CombinedOutput ¶
CombinedOutput runs the command and returns standard output and standard error interleaved. Standard input is empty.
func Environ ¶
Environ returns env without the variables that bind git to a specific repository.
When allbctl (or its test suite) is started from a git hook it inherits GIT_DIR and friends. Left in place, every `git -C <other repo> ...` it runs would silently operate on the hook's repository instead: status would report the wrong repository, and `git init` would rewrite the hook repository's own config.
func Output ¶
Output runs the command and returns its standard output. Standard error is discarded and standard input is empty.
func OutputString ¶
OutputString runs the command and returns its standard output with surrounding whitespace removed.
Types ¶
This section is empty.