Documentation
¶
Overview ¶
Package exec provides an abstraction for executing podman commands.
Index ¶
- type Executor
- type FakeExecutor
- func (f *FakeExecutor) AssertOutputCalledWith(t interface{ ... }, expectedArgs ...string)
- func (f *FakeExecutor) AssertRunCalledWith(t interface{ ... }, expectedArgs ...string)
- func (f *FakeExecutor) AssertRunInteractiveCalledWith(t interface{ ... }, expectedArgs ...string)
- func (f *FakeExecutor) Output(ctx context.Context, stderr io.Writer, args ...string) ([]byte, error)
- func (f *FakeExecutor) Run(ctx context.Context, stdout, stderr io.Writer, args ...string) error
- func (f *FakeExecutor) RunInteractive(ctx context.Context, args ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor interface {
// Run executes a podman command, writing stdout and stderr to the provided writers.
// Returns an error if the command fails.
Run(ctx context.Context, stdout, stderr io.Writer, args ...string) error
// Output executes a podman command and returns its standard output.
// Stderr is written to the provided writer.
// Returns an error if the command fails.
Output(ctx context.Context, stderr io.Writer, args ...string) ([]byte, error)
// RunInteractive executes a podman command with stdin/stdout/stderr connected to the terminal.
// This is used for interactive sessions where user input is required.
// Returns an error if the command fails.
RunInteractive(ctx context.Context, args ...string) error
}
Executor provides an interface for executing podman commands.
type FakeExecutor ¶
type FakeExecutor struct {
// RunFunc is called when Run is invoked. If nil, Run returns nil.
RunFunc func(ctx context.Context, args ...string) error
// OutputFunc is called when Output is invoked. If nil, Output returns empty bytes.
OutputFunc func(ctx context.Context, args ...string) ([]byte, error)
// RunInteractiveFunc is called when RunInteractive is invoked. If nil, RunInteractive returns nil.
RunInteractiveFunc func(ctx context.Context, args ...string) error
// RunCalls tracks all calls to Run with their arguments.
RunCalls [][]string
// OutputCalls tracks all calls to Output with their arguments.
OutputCalls [][]string
// RunInteractiveCalls tracks all calls to RunInteractive with their arguments.
RunInteractiveCalls [][]string
}
FakeExecutor is a fake implementation of Executor for testing.
func (*FakeExecutor) AssertOutputCalledWith ¶
func (f *FakeExecutor) AssertOutputCalledWith(t interface { Errorf(format string, args ...interface{}) }, expectedArgs ...string)
AssertOutputCalledWith checks if Output was called with the expected arguments.
func (*FakeExecutor) AssertRunCalledWith ¶
func (f *FakeExecutor) AssertRunCalledWith(t interface { Errorf(format string, args ...interface{}) }, expectedArgs ...string)
AssertRunCalledWith checks if Run was called with the expected arguments.
func (*FakeExecutor) AssertRunInteractiveCalledWith ¶
func (f *FakeExecutor) AssertRunInteractiveCalledWith(t interface { Errorf(format string, args ...interface{}) }, expectedArgs ...string)
AssertRunInteractiveCalledWith checks if RunInteractive was called with the expected arguments.
func (*FakeExecutor) Output ¶
func (f *FakeExecutor) Output(ctx context.Context, stderr io.Writer, args ...string) ([]byte, error)
Output executes the OutputFunc if set, otherwise returns empty bytes.
func (*FakeExecutor) RunInteractive ¶
func (f *FakeExecutor) RunInteractive(ctx context.Context, args ...string) error
RunInteractive executes the RunInteractiveFunc if set, otherwise returns nil.
Click to show internal directories.
Click to hide internal directories.