Documentation
¶
Overview ¶
Package image provides auto-detection of Docker base images based on workspace language/framework signals.
Package image provides version parsing and normalization for language version detection.
Index ¶
Constants ¶
const DefaultImage = "golang:1.22"
DefaultImage is the fallback Docker image used when no language signal is detected.
Variables ¶
This section is empty.
Functions ¶
func FormatResult ¶
func FormatResult(result *DetectResult) string
FormatResult formats a DetectResult as a human-readable string.
func NormalizeVersionRange ¶
NormalizeVersionRange attempts to normalize a version range to a specific version. For broad ranges (e.g., "^1.0.0", ">=2"), it returns a suggested LTS version. Returns empty string if the range is too broad and a default should be used.
Types ¶
type DetectResult ¶
type DetectResult struct {
Image string // Detected Docker image (e.g., image.DefaultImage)
Signals []string // List of signals that contributed to this detection
Rationale string // Human-readable explanation of the detection
Disabled bool // True if auto-detection is disabled
}
DetectResult contains the detected image and detection rationale.
func Detect ¶
func Detect(workspace string) *DetectResult
Detect is a convenience function that detects the image for a workspace.
type Detector ¶
type Detector struct {
// contains filtered or unexported fields
}
Detector detects the appropriate Docker base image for a workspace.
func NewDetector ¶
NewDetector creates a new Detector for the given workspace path.
func (*Detector) Detect ¶
func (d *Detector) Detect() *DetectResult
Detect analyzes the workspace to determine an appropriate base image. If no strong signal is detected, returns a safe default. Attempts to detect language versions from project files.
type Version ¶
Version represents a parsed language version with major, minor, and patch components.
func ParseVersion ¶
ParseVersion parses a version string and returns a Version struct. Supports various version formats: - "1.22" -> {Major: 1, Minor: 22, Patch: 0} - "1.22.0" -> {Major: 1, Minor: 22, Patch: 0} - "22" -> {Major: 22, Minor: 0, Patch: 0}
func (*Version) Compare ¶
Compare compares two versions. Returns: -1 if v < other, 0 if v == other, 1 if v > other
func (*Version) ImageString ¶
ImageString returns the version formatted for Docker image tags. For most languages, this is "major.minor", but some languages use just major (Node.js).