2015-07-10 18:36:04 +00:00
|
|
|
// 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
|
|
|
|
//
|
2016-02-11 18:26:05 +00:00
|
|
|
// reference := name [ ":" tag ] [ "@" digest ]
|
2016-06-09 18:32:23 +00:00
|
|
|
// name := [domain '/'] path-component ['/' path-component]*
|
|
|
|
// domain := domain-component ['.' domain-component]* [':' port-number]
|
|
|
|
// domain-component := /([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])/
|
2015-12-04 22:40:09 +00:00
|
|
|
// port-number := /[0-9]+/
|
2016-06-09 18:32:23 +00:00
|
|
|
// path-component := alpha-numeric [separator alpha-numeric]*
|
2015-12-04 22:40:09 +00:00
|
|
|
// alpha-numeric := /[a-z0-9]+/
|
|
|
|
// separator := /[_.]|__|[-]*/
|
2015-07-10 18:36:04 +00:00
|
|
|
//
|
|
|
|
// tag := /[\w][\w.-]{0,127}/
|
|
|
|
//
|
|
|
|
// digest := digest-algorithm ":" digest-hex
|
|
|
|
// digest-algorithm := digest-algorithm-component [ digest-algorithm-separator digest-algorithm-component ]
|
|
|
|
// digest-algorithm-separator := /[+.-_]/
|
2015-09-08 23:00:48 +00:00
|
|
|
// digest-algorithm-component := /[A-Za-z][A-Za-z0-9]*/
|
2015-12-02 23:57:47 +00:00
|
|
|
// digest-hex := /[0-9a-fA-F]{32,}/ ; At least 128 bit digest value
|
2016-06-15 21:04:21 +00:00
|
|
|
//
|
|
|
|
// identifier := /[a-f0-9]{64}/
|
|
|
|
// short-identifier := /[a-f0-9]{6,64}/
|
2015-07-10 18:36:04 +00:00
|
|
|
package reference
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2015-09-08 23:00:48 +00:00
|
|
|
"fmt"
|
2016-11-09 21:04:52 +00:00
|
|
|
"path"
|
2016-08-11 13:30:17 +00:00
|
|
|
"strings"
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2016-12-17 00:28:34 +00:00
|
|
|
"github.com/opencontainers/go-digest"
|
2015-07-10 18:36:04 +00:00
|
|
|
)
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
const (
|
|
|
|
// NameTotalLengthMax is the maximum total number of characters in a repository name.
|
|
|
|
NameTotalLengthMax = 255
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference.
|
|
|
|
ErrReferenceInvalidFormat = errors.New("invalid reference format")
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-10-10 00:09:54 +00:00
|
|
|
// 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")
|
|
|
|
|
2016-08-11 13:30:17 +00:00
|
|
|
// ErrNameContainsUppercase is returned for invalid repository names that contain uppercase characters.
|
|
|
|
ErrNameContainsUppercase = errors.New("repository name must be lowercase")
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
// ErrNameEmpty is returned for empty, invalid repository names.
|
|
|
|
ErrNameEmpty = errors.New("repository name must have at least one component")
|
|
|
|
|
2015-12-22 11:22:31 +00:00
|
|
|
// ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax.
|
2015-09-08 23:00:48 +00:00
|
|
|
ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", NameTotalLengthMax)
|
|
|
|
)
|
|
|
|
|
|
|
|
// Reference is an opaque object reference identifier that may include
|
|
|
|
// modifiers such as a hostname, name, tag, and digest.
|
2015-07-10 18:36:04 +00:00
|
|
|
type Reference interface {
|
2015-09-08 23:00:48 +00:00
|
|
|
// String returns the full reference
|
2015-07-10 18:36:04 +00:00
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
2015-09-30 22:36:19 +00:00
|
|
|
// Field provides a wrapper type for resolving correct reference types when
|
|
|
|
// working with encoding.
|
|
|
|
type Field struct {
|
|
|
|
reference Reference
|
|
|
|
}
|
|
|
|
|
|
|
|
// AsField wraps a reference in a Field for encoding.
|
|
|
|
func AsField(reference Reference) Field {
|
|
|
|
return 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 (f Field) Reference() Reference {
|
|
|
|
return f.reference
|
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalText serializes the field to byte text which
|
|
|
|
// is the string of the reference.
|
|
|
|
func (f Field) MarshalText() (p []byte, err error) {
|
|
|
|
return []byte(f.reference.String()), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalText parses text bytes by invoking the
|
|
|
|
// reference parser to ensure the appropriately
|
|
|
|
// typed reference object is wrapped by field.
|
|
|
|
func (f *Field) UnmarshalText(p []byte) error {
|
|
|
|
r, err := Parse(string(p))
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
f.reference = r
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
// Named is an object with a full name
|
|
|
|
type Named interface {
|
2015-10-09 23:01:31 +00:00
|
|
|
Reference
|
2015-09-08 23:00:48 +00:00
|
|
|
Name() string
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
// Tagged is an object which has a tag
|
|
|
|
type Tagged interface {
|
2015-10-09 23:01:31 +00:00
|
|
|
Reference
|
2015-09-08 23:00:48 +00:00
|
|
|
Tag() string
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-10-13 22:42:04 +00:00
|
|
|
// NamedTagged is an object including a name and tag.
|
|
|
|
type NamedTagged interface {
|
|
|
|
Named
|
|
|
|
Tag() string
|
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
// Digested is an object which has a digest
|
|
|
|
// in which it can be referenced by
|
|
|
|
type Digested interface {
|
2015-10-09 23:01:31 +00:00
|
|
|
Reference
|
2015-09-08 23:00:48 +00:00
|
|
|
Digest() digest.Digest
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
// Canonical reference is an object with a fully unique
|
2016-06-09 18:32:23 +00:00
|
|
|
// name including a name with domain and digest
|
2015-09-08 23:00:48 +00:00
|
|
|
type Canonical interface {
|
|
|
|
Named
|
2015-10-09 23:01:31 +00:00
|
|
|
Digest() digest.Digest
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
|
|
|
|
2017-01-09 23:44:59 +00:00
|
|
|
// namedRepository is a reference to a repository with a name.
|
|
|
|
// A namedRepository has both domain and path components.
|
|
|
|
type namedRepository interface {
|
2016-06-09 18:32:23 +00:00
|
|
|
Named
|
|
|
|
Domain() string
|
|
|
|
Path() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// Domain returns the domain part of the Named reference
|
|
|
|
func Domain(named Named) string {
|
2017-01-09 23:44:59 +00:00
|
|
|
if r, ok := named.(namedRepository); ok {
|
2016-06-09 18:32:23 +00:00
|
|
|
return r.Domain()
|
|
|
|
}
|
|
|
|
domain, _ := splitDomain(named.Name())
|
|
|
|
return domain
|
|
|
|
}
|
|
|
|
|
|
|
|
// Path returns the name without the domain part of the Named reference
|
|
|
|
func Path(named Named) (name string) {
|
2017-01-09 23:44:59 +00:00
|
|
|
if r, ok := named.(namedRepository); ok {
|
2016-06-09 18:32:23 +00:00
|
|
|
return r.Path()
|
|
|
|
}
|
|
|
|
_, path := splitDomain(named.Name())
|
|
|
|
return path
|
|
|
|
}
|
|
|
|
|
|
|
|
func splitDomain(name string) (string, string) {
|
|
|
|
match := anchoredNameRegexp.FindStringSubmatch(name)
|
|
|
|
if len(match) != 3 {
|
|
|
|
return "", name
|
|
|
|
}
|
|
|
|
return match[1], match[2]
|
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
// 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
|
2016-06-09 18:32:23 +00:00
|
|
|
// DEPRECATED: Use Domain or Path
|
2015-09-08 23:00:48 +00:00
|
|
|
func SplitHostname(named Named) (string, string) {
|
2017-01-09 23:44:59 +00:00
|
|
|
if r, ok := named.(namedRepository); ok {
|
2016-06-09 18:32:23 +00:00
|
|
|
return r.Domain(), r.Path()
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
2016-06-09 18:32:23 +00:00
|
|
|
return splitDomain(named.Name())
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Parse parses s and returns a syntactically valid Reference.
|
|
|
|
// If an error was encountered it is returned, along with a nil Reference.
|
2015-09-08 23:00:48 +00:00
|
|
|
// NOTE: Parse will not handle short digests.
|
2015-07-10 18:36:04 +00:00
|
|
|
func Parse(s string) (Reference, error) {
|
2015-09-08 23:00:48 +00:00
|
|
|
matches := ReferenceRegexp.FindStringSubmatch(s)
|
|
|
|
if matches == nil {
|
|
|
|
if s == "" {
|
|
|
|
return nil, ErrNameEmpty
|
|
|
|
}
|
2016-08-11 13:30:17 +00:00
|
|
|
if ReferenceRegexp.FindStringSubmatch(strings.ToLower(s)) != nil {
|
|
|
|
return nil, ErrNameContainsUppercase
|
|
|
|
}
|
2015-09-08 23:00:48 +00:00
|
|
|
return nil, ErrReferenceInvalidFormat
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(matches[1]) > NameTotalLengthMax {
|
|
|
|
return nil, ErrNameTooLong
|
|
|
|
}
|
|
|
|
|
2016-06-09 18:32:23 +00:00
|
|
|
var repo repository
|
|
|
|
|
|
|
|
nameMatch := anchoredNameRegexp.FindStringSubmatch(matches[1])
|
|
|
|
if nameMatch != nil && len(nameMatch) == 3 {
|
|
|
|
repo.domain = nameMatch[1]
|
|
|
|
repo.path = nameMatch[2]
|
|
|
|
} else {
|
|
|
|
repo.domain = ""
|
|
|
|
repo.path = matches[1]
|
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
ref := reference{
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository: repo,
|
2016-06-27 23:41:28 +00:00
|
|
|
tag: matches[2],
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
|
|
|
if matches[3] != "" {
|
|
|
|
var err error
|
2016-12-15 23:07:42 +00:00
|
|
|
ref.digest, err = digest.Parse(matches[3])
|
2015-09-08 23:00:48 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
2015-09-08 23:00:48 +00:00
|
|
|
|
|
|
|
r := getBestReferenceType(ref)
|
|
|
|
if r == nil {
|
|
|
|
return nil, ErrNameEmpty
|
|
|
|
}
|
|
|
|
|
|
|
|
return r, nil
|
|
|
|
}
|
|
|
|
|
2015-10-13 22:42:04 +00:00
|
|
|
// 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.
|
|
|
|
func ParseNamed(s string) (Named, error) {
|
|
|
|
ref, err := Parse(s)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
named, isNamed := ref.(Named)
|
|
|
|
if !isNamed {
|
|
|
|
return nil, fmt.Errorf("reference %s has no name", ref.String())
|
|
|
|
}
|
|
|
|
return named, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithName returns a named object representing the given string. If the input
|
|
|
|
// is invalid ErrReferenceInvalidFormat will be returned.
|
|
|
|
func WithName(name string) (Named, error) {
|
2015-11-02 17:12:21 +00:00
|
|
|
if len(name) > NameTotalLengthMax {
|
|
|
|
return nil, ErrNameTooLong
|
|
|
|
}
|
2016-06-09 18:32:23 +00:00
|
|
|
|
|
|
|
match := anchoredNameRegexp.FindStringSubmatch(name)
|
|
|
|
if match == nil || len(match) != 3 {
|
2015-07-10 18:36:04 +00:00
|
|
|
return nil, ErrReferenceInvalidFormat
|
|
|
|
}
|
2016-06-09 18:32:23 +00:00
|
|
|
return repository{
|
|
|
|
domain: match[1],
|
|
|
|
path: match[2],
|
|
|
|
}, nil
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-10-10 00:09:54 +00:00
|
|
|
// WithTag combines the name from "name" and the tag from "tag" to form a
|
|
|
|
// reference incorporating both the name and the tag.
|
2015-10-13 22:42:04 +00:00
|
|
|
func WithTag(name Named, tag string) (NamedTagged, error) {
|
2015-10-29 01:22:00 +00:00
|
|
|
if !anchoredTagRegexp.MatchString(tag) {
|
2015-10-10 00:09:54 +00:00
|
|
|
return nil, ErrTagInvalidFormat
|
|
|
|
}
|
2016-06-09 18:32:23 +00:00
|
|
|
var repo repository
|
2017-01-09 23:44:59 +00:00
|
|
|
if r, ok := name.(namedRepository); ok {
|
2016-06-09 18:32:23 +00:00
|
|
|
repo.domain = r.Domain()
|
|
|
|
repo.path = r.Path()
|
|
|
|
} else {
|
|
|
|
repo.path = name.Name()
|
|
|
|
}
|
2016-11-08 22:47:33 +00:00
|
|
|
if canonical, ok := name.(Canonical); ok {
|
|
|
|
return reference{
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository: repo,
|
2016-06-27 23:41:28 +00:00
|
|
|
tag: tag,
|
|
|
|
digest: canonical.Digest(),
|
2016-11-08 22:47:33 +00:00
|
|
|
}, nil
|
|
|
|
}
|
2015-10-10 00:09:54 +00:00
|
|
|
return taggedReference{
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository: repo,
|
2016-06-27 23:41:28 +00:00
|
|
|
tag: tag,
|
2015-10-10 00:09:54 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithDigest combines the name from "name" and the digest from "digest" to form
|
|
|
|
// a reference incorporating both the name and the digest.
|
2015-10-13 22:42:04 +00:00
|
|
|
func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
|
2015-10-10 00:09:54 +00:00
|
|
|
if !anchoredDigestRegexp.MatchString(digest.String()) {
|
|
|
|
return nil, ErrDigestInvalidFormat
|
|
|
|
}
|
2016-06-09 18:32:23 +00:00
|
|
|
var repo repository
|
2017-01-09 23:44:59 +00:00
|
|
|
if r, ok := name.(namedRepository); ok {
|
2016-06-09 18:32:23 +00:00
|
|
|
repo.domain = r.Domain()
|
|
|
|
repo.path = r.Path()
|
|
|
|
} else {
|
|
|
|
repo.path = name.Name()
|
|
|
|
}
|
2016-11-08 22:47:33 +00:00
|
|
|
if tagged, ok := name.(Tagged); ok {
|
|
|
|
return reference{
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository: repo,
|
2016-06-27 23:41:28 +00:00
|
|
|
tag: tagged.Tag(),
|
|
|
|
digest: digest,
|
2016-11-08 22:47:33 +00:00
|
|
|
}, nil
|
|
|
|
}
|
2015-10-10 00:09:54 +00:00
|
|
|
return canonicalReference{
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository: repo,
|
2016-06-27 23:41:28 +00:00
|
|
|
digest: digest,
|
2015-10-10 00:09:54 +00:00
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2016-11-09 21:04:52 +00:00
|
|
|
// Match reports whether ref matches the specified pattern.
|
|
|
|
// See https://godoc.org/path#Match for supported patterns.
|
|
|
|
func Match(pattern string, ref Reference) (bool, error) {
|
|
|
|
matched, err := path.Match(pattern, ref.String())
|
|
|
|
if namedRef, isNamed := ref.(Named); isNamed && !matched {
|
|
|
|
matched, _ = path.Match(pattern, namedRef.Name())
|
|
|
|
}
|
|
|
|
return matched, err
|
|
|
|
}
|
|
|
|
|
2016-11-10 22:46:04 +00:00
|
|
|
// TrimNamed removes any tag or digest from the named reference.
|
|
|
|
func TrimNamed(ref Named) Named {
|
2016-06-27 23:41:28 +00:00
|
|
|
domain, path := SplitHostname(ref)
|
|
|
|
return repository{
|
|
|
|
domain: domain,
|
|
|
|
path: path,
|
|
|
|
}
|
2016-11-10 22:46:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func getBestReferenceType(ref reference) Reference {
|
2016-06-27 23:41:28 +00:00
|
|
|
if ref.Name() == "" {
|
2015-09-08 23:00:48 +00:00
|
|
|
// Allow digest only references
|
|
|
|
if ref.digest != "" {
|
|
|
|
return digestReference(ref.digest)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if ref.tag == "" {
|
|
|
|
if ref.digest != "" {
|
|
|
|
return canonicalReference{
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository: ref.namedRepository,
|
2016-06-27 23:41:28 +00:00
|
|
|
digest: ref.digest,
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-09 23:44:59 +00:00
|
|
|
return ref.namedRepository
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
2015-09-08 23:00:48 +00:00
|
|
|
if ref.digest == "" {
|
|
|
|
return taggedReference{
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository: ref.namedRepository,
|
2016-06-27 23:41:28 +00:00
|
|
|
tag: ref.tag,
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
2015-09-08 23:00:48 +00:00
|
|
|
|
|
|
|
return ref
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
type reference struct {
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository
|
2015-09-08 23:00:48 +00:00
|
|
|
tag string
|
|
|
|
digest digest.Digest
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (r reference) String() string {
|
2016-06-09 18:32:23 +00:00
|
|
|
return r.Name() + ":" + r.tag + "@" + r.digest.String()
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (r reference) Tag() string {
|
|
|
|
return r.tag
|
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (r reference) Digest() digest.Digest {
|
|
|
|
return r.digest
|
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2016-06-09 18:32:23 +00:00
|
|
|
type repository struct {
|
|
|
|
domain string
|
|
|
|
path string
|
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (r repository) String() string {
|
2016-06-09 18:32:23 +00:00
|
|
|
return r.Name()
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (r repository) Name() string {
|
2016-06-09 18:32:23 +00:00
|
|
|
if r.domain == "" {
|
|
|
|
return r.path
|
|
|
|
}
|
|
|
|
return r.domain + "/" + r.path
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r repository) Domain() string {
|
|
|
|
return r.domain
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r repository) Path() string {
|
|
|
|
return r.path
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
type digestReference digest.Digest
|
|
|
|
|
|
|
|
func (d digestReference) String() string {
|
|
|
|
return d.String()
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (d digestReference) Digest() digest.Digest {
|
|
|
|
return digest.Digest(d)
|
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
type taggedReference struct {
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository
|
2016-06-09 18:32:23 +00:00
|
|
|
tag string
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (t taggedReference) String() string {
|
2016-06-09 18:32:23 +00:00
|
|
|
return t.Name() + ":" + t.tag
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (t taggedReference) Tag() string {
|
|
|
|
return t.tag
|
|
|
|
}
|
|
|
|
|
|
|
|
type canonicalReference struct {
|
2017-01-09 23:44:59 +00:00
|
|
|
namedRepository
|
2015-09-08 23:00:48 +00:00
|
|
|
digest digest.Digest
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c canonicalReference) String() string {
|
2016-06-09 18:32:23 +00:00
|
|
|
return c.Name() + "@" + c.digest.String()
|
2015-09-08 23:00:48 +00:00
|
|
|
}
|
2015-07-10 18:36:04 +00:00
|
|
|
|
2015-09-08 23:00:48 +00:00
|
|
|
func (c canonicalReference) Digest() digest.Digest {
|
|
|
|
return c.digest
|
2015-07-10 18:36:04 +00:00
|
|
|
}
|