executor

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 37 Imported by: 0

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

func GetWorkdirAsLinuxPath() (string, error)

GetWorkdirAsLinuxPath is useful for consistently mapping any host fs to what is typically in container environments (Linux)

func ToLinuxPath

func ToLinuxPath(p string) string

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 WillHost

func WillHost(bin string) error

WillHost checks whether the given binary can be found on the host PATH.

func WillPodman

func WillPodman(ctx context.Context) error

WillPodman checks whether Podman is available and responsive on the host.

Types

type Executor

type Executor interface {
	Setup(ctx context.Context, i Instance) error
	Exec(filepath string, stdout io.Writer, stderr io.Writer) error
	Cleanup(ctx context.Context) 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.

func NewDocker

func NewDocker(image string) Executor

NewDocker creates an executor using containers managed by the docker client.

func NewHost

func NewHost() Executor

NewHost creates an executor that uses direct exec calls

func NewNoop

func NewNoop() Executor

NewNoop creates an executor that does nothing

func NewPodman

func NewPodman(image string) Executor

NewPodman creates an executor using containers managed by the podman client.

type Instance

type Instance struct {
	Bin       string `json:"bin" yaml:"bin" jsonschema:"the binary or command to use"`
	Start     Par    `json:"start,flow,omitzero" yaml:"start,flow" jsonschema:"parameters that will be put in front of the file path"`
	End       Par    `json:"end,flow,omitzero" yaml:"end,flow" jsonschema:"parameters that will be put behind the file path"`
	ChDir     bool   `json:"chdir,omitzero" yaml:"chdir" jsonschema:"if true the tool will change directory to where the target file is located"`
	WillWrite bool   `` /* 175-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 Par

type Par []string

Par represents command-line parameters passed to a linter executable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL