image

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

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

View Source
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

func NormalizeVersionRange(versionRange string, ltsVersion string) string

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

func NewDetector(workspace string) *Detector

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

type Version struct {
	Major    int
	Minor    int
	Patch    int
	Original string
}

Version represents a parsed language version with major, minor, and patch components.

func ParseVersion

func ParseVersion(version string) (*Version, error)

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

func (v *Version) Compare(other *Version) int

Compare compares two versions. Returns: -1 if v < other, 0 if v == other, 1 if v > other

func (*Version) ImageString

func (v *Version) ImageString(useMajorOnly bool) string

ImageString returns the version formatted for Docker image tags. For most languages, this is "major.minor", but some languages use just major (Node.js).

func (*Version) IsZero

func (v *Version) IsZero() bool

IsZero returns true if the version is all zeros.

func (*Version) String

func (v *Version) String() string

String returns the version in "major.minor" format (patch is omitted for Docker images).

Jump to

Keyboard shortcuts

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