{"modulePath":"github.com/2lambda123/openshift-origin","version":"v4.1.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package reference\n\nreference is a copy from \"github.com/docker/distribution/reference\" that is kept because we want to avoid the godep, this package has no non-standard dependencies, and if it changes lots of other docker registry stuff breaks. Don't try this at home! Changes here require sign-off from openshift/api-reviewers and they will be rejected.\n\nPackage 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).\n\nGrammar\n\n\treference                       := name [ \":\" tag ] [ \"@\" digest ]\n\tname                            := [hostname '/'] component ['/' component]*\n\thostname                        := hostcomponent ['.' hostcomponent]* [':' port-number]\n\thostcomponent                   := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/\n\tport-number                     := /[0-9]+/\n\tcomponent                       := alpha-numeric [separator alpha-numeric]*\n\talpha-numeric                   := /[a-z0-9]+/\n\tseparator                       := /[_.]|__|[-]*/\n\n\ttag                             := /[\\w][\\w.-]{0,127}/\n\n\tdigest                          := digest-algorithm \":\" digest-hex\n\tdigest-algorithm                := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ]\n\tdigest-algorithm-separator      := /[+.-_]/\n\tdigest-algorithm-component      := /[A-Za-z][A-Za-z0-9]*/\n\tdigest-hex                      := /[0-9a-fA-F]{32,}/ ; At least 128 bit digest value\n\n## Constants\n\n```go\nconst (\n\t// NameTotalLengthMax is the maximum total number of characters in a repository name.\n\tNameTotalLengthMax = 255\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference.\n\tErrReferenceInvalidFormat = errors.New(\"invalid reference format\")\n\n\t// ErrTagInvalidFormat represents an error while trying to parse a string as a tag.\n\tErrTagInvalidFormat = errors.New(\"invalid tag format\")\n\n\t// ErrDigestInvalidFormat represents an error while trying to parse a string as a tag.\n\tErrDigestInvalidFormat = errors.New(\"invalid digest format\")\n\n\t// ErrNameContainsUppercase is returned for invalid repository names that contain uppercase characters.\n\tErrNameContainsUppercase = errors.New(\"repository name must be lowercase\")\n\n\t// ErrNameEmpty is returned for empty, invalid repository names.\n\tErrNameEmpty = errors.New(\"repository name must have at least one component\")\n\n\t// ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax.\n\tErrNameTooLong = fmt.Errorf(\"repository name must not be more than %v characters\", NameTotalLengthMax)\n)\n```\n\n```go\nvar (\n\n\t// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.\n\tTagRegexp = match(`[\\w][\\w.-]{0,127}`)\n\n\t// DigestRegexp matches valid digests.\n\tDigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`)\n\n\t// NameRegexp is the format for the name component of references. The\n\t// regexp has capturing groups for the hostname and name part omitting\n\t// the separating forward slash from either.\n\tNameRegexp = expression(\n\t\toptional(hostnameRegexp, literal(`/`)),\n\t\tnameComponentRegexp,\n\t\toptional(repeated(literal(`/`), nameComponentRegexp)))\n\n\t// ReferenceRegexp is the full supported format of a reference. The regexp\n\t// is anchored and has capturing groups for name, tag, and digest\n\t// components.\n\tReferenceRegexp = anchored(capture(NameRegexp),\n\t\toptional(literal(\":\"), capture(TagRegexp)),\n\t\toptional(literal(\"@\"), capture(DigestRegexp)))\n)\n```\n\n## Functions\n\n```go\nfunc Match(pattern string, ref Reference) (bool, error)\n```\nMatch reports whether ref matches the specified pattern. See [https://godoc.org/path#Match](https://godoc.org/path#Match) for supported patterns.\n\n```go\nfunc SplitHostname(named Named) (string, string)\n```\nSplitHostname 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\n\n## Types\n\n```go\ntype Canonical interface {\n\tNamed\n\tDigest() digest.Digest\n}\n```\nCanonical reference is an object with a fully unique name including a name with hostname and digest\n\n```go\nfunc WithDigest(name Named, digest digest.Digest) (Canonical, error)\n```\nWithDigest combines the name from \"name\" and the digest from \"digest\" to form a reference incorporating both the name and the digest.\n\n```go\ntype Digested interface {\n\tReference\n\tDigest() digest.Digest\n}\n```\nDigested is an object which has a digest in which it can be referenced by\n\n```go\ntype Field struct {\n\t// contains filtered or unexported fields\n}\n```\nField provides a wrapper type for resolving correct reference types when working with encoding.\n\n```go\nfunc AsField(reference Reference) Field\n```\nAsField wraps a reference in a Field for encoding.\n\n```go\nfunc (f Field) MarshalText() (p []byte, err error)\n```\nMarshalText serializes the field to byte text which is the string of the reference.\n\n```go\nfunc (f Field) Reference() Reference\n```\nReference 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.\n\n```go\nfunc (f *Field) UnmarshalText(p []byte) error\n```\nUnmarshalText parses text bytes by invoking the reference parser to ensure the appropriately typed reference object is wrapped by field.\n\n```go\ntype Named interface {\n\tReference\n\tName() string\n}\n```\nNamed is an object with a full name\n\n```go\nfunc ParseNamed(s string) (Named, error)\n```\nParseNamed 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.\n\n```go\nfunc TrimNamed(ref Named) Named\n```\nTrimNamed removes any tag or digest from the named reference.\n\n```go\nfunc WithName(name string) (Named, error)\n```\nWithName returns a named object representing the given string. If the input is invalid ErrReferenceInvalidFormat will be returned.\n\n```go\ntype NamedTagged interface {\n\tNamed\n\tTag() string\n}\n```\nNamedTagged is an object including a name and tag.\n\n```go\nfunc WithTag(name Named, tag string) (NamedTagged, error)\n```\nWithTag combines the name from \"name\" and the tag from \"tag\" to form a reference incorporating both the name and the tag.\n\n```go\ntype Reference interface {\n\t// String returns the full reference\n\tString() string\n}\n```\nReference is an opaque object reference identifier that may include modifiers such as a hostname, name, tag, and digest.\n\n```go\nfunc Parse(s string) (Reference, error)\n```\nParse parses s and returns a syntactically valid Reference. If an error was encountered it is returned, along with a nil Reference. NOTE: Parse will not handle short digests.\n\n```go\ntype Tagged interface {\n\tReference\n\tTag() string\n}\n```\nTagged is an object which has a tag\n\n","path":"github.com/2lambda123/openshift-origin/pkg/image/internal/reference","name":"reference","synopsis":"reference is a copy from \"github.com/docker/distribution/reference\" that is kept because we want to avoid the godep, this package has no non-standard dependencies, and if it changes lots of other docker registry stuff breaks.","isRedistributable":true}
