Documentation
¶
Overview ¶
Package exec allows for a CLI tool to be executed in different contexts
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetWorkdirAsLinuxPath ¶
GetWorkdirAsLinuxPath is useful for consistently mapping any host fs to what is typically in container environments (Linux)
func ToLinuxPath ¶
ToLinuxPath ensures windows paths can be mapped to linux container paths
func WillDocker ¶
func WillDocker() error
WillDocker checks whether Docker is available on the host (via the socket).
func WillPodman ¶
func WillPodman() error
WillPodman checks whether Podman is available and responsive on the host.
Types ¶
type DockerExecutor ¶
DockerExecutor runs CLI tools inside a Docker container.
func (*DockerExecutor) Cleanup ¶
func (e *DockerExecutor) Cleanup() error
Cleanup stops and removes the temporary Docker container created during Setup.
func (*DockerExecutor) Exec ¶
func (e *DockerExecutor) Exec(i Instance, filePath string, stdout io.Writer, stderr io.Writer) error
Exec runs the configured command inside the prepared Docker container.
func (*DockerExecutor) Setup ¶
func (e *DockerExecutor) Setup() error
Setup creates and starts a disposable Docker container for executing commands.
type Executor ¶
type Executor interface {
Setup() error
Exec(i Instance, filepath string, stdout io.Writer, stderr io.Writer) error
Cleanup() error
}
Executor abstracts how a CLI tool is executed (host, Docker, Podman, etc.). Implementations should prepare resources in Setup, execute the tool in Exec, and free resources in Cleanup.
type HostExecutor ¶
type HostExecutor struct {
}
HostExecutor runs CLI tools directly on the host operating system.
func (*HostExecutor) Cleanup ¶
func (e *HostExecutor) Cleanup() error
Cleanup releases any resources allocated during host execution setup.
func (*HostExecutor) Exec ¶
Exec runs the configured CLI tool on the host against the provided file.
func (*HostExecutor) Setup ¶
func (e *HostExecutor) Setup() error
Setup performs any required initialization for host execution.
type Instance ¶
type Instance struct {
Bin string `json:"bin" yaml:"bin" jsonschema_required:"true" jsonschema_description:"the binary or command to use"`
Start Par `` /* 134-byte string literal not displayed */
End Par `json:"end,flow,omitempty" yaml:"end,flow,omitempty" jsonschema_description:"parameters that will be put behind the file path"`
ChDir bool `` /* 145-byte string literal not displayed */
}
Instance describes a single CLI execution configuration for a linter tool. It specifies the binary to run, positional arguments to prepend/append, and whether execution should change to the file's directory first.
type NoopExecutor ¶
type NoopExecutor struct{}
NoopExecutor is a test/dummy executor that writes fixed strings to stdout and stderr.
func (*NoopExecutor) Cleanup ¶
func (ne *NoopExecutor) Cleanup() error
Cleanup finalizes the NoopExecutor (no-op).
func (*NoopExecutor) Setup ¶
func (ne *NoopExecutor) Setup() error
Setup initializes the NoopExecutor (no-op).
type PodmanExecutor ¶
PodmanExecutor runs CLI tools inside a Podman container.
func (*PodmanExecutor) Cleanup ¶
func (e *PodmanExecutor) Cleanup() error
Cleanup stops and removes the temporary Podman container created during Setup.
func (*PodmanExecutor) Exec ¶
func (e *PodmanExecutor) Exec(i Instance, filePath string, stdout io.Writer, stderr io.Writer) error
Exec runs the configured command inside the prepared Podman container.
func (*PodmanExecutor) Setup ¶
func (e *PodmanExecutor) Setup() error
Setup creates and starts a disposable Podman container for executing commands.