Documentation
¶
Overview ¶
Package version_resolver maps a runtime name and user-supplied version string to a Docker image reference.
Version inputs are intentionally loose — a major ("3"), a minor ("3.12"), or a full patch pin ("3.12.7") are all valid. Missing precision is filled in by querying endoflife.date, which picks the latest non-EOL release that matches the prefix.
Responses are cached per product for 24 hours. A failed refresh serves the previous data so a transient outage to endoflife.date does not block builds.
Runtimes with multi-stage Dockerfiles (nodejs, java) expose separate builder and runner images through Resolution. Single-stage runtimes return the same image for both.
Two inputs are always rejected: strings that do not parse as a version prefix (letters, extra dots, wildcards), and versions whose end-of-life date has already passed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cycle ¶
type Cycle struct {
Cycle string `json:"cycle"`
Latest string `json:"latest"`
EOL EOLDate `json:"eol"`
ReleaseDate string `json:"releaseDate"`
LTS bool `json:"lts"`
}
Cycle is a single release line as returned by endoflife.date.
type EOLClient ¶
EOLClient fetches release cycle data for a given product. The product name matches endoflife.date's URL slug (e.g. "python", "nodejs").
func NewHTTPClient ¶
func NewHTTPClient() EOLClient
NewHTTPClient returns an EOLClient backed by endoflife.date with a 24-hour cache.
type EOLDate ¶
type EOLDate struct {
// contains filtered or unexported fields
}
EOLDate is either "no end-of-life" (the zero value) or a calendar date. The endoflife.date API encodes this as either the boolean false or a "YYYY-MM-DD" string, so a custom unmarshaler is required.
func NewEOLDate ¶
NewEOLDate constructs an EOLDate from a "YYYY-MM-DD" string. Pass "" to represent a release with no scheduled end-of-life.
func (*EOLDate) UnmarshalJSON ¶
type Resolution ¶
type Resolution struct {
// BuilderImage is the primary FROM image (used for single-stage builds and
// the first stage of multi-stage builds).
BuilderImage string
// RunnerImage is the lightweight runtime image used in the final stage of
// multi-stage builds. It equals BuilderImage for single-stage runtimes.
RunnerImage string
// Version is the resolved version tag (e.g. "3.12", "21") without the
// image name, useful when constructing secondary images inside a Dockerfile.
Version string
}
Resolution holds the images produced for a single resolve call.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves user-supplied runtime versions to concrete Docker image references using live release-cycle data from endoflife.date.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(runtime, version string) (Resolution, error)
Resolve returns the Docker images for the given runtime and version string.
An empty version picks the latest stable release. A partial version (major or major.minor) is resolved to the most recent non-EOL cycle in that line. A full patch version is validated against the known cycle data and passed through, subject to the runtime's maximum tag granularity.