Documentation
¶
Index ¶
- Constants
- Variables
- func ContainerName(workspace, tool string) string
- func PodmanSocketHint() string
- func PodmanUsable() bool
- func ProjectScope(workspace string) string
- type AuthError
- type BackendType
- type DockerExecutor
- type ExecutionContext
- type Executor
- type NameConflictError
- type PodmanExecutor
- type Selector
- func (s *Selector) Close() error
- func (s *Selector) DockerAvailable() bool
- func (s *Selector) GetDocker() *DockerExecutor
- func (s *Selector) ListAvailableBackends() []BackendType
- func (s *Selector) PodmanAvailable() bool
- func (s *Selector) Select(toolName string, backend BackendType) (Executor, error)
Constants ¶
const DefaultTimeout = 30 * time.Minute
DefaultTimeout is the default timeout for container execution (30 minutes)
Variables ¶
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
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
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 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
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 ¶
func (e *PodmanExecutor) Run(ctx context.Context, cfg *config.ContainerConfig) error
type Selector ¶
type Selector struct {
// contains filtered or unexported fields
}
Selector manages executor selection based on availability and user preference
func NewSelector ¶
NewSelector creates a new executor selector
func (*Selector) DockerAvailable ¶
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 ¶
PodmanAvailable checks if Podman is available