reference

package
v1.4.2-0...-6138a02 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTag defines the default tag used when performing images related actions and no tag or digest is specified
	DefaultTag = "latest"
	// DefaultHostname is the default built-in hostname
	DefaultHostname = "docker.io"
	// LegacyDefaultHostname is automatically converted to DefaultHostname
	LegacyDefaultHostname = "index.docker.io"
	// DefaultRepoPrefix is the prefix used for default repositories in default host
	DefaultRepoPrefix = "library/"
)

Variables

View Source
var (
	// ErrDoesNotExist is returned if a reference is not found in the
	// store.
	ErrDoesNotExist = errors.New("reference does not exist")
)

Functions

func IsNameOnly

func IsNameOnly(ref Named) bool

IsNameOnly returns true if reference only contains a repo name.

Types

type Association

type Association struct {
	Ref Named
	ID  digest.Digest
}

An Association is a tuple associating a reference with an image ID.

type Canonical

type Canonical interface {
	Named
	Digest() digest.Digest
}

Canonical reference is an object with a fully unique name including a name with hostname and digest

func WithDigest

func WithDigest(name Named, digest digest.Digest) (Canonical, error)

WithDigest combines the name from "name" and the digest from "digest" to form a reference incorporating both the name and the digest.

type Named

type Named interface {
	// Name returns normalized repository name, like "ubuntu".
	Name() string
	// String returns full reference, like "ubuntu@sha256:abcdef..."
	String() string
	// FullName returns full repository name with hostname, like "docker.io/library/ubuntu"
	FullName() string
	// Hostname returns hostname for the reference, like "docker.io"
	Hostname() string
	// RemoteName returns the repository component of the full name, like "library/ubuntu"
	RemoteName() string
}

Named is an object with a full name

func ParseIDOrReference

func ParseIDOrReference(idOrRef string) (digest.Digest, Named, error)

ParseIDOrReference parses string for an image ID or a reference. ID can be without a default prefix.

func ParseNamed

func ParseNamed(s string) (Named, error)

ParseNamed parses s and returns a syntactically valid reference implementing the Named interface. The reference must have a name, otherwise an error is returned. If an error was encountered it is returned, along with a nil Reference.

func TrimNamed

func TrimNamed(ref Named) Named

TrimNamed removes any tag or digest from the named reference

func WithDefaultTag

func WithDefaultTag(ref Named) Named

WithDefaultTag adds a default tag to a reference if it only has a repo name.

func WithName

func WithName(name string) (Named, error)

WithName returns a named object representing the given string. If the input is invalid ErrReferenceInvalidFormat will be returned.

type NamedTagged

type NamedTagged interface {
	Named
	Tag() string
}

NamedTagged is an object including a name and tag.

func WithTag

func WithTag(name Named, tag string) (NamedTagged, error)

WithTag combines the name from "name" and the tag from "tag" to form a reference incorporating both the name and the tag.

type Store

type Store interface {
	References(id digest.Digest) []Named
	ReferencesByName(ref Named) []Association
	AddTag(ref Named, id digest.Digest, force bool) error
	AddDigest(ref Canonical, id digest.Digest, force bool) error
	Delete(ref Named) (bool, error)
	Get(ref Named) (digest.Digest, error)
}

Store provides the set of methods which can operate on a tag store.

func NewReferenceStore

func NewReferenceStore(jsonPath string) (Store, error)

NewReferenceStore creates a new reference store, tied to a file path where the set of references are serialized in JSON format.

Jump to

Keyboard shortcuts

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