reference

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package reference provides image reference parsing using the distribution/reference library. This replaces go-containerregistry's name package.

Index

Constants

View Source
const (
	// DefaultRegistry is the default registry (Docker Hub).
	DefaultRegistry = "index.docker.io"
	// DefaultTag is the default tag when none is specified.
	DefaultTag = "latest"
)
View Source
const DefaultOrg = "ai"

DefaultOrg is the default organization when none is specified.

Variables

This section is empty.

Functions

This section is empty.

Types

type Digest

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

Digest represents a digest-referenced image.

func (*Digest) Context

func (d *Digest) Context() Repository

Context returns the repository context.

func (*Digest) DigestStr

func (d *Digest) DigestStr() string

DigestStr returns just the digest string.

func (*Digest) Identifier

func (d *Digest) Identifier() string

Identifier returns the digest.

func (*Digest) Name

func (d *Digest) Name() string

Name returns the full reference name.

func (*Digest) Scope

func (d *Digest) Scope(action string) string

Scope returns the scope for registry authentication.

func (*Digest) String

func (d *Digest) String() string

String returns the full reference string including digest.

type Option

type Option func(*options)

Option is a functional option for reference parsing.

var Insecure Option = func(o *options) {
	o.insecure = true
}

Insecure allows insecure (HTTP) connections.

func WithDefaultOrg

func WithDefaultOrg(org string) Option

WithDefaultOrg sets a custom default organization. This is used when a reference doesn't include an organization (e.g., "model:tag").

func WithDefaultRegistry

func WithDefaultRegistry(registry string) Option

WithDefaultRegistry sets a custom default registry.

type Reference

type Reference interface {
	// Name returns the full name of the reference (registry/repo).
	Name() string
	// String returns the full reference string.
	String() string
	// Context returns the repository context.
	Context() Repository
	// Identifier returns the tag or digest identifier.
	Identifier() string
	// Scope returns the scope for registry authentication.
	Scope(action string) string
}

Reference represents an image reference.

func ParseReference

func ParseReference(s string, opts ...Option) (Reference, error)

ParseReference parses a string into a Reference.

type Registry

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

Registry represents a registry.

func (Registry) Name

func (r Registry) Name() string

Name returns the registry name.

func (Registry) RegistryStr

func (r Registry) RegistryStr() string

RegistryStr returns the registry string.

func (Registry) Scheme

func (r Registry) Scheme() string

Scheme returns the URL scheme (http or https).

type Repository

type Repository struct {
	Registry   Registry
	Repository string
}

Repository represents a repository context.

func (Repository) Name

func (r Repository) Name() string

Name returns the full repository name including registry.

func (Repository) RepositoryStr

func (r Repository) RepositoryStr() string

RepositoryStr returns just the repository part.

type Tag

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

Tag represents a tagged image reference.

func NewTag

func NewTag(s string, opts ...Option) (*Tag, error)

NewTag creates a new tag reference.

func (*Tag) Context

func (t *Tag) Context() Repository

Context returns the repository context.

func (*Tag) Identifier

func (t *Tag) Identifier() string

Identifier returns the tag.

func (*Tag) Name

func (t *Tag) Name() string

Name returns the full reference name.

func (*Tag) Scope

func (t *Tag) Scope(action string) string

Scope returns the scope for registry authentication.

func (*Tag) String

func (t *Tag) String() string

String returns the full reference string including tag.

func (*Tag) TagStr

func (t *Tag) TagStr() string

TagStr returns just the tag string.

Jump to

Keyboard shortcuts

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