reference

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package reference parses OCI image references and resolves tags to digests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FamiliarString added in v0.4.0

func FamiliarString(s string) string

FamiliarString returns a reference in its short form: busybox:latest for docker.io/library/busybox:latest. An invalid reference is returned as is.

func ShortDigest added in v0.4.0

func ShortDigest(digest string) string

ShortDigest abbreviates a digest for a person, as git does a commit: "sha256:1a2b3c4d5e6f". A digest too short to abbreviate, or without an algorithm, is returned as is.

Types

type Ref

type Ref struct {
	// contains filtered or unexported fields
}

Ref is a parsed OCI image reference in its normalised form, such as docker.io/library/alpine:latest.

func Parse

func Parse(s string) (*Ref, error)

Parse validates and normalises an image reference: the registry and library path Docker assumes are filled in, and a reference with neither tag nor digest is tagged latest.

func (*Ref) Digest

func (r *Ref) Digest() string

Digest returns the digest the reference names, or "" if it names a tag.

func (*Ref) HasDigest

func (r *Ref) HasDigest() bool

HasDigest reports whether the reference names an immutable digest.

func (*Ref) Repository

func (r *Ref) Repository() string

Repository returns the reference without its tag or digest, such as docker.io/library/alpine.

func (*Ref) String

func (r *Ref) String() string

String returns the normalised reference.

type ResolvedRef

type ResolvedRef struct {
	// contains filtered or unexported fields
}

ResolvedRef is an image reference pinned to a manifest digest.

func Resolve

func Resolve(ctx context.Context, resolver Resolver, ref *Ref) (*ResolvedRef, error)

Resolve pins ref to a manifest digest: its own if it names one, otherwise the one resolver finds for its tag. resolver may be nil only for a reference by digest.

func (*ResolvedRef) Digest added in v0.4.0

func (r *ResolvedRef) Digest() string

Digest returns the manifest digest the reference was resolved to.

func (*ResolvedRef) DigestHex

func (r *ResolvedRef) DigestHex() string

DigestHex returns the digest without its algorithm prefix, suitable for use as a directory name.

func (*ResolvedRef) String added in v0.4.0

func (r *ResolvedRef) String() string

String returns the normalised reference, as it was before it was resolved.

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, ref *Ref) (string, error)
}

Resolver looks up the digest of the manifest a tagged reference names.

Jump to

Keyboard shortcuts

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