Documentation
¶
Overview ¶
Package exec wraps os/exec to add a little error sanitization and standardization around process return codes and a channel-based cancel mechanism
Index ¶
- Constants
- func RedactSecrets(s string) string
- type CmdRunResult
- func (r *CmdRunResult) AttachErrorf(msg string, err error)
- func (r CmdRunResult) ErrorStr() string
- func (r CmdRunResult) IsEmpty() bool
- func (r CmdRunResult) WithFriendlyYAMLStrings() CmdRunResult
- func (r CmdRunResult) WithRedactedSecrets() CmdRunResult
- func (r CmdRunResult) WithTruncatedStrings(maxBytes int) CmdRunResult
- type CmdRunner
- type Flag
- type FlagSet
- type PlainCmdRunner
Constants ¶
const TruncationMarker = "[output truncated]\n"
TruncationMarker is prepended to any output field that was clipped. Operators can detect truncation by checking for this prefix.
Variables ¶
This section is empty.
Functions ¶
func RedactSecrets ¶ added in v0.60.10
RedactSecrets masks credential-bearing substrings in subprocess output. It redacts URL userinfo (user:password@host or user@host) to prevent credential leakage in resource status fields, logs, and debug output. For example: https://token:x@registry → https://[REDACTED]@registry
RedactSecrets is idempotent: calling it multiple times produces the same result.
Types ¶
type CmdRunResult ¶
func NewCmdRunResultWithErr ¶
func NewCmdRunResultWithErr(err error) CmdRunResult
func (*CmdRunResult) AttachErrorf ¶
func (r *CmdRunResult) AttachErrorf(msg string, err error)
func (CmdRunResult) ErrorStr ¶
func (r CmdRunResult) ErrorStr() string
func (CmdRunResult) IsEmpty ¶ added in v0.52.0
func (r CmdRunResult) IsEmpty() bool
func (CmdRunResult) WithFriendlyYAMLStrings ¶
func (r CmdRunResult) WithFriendlyYAMLStrings() CmdRunResult
func (CmdRunResult) WithRedactedSecrets ¶ added in v0.60.10
func (r CmdRunResult) WithRedactedSecrets() CmdRunResult
WithRedactedSecrets returns a copy of r with Stdout, Stderr, and Error fields redacted to mask credential-bearing substrings before truncation or output. Redaction must happen before truncation to avoid losing the URL scheme prefix, which would prevent pattern matching (e.g., https://user:pass@host becomes pass@host after tail-truncation, and the regex won't match without the scheme).
func (CmdRunResult) WithTruncatedStrings ¶ added in v0.60.4
func (r CmdRunResult) WithTruncatedStrings(maxBytes int) CmdRunResult
WithTruncatedStrings returns a copy of r with Stdout and Stderr each capped to maxBytes by keeping the tail (the most actionable kapp output always appears last). When a field is under the limit it is left unchanged.
type CmdRunner ¶ added in v0.52.0
type CmdRunner interface {
Run(*exec.Cmd) error
RunWithCancel(cmd *exec.Cmd, cancelCh chan struct{}) error
}
CmdRunner allows to run commands on the OS. All commands running within kapp-controller should happen through an instance of this interface so that they can be intercepted and potentially modified in kctrl when running kapp-controller locally.
type Flag ¶
func NewFlagFromString ¶
type FlagSet ¶ added in v0.52.0
type FlagSet struct {
// contains filtered or unexported fields
}
func NewFlagSet ¶ added in v0.52.0
type PlainCmdRunner ¶ added in v0.52.0
type PlainCmdRunner struct{}
PlainCmdRunner implements CmdRunner interface by simply running exec.Cmd.
func NewPlainCmdRunner ¶ added in v0.52.0
func NewPlainCmdRunner() PlainCmdRunner
NewPlainCmdRunner returns a new PlainCmdRunner.
func (PlainCmdRunner) Run ¶ added in v0.52.0
func (PlainCmdRunner) Run(cmd *exec.Cmd) error
Run executes exec.Cmd.
func (PlainCmdRunner) RunWithCancel ¶ added in v0.52.0
func (PlainCmdRunner) RunWithCancel(cmd *exec.Cmd, cancelCh chan struct{}) error
RunWithCancel executes exec.Cmd. Kills execution immediately if value is read from cancelCh.