imageref

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 5 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 reads image references as written, ${VAR:-default} templates included. The full parse (registry, tag, digest, pinning) is the artifact reference; this holds only what links need. See https://cernly.dev/how/facts/.

Index

Constants

View Source
const (
	PinDigest   = "digest"   // @sha256:...
	PinExact    = "exact"    // a full version: x.y.z or a release date, variant suffix allowed
	PinFloating = "floating" // latest, no tag, a major or major.minor, a branch or word tag
	PinUnknown  = "unknown"  // the tag comes from a variable without a default
)

Pinning grades.

Variables

This section is empty.

Functions

func Datastore

func Datastore(image string) (engine string, v version.Version, ok bool)

Datastore classifies an image reference such as "docker.io/library/postgres:16-alpine@sha256:..." as postgres, version 16. The version comes from the tag through the version scheme parser, so RELEASE.<date> tags keep a date.

func Name

func Name(ref string) string

Name returns an image reference without its tag or digest, as written: "ghcr.io/acme/api:${TAG}" -> "ghcr.io/acme/api". A ":" before the last "/" (a registry port) and separators inside ${...} are kept.

func Repo

func Repo(ref string) string

Repo returns the last path segment of an image reference without tag or digest: "${REGISTRY:-localhost:5000}/acme/api:${TAG:-latest}" -> "api". Separators inside ${...} do not count.

Types

type Ref

type Ref struct {
	Raw        string
	Registry   string
	Repository string
	Tag        string
	Digest     string
	Templated  []string // variable names in Raw
	Pinning    string
}

Ref is the artifact_ref of scan.v1.schema.json for an image.

func Parse

func Parse(raw string) Ref

Parse reads an image reference as written. ${VAR:-default} templates show their default, nested ones too; a variable without a default stays as ${VAR} and makes what it covers unknown. Docker Hub names are normalised: postgres -> docker.io/library/postgres.

func (Ref) Attrs

func (r Ref) Attrs() map[string]any

Attrs returns the ref as fact attrs.

Jump to

Keyboard shortcuts

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