imageref

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package imageref manipulates container image references as strings: it expands docker shorthand the way container runtimes do, splits a reference into repository, tag and digest (tolerating registry ports and pinned digests), applies source-registry rewrites, and matches shell-style glob patterns against references.

Everything here is pure string manipulation — no registry access. The mirror engine records canonical (normalized, un-rewritten) references in its lock files; rewrites only ever affect where a pull is made from.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GlobMatch

func GlobMatch(pattern, value string) bool

GlobMatch reports whether value matches a shell-style glob pattern as a bash case statement would: '*' matches any run of characters including '/', '?' matches exactly one. No other metacharacters are supported.

func Normalize

func Normalize(ref string) string

Normalize expands shorthand image references the way container runtimes do: a bare name gains docker.io/library/, a path without a registry host gains docker.io/, and a single-segment docker.io path gains library/.

func Rewrite

func Rewrite(ref string, rewrites map[string]string) string

Rewrite routes a pull through a per-host rewrite (e.g. a pull-through cache in front of docker.io) when one is configured for the reference's registry host. References whose host has no rewrite pass through unchanged; recorded sources and publish targets always keep the canonical name.

Types

type Ref

type Ref struct {
	// Repository is the registry host plus path, e.g. "ghcr.io/acme/app".
	Repository string
	// Tag is the tag portion, "latest" when the reference carries none.
	Tag string
	// Digest is the "sha256:..." pin when present, empty otherwise.
	Digest string
}

Ref is a container image reference split into its addressable parts. Repository always carries an explicit registry host (Normalize first when the input may be shorthand).

func Parse

func Parse(ref string) (Ref, error)

Parse splits a reference into repository, tag and digest. It tolerates pinned digests (repo:tag@sha256:... and repo@sha256:...) and registry ports (localhost:5000/app:v1). A reference with no tag parses with Tag "latest", matching runtime behaviour.

func (Ref) String

func (r Ref) String() string

String reassembles the reference: repository, ":tag" when set, "@digest" when set.

Jump to

Keyboard shortcuts

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