executor

package
v2.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 30 * time.Minute

DefaultTimeout is the default timeout for container execution (30 minutes)

Variables

View Source
var Version = "dev"

Version is the cidx build version stamped onto every created container as the `cidx.version` label. Set from cmd/cidx/main.go on startup so the executor package stays free of import cycles. Defaults to "dev".

Functions

func ContainerName added in v2.1.3

func ContainerName(workspace, tool string) string

ContainerName returns the Docker container name for a tool running in the given workspace: `cidx_<project>_<tool>`.

The result always satisfies Docker's container name grammar ([a-zA-Z0-9][a-zA-Z0-9_.-]*): the `cidx` prefix covers the first character, and every dynamic part is sanitized to [a-zA-Z0-9_.-].

func PodmanSocketHint

func PodmanSocketHint() string

PodmanSocketHint returns the platform-appropriate command that makes Podman's Docker-compatible API socket available.

func PodmanUsable

func PodmanUsable() bool

PodmanUsable reports whether cidx can actually drive Podman. The Podman CLI alone is not enough: cidx talks to Podman through its Docker-compatible API socket, so the socket must exist and respond.

func ProjectScope added in v2.1.3

func ProjectScope(workspace string) string

ProjectScope returns the per-project component of a container name: a sanitized, truncated workspace basename followed by a short hash of the absolute workspace path.

The hash is computed over the cleaned absolute path, so it is stable for a given directory across runs and differs for any two distinct directories — including two repositories that share a basename.

Types

type AuthError

type AuthError struct {
	Registry string
	Image    string
	Err      error
}

AuthError represents an authentication failure when pulling images

func (*AuthError) Error

func (e *AuthError) Error() string

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

type BackendType

type BackendType string

BackendType represents the executor backend type

const (
	BackendAuto       BackendType = "auto"
	BackendDocker     BackendType = "docker"
	BackendPodman     BackendType = "podman"
	BackendKubernetes BackendType = "kubernetes"
)

func ParseBackendType

func ParseBackendType(s string) BackendType

ParseBackendType converts a string to BackendType

func (BackendType) String

func (b BackendType) String() string

String returns the string representation of BackendType

type DockerExecutor

type DockerExecutor struct {
	// contains filtered or unexported fields
}

DockerExecutor executes tools using Docker

func NewDockerExecutor

func NewDockerExecutor(dryRun, verbose, quiet bool) (*DockerExecutor, error)

NewDockerExecutor creates a new Docker executor

func (*DockerExecutor) Available

func (e *DockerExecutor) Available() bool

Available checks if Docker daemon is running and accessible

func (*DockerExecutor) Close

func (e *DockerExecutor) Close() error

Close closes the Docker client

func (*DockerExecutor) Name

func (e *DockerExecutor) Name() string

Name returns the executor backend name

func (*DockerExecutor) Run

func (e *DockerExecutor) Run(ctx context.Context, containerConfig *config.ContainerConfig) error

Run executes a tool configuration

func (*DockerExecutor) SetTimeout

func (e *DockerExecutor) SetTimeout(d time.Duration)

SetTimeout sets the execution timeout for containers

type ExecutionContext

type ExecutionContext struct {
	DryRun    bool   // If true, show what would be executed without running
	Verbose   bool   // If true, show detailed output
	Workspace string // Project workspace path
}

ExecutionContext provides runtime context for executors

type Executor

type Executor interface {
	// Run executes a tool with the given configuration
	Run(ctx context.Context, config *config.ContainerConfig) error

	// Available checks if this executor backend is available
	// For Docker: checks if daemon is running
	// For Podman: checks if podman machine is running
	Available() bool

	// Name returns the executor backend name (docker, podman, kubernetes)
	Name() string

	// Close releases any resources held by the executor
	Close() error
}

Executor defines the interface for executing tools in containers Implementations include DockerExecutor, PodmanExecutor, KubernetesExecutor

type NameConflictError added in v2.1.3

type NameConflictError struct {
	Name string
	ID   string
}

NameConflictError reports that a container name cidx wants is held by a container cidx does not manage. Deleting it is the user's call, so cidx refuses rather than forcing a removal.

func (*NameConflictError) Error added in v2.1.3

func (e *NameConflictError) Error() string

type PodmanExecutor

type PodmanExecutor struct {
	// contains filtered or unexported fields
}

PodmanExecutor wraps DockerExecutor connected to Podman's Docker-compatible socket. Podman exposes a Docker-compatible API, so we reuse the Docker SDK.

func NewPodmanExecutor

func NewPodmanExecutor(dryRun, verbose, quiet bool) (*PodmanExecutor, error)

NewPodmanExecutor creates a Podman executor via Docker-compatible socket.

func (*PodmanExecutor) Available

func (e *PodmanExecutor) Available() bool

func (*PodmanExecutor) Close

func (e *PodmanExecutor) Close() error

func (*PodmanExecutor) Name

func (e *PodmanExecutor) Name() string

func (*PodmanExecutor) Run

type Selector

type Selector struct {
	// contains filtered or unexported fields
}

Selector manages executor selection based on availability and user preference

func NewSelector

func NewSelector(dryRun, verbose, quiet bool) (*Selector, error)

NewSelector creates a new executor selector

func (*Selector) Close

func (s *Selector) Close() error

Close releases resources held by all executors

func (*Selector) DockerAvailable

func (s *Selector) DockerAvailable() bool

DockerAvailable checks if Docker is available

func (*Selector) GetDocker

func (s *Selector) GetDocker() *DockerExecutor

GetDocker returns the Docker executor (may be nil)

func (*Selector) ListAvailableBackends

func (s *Selector) ListAvailableBackends() []BackendType

ListAvailableBackends returns which backends are currently available

func (*Selector) PodmanAvailable

func (s *Selector) PodmanAvailable() bool

PodmanAvailable checks if Podman is available

func (*Selector) Select

func (s *Selector) Select(toolName string, backend BackendType) (Executor, error)

Select chooses the appropriate executor for a tool based on backend preference

Jump to

Keyboard shortcuts

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