registry

package
v1.22.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package registry queries OCI registries for available tags so lerd can surface "update available" badges and apply minor/patch updates to default services.

Two backends are supported: Docker Hub (`docker.io/...`) and GHCR (`ghcr.io/...`). Other registries are reported as unsupported; the caller treats that as "no update info" rather than an error to surface to the user.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthRequiredErr

type AuthRequiredErr struct{ Registry string }

AuthRequiredErr is returned when the registry needs credentials we don't have. Treated as "no update info" by NewestStable / MaybeNewerTag, but distinguishable so future code can surface a "click to authenticate" hint.

func (*AuthRequiredErr) Error

func (e *AuthRequiredErr) Error() string

type ImageRef

type ImageRef struct {
	Registry string
	Repo     string
	Tag      string
}

ImageRef is the parsed form of an OCI image reference.

func ParseImage

func ParseImage(image string) (ImageRef, error)

ParseImage splits an image reference into registry, repo and tag. Implicit "docker.io" prefix is supplied for short forms ("redis", "library/mysql:5.7"). Implicit "library/" namespace is added for one-segment Docker Hub repos. Implicit ":latest" tag is added when omitted.

func (ImageRef) String

func (r ImageRef) String() string

String formats the ImageRef back to a registry-qualified image reference.

type NotFoundErr

type NotFoundErr struct{ Repo string }

NotFoundErr signals the repo doesn't exist (404). Distinguished from transient unreachability so the UI can show a typo hint instead of silently hiding the error.

func (*NotFoundErr) Error

func (e *NotFoundErr) Error() string

type Strategy

type Strategy string

Strategy controls which tags MaybeNewerTag will consider as a recommended upgrade for the current image. Stays as a string so it serialises cleanly from preset YAML's update_strategy field.

const (
	// StrategyRolling re-pulls the current tag (e.g. :latest) and recommends
	// it whenever the remote digest differs from the local one.
	StrategyRolling Strategy = "rolling"
	// StrategyPatch accepts only newer patch releases sharing the same major
	// AND minor numeric segments (e.g. 8.0.34 → 8.0.35, never 8.1.0).
	StrategyPatch Strategy = "patch"
	// StrategyMinor accepts newer tags within the same major segment with the
	// same trailing variant suffix (e.g. 16-3.5-alpine → 16.4-3.5-alpine).
	StrategyMinor Strategy = "minor"
	// StrategyNone disables update suggestions entirely.
	StrategyNone Strategy = "none"
)

type TagInfo

type TagInfo struct {
	Name   string    `json:"name"`
	Pushed time.Time `json:"pushed,omitempty"`
	Digest string    `json:"digest,omitempty"`
}

TagInfo is one tag returned by a registry's list-tags endpoint.

func ListTags

func ListTags(image string) ([]TagInfo, error)

ListTags fetches available tags for the named image, choosing the backend by registry hostname. Errors classify as Auth/NotFound/Unreachable/ Unsupported so callers can decide whether to surface or swallow.

func MaybeNewerTag

func MaybeNewerTag(image string, strategy Strategy) (*TagInfo, error)

MaybeNewerTag is the high-level entry point. Looks at the image's tag, queries the registry, applies the strategy, and returns either a newer tag to recommend or nil. Quiet errors collapse to (nil, nil).

func NewestStable

func NewestStable(image string, allowMajorUpgrade bool) (*TagInfo, error)

NewestStable returns the newest version-shaped tag in the registry, ignoring update_strategy. Same variant suffix is required. When allowMajorUpgrade is false the search stays within the current numeric major; when true any newer version qualifies.

type UnreachableErr

type UnreachableErr struct{ Cause error }

UnreachableErr signals a transient registry failure (DNS / timeout / 5xx / rate limit). The caller should treat it as "no update info" rather than surfacing a scary error.

func (*UnreachableErr) Error

func (e *UnreachableErr) Error() string

func (*UnreachableErr) Unwrap

func (e *UnreachableErr) Unwrap() error

type UnsupportedRegistryErr

type UnsupportedRegistryErr struct{ Registry string }

UnsupportedRegistryErr is returned when the registry hostname is not one of the recognised backends.

func (*UnsupportedRegistryErr) Error

func (e *UnsupportedRegistryErr) Error() string

Jump to

Keyboard shortcuts

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