Documentation ¶
Overview ¶
Package reference provides a general type to represent any way of referencing images within the registry. Its main purpose is to abstract tags and digests (content-addressable hash).
Grammar
reference := repository [ ":" tag ] [ "@" digest ] // repository.go repository := hostname ['/' component]+ hostname := hostcomponent [':' port-number] component := subcomponent [separator subcomponent]* subcomponent := alpha-numeric ['-'* alpha-numeric]* hostcomponent := [hostpart '.']* hostpart alpha-numeric := /[a-z0-9]+/ separator := /([_.]|__)/ port-number := /[0-9]+/ hostpart := /([a-z0-9]|[a-z0-9][a-z0-9-]*[a-z0-9])/ // tag.go tag := /[\w][\w.-]{0,127}/ // from the digest package digest := digest-algorithm ":" digest-hex digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ] digest-algorithm-separator := /[+.-_]/ digest-algorithm-component := /[A-Za-z][A-Za-z0-9]*/ digest-hex := /[0-9a-fA-F]{32,}/ ; Atleast 128 bit digest value
Index ¶
Constants ¶
const (
// NameTotalLengthMax is the maximum total number of characters in a repository name.
NameTotalLengthMax = 255
)
Variables ¶
var ( // ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference. ErrReferenceInvalidFormat = errors.New("invalid reference format") // ErrTagInvalidFormat represents an error while trying to parse a string as a tag. ErrTagInvalidFormat = errors.New("invalid tag format") // ErrDigestInvalidFormat represents an error while trying to parse a string as a tag. ErrDigestInvalidFormat = errors.New("invalid digest format") // ErrNameEmpty is returned for empty, invalid repository names. ErrNameEmpty = errors.New("repository name must have at least one component") // ErrNameTooLong is returned when a repository name is longer than // RepositoryNameTotalLengthMax ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", NameTotalLengthMax) )
var ( // TagRegexp matches valid tag names. From docker/docker:graph/tags.go. TagRegexp = regexp.MustCompile(`[\w][\w.-]{0,127}`) // DigestRegexp matches valid digests. DigestRegexp = regexp.MustCompile(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`) // NameRegexp is the format for the name component of references. The // regexp has capturing groups for the hostname and name part omitting // the seperating forward slash from either. NameRegexp = regexp.MustCompile(`(?:` + hostnameRegexp.String() + `/)?` + nameRegexp.String()) // ReferenceRegexp is the full supported format of a reference. The // regexp has capturing groups for name, tag, and digest components. ReferenceRegexp = regexp.MustCompile(`^((?:` + hostnameRegexp.String() + `/)?` + nameRegexp.String() + `)(?:[:](` + TagRegexp.String() + `))?(?:[@](` + DigestRegexp.String() + `))?$`) )
Functions ¶
func SplitHostname ¶
SplitHostname splits a named reference into a hostname and name string. If no valid hostname is found, the hostname is empty and the full value is returned as name
Types ¶
type Canonical ¶
Canonical reference is an object with a fully unique name including a name with hostname and digest
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field provides a wrapper type for resolving correct reference types when working with encoding.
func (Field) MarshalText ¶
MarshalText serializes the field to byte text which is the string of the reference.
func (Field) Reference ¶
Reference unwraps the reference type from the field to return the Reference object. This object should be of the appropriate type to further check for different reference types.
func (*Field) UnmarshalText ¶
UnmarshalText parses text bytes by invoking the reference parser to ensure the appropriately typed reference object is wrapped by field.
type Named ¶
Named is an object with a full name
func ParseNamed ¶
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. NOTE: ParseNamed will not handle short digests.
type NamedTagged ¶
NamedTagged is an object including a name and tag.