imageref

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 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 with 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 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 PathMatch added in v0.13.0

func PathMatch(pattern, value string) bool

PathMatch reports whether value matches a path-aware glob pattern: '*' matches any run of characters within one '/'-separated segment, '**' matches any run including '/', and '?' matches exactly one character other than '/'. A "**/" that begins a segment also matches zero segments, so "ghcr.io/**/app" matches both ghcr.io/app and ghcr.io/a/b/app. No other metacharacters are supported.

It is the one glob dialect of every reference pattern list (images.exclude, images.verifyUpstream match, ociRefs.allow and the source policies), so a segment boundary always holds ("ghcr.io/acme/*" never reaches into ghcr.io/acme/team/app).

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