Documentation
¶
Index ¶
- type AnalyzerOption
- type Error
- type Errors
- type Executable
- type ExecutionStrategy
- type Executor
- type ExecutorOption
- type Option
- func WithArgs(args []string) Option
- func WithDir(workingDirectory string) Option
- func WithEnv(env []string) Option
- func WithHook(lifecycle v1.Lifecycle, fn v1.HookFunction) Option
- func WithID(id string) Option
- func WithOutputAnalyzer(heuristics []OutputAnalyzerHeuristic, opts ...AnalyzerOption) Option
- func WithOutputSinks(sinks ...io.WriteCloser) Option
- func WithTimeout(timeout time.Duration) Option
- type OutputAnalyzer
- type OutputAnalyzerHeuristic
- type StdioExecutable
- type StdioProcess
- type StdioProcessHooks
- type WaitFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalyzerOption ¶
type AnalyzerOption func(*analyzerConfig)
AnalyzerOption is a functional option for configuring an OutputAnalyzer.
func StderrCheckForProvider ¶
func StderrCheckForProvider(provider console.StackType) AnalyzerOption
StderrCheckForProvider returns an AnalyzerOption that enables stderr checking only for providers where stderr reliably indicates errors (e.g. Terraform), and disables it for providers that write non-error output to stderr (e.g. Ansible).
func WithStderrCheck ¶
func WithStderrCheck(check bool) AnalyzerOption
WithStderrCheck enables or disables treating stderr output as an error.
type Executable ¶
type Executable interface {
ID() string
Run(ctx context.Context) error
Start(ctx context.Context) (WaitFn, error)
RunWithOutput(ctx context.Context) ([]byte, error)
RunStream(ctx context.Context, cb func([]byte)) error
Command() string
}
func NewExecutable ¶
func NewExecutable(command string, options ...Option) Executable
type ExecutionStrategy ¶
type ExecutionStrategy string
ExecutionStrategy defines how executables queue should be processed.
const ( ExecutionStrategyParallel ExecutionStrategy = "parallel" ExecutionStrategyOrdered ExecutionStrategy = "ordered" )
type Executor ¶
type Executor interface {
Start(ctx context.Context) error
Add(executable Executable) error
}
func NewExecutor ¶
func NewExecutor(errChan chan error, finishedChan chan struct{}, options ...ExecutorOption) Executor
type ExecutorOption ¶
type ExecutorOption func(*executor)
func WithExecutionStrategy ¶
func WithExecutionStrategy(strategy ExecutionStrategy) ExecutorOption
func WithPostRunFunc ¶
func WithPostRunFunc(fn func(string, error)) ExecutorOption
func WithPreRunFunc ¶
func WithPreRunFunc(fn func(string)) ExecutorOption
type Option ¶
type Option func(*executable)
func WithOutputAnalyzer ¶
func WithOutputAnalyzer(heuristics []OutputAnalyzerHeuristic, opts ...AnalyzerOption) Option
func WithOutputSinks ¶
func WithOutputSinks(sinks ...io.WriteCloser) Option
func WithTimeout ¶
type OutputAnalyzer ¶
type OutputAnalyzer interface {
Stdout() io.Writer
Stderr() io.Writer
// Detect scans the output for potential errors.
// It uses a custom heuristics to detect issues.
// It can result in a false positives.
//
// Note: Make sure that it is executed after Write
// has finished to ensure proper detection.
Detect() []error
}
OutputAnalyzer captures the command output and attempts to detect potential errors.
func NewOutputAnalyzer ¶
func NewOutputAnalyzer(heuristics []OutputAnalyzerHeuristic, opts ...AnalyzerOption) OutputAnalyzer
type OutputAnalyzerHeuristic ¶
func NewKeywordDetector ¶
func NewKeywordDetector() OutputAnalyzerHeuristic
type StdioExecutable ¶ added in v0.6.65
type StdioExecutable interface {
Executable
StartWithStdio(context.Context) (*StdioProcess, error)
}
StdioExecutable is implemented by executables that can be started with bidirectional standard streams. It is intentionally separate from Executable so existing callers and test doubles keep their contracts.
type StdioProcess ¶ added in v0.6.65
type StdioProcess struct {
Stdin io.WriteCloser
Stdout io.ReadCloser
Stderr io.ReadCloser
// contains filtered or unexported fields
}
StdioProcess is a running executable with bidirectional standard input and output. The process owner must drain Stdout before calling Wait. Standard error is retained as a bounded diagnostic tail. Stop closes the input stream and terminates the process; it is safe to call more than once.
func NewStdioProcess ¶ added in v0.6.65
func NewStdioProcess(stdin io.WriteCloser, stdout, stderr io.ReadCloser, hooks StdioProcessHooks) *StdioProcess
NewStdioProcess wraps bidirectional streams and their lifecycle operations.
func StartWithStdio ¶ added in v0.6.65
StartWithStdio creates and starts a command with bidirectional standard streams. It is additive to NewExecutable and leaves existing execution behavior unchanged.
func (*StdioProcess) Close ¶ added in v0.6.65
func (p *StdioProcess) Close() error
Close closes all process streams. It does not wait for the process.
func (*StdioProcess) Kill ¶ added in v0.6.65
func (p *StdioProcess) Kill() error
Kill terminates the child process without waiting for it.
func (*StdioProcess) StderrTail ¶ added in v0.6.65
func (p *StdioProcess) StderrTail() string
StderrTail returns a bounded tail of the child's standard error.
func (*StdioProcess) Stop ¶ added in v0.6.65
func (p *StdioProcess) Stop() error
Stop closes stdin and terminates the child process.
func (*StdioProcess) Wait ¶ added in v0.6.65
func (p *StdioProcess) Wait() error
Wait waits for the process and runs its post-start lifecycle hook. It also closes the process streams after the child exits.
type StdioProcessHooks ¶ added in v0.6.65
type StdioProcessHooks struct {
Wait func() error
Kill func() error
Stop func() error
Close func() error
StderrTail func() string
}
StdioProcessHooks supplies lifecycle operations for a StdioProcess. It is useful for protocol adapters and deterministic tests that provide their own in-memory streams.