Unexport NamedRepository
NamedRepository only needs to be used internally. Additionally this interface may go away in the future and be merged with Named. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
parent
e0286a7de0
commit
320f72d252
@ -81,7 +81,7 @@ func splitDockerDomain(name string) (domain, remainder string) {
|
|||||||
// For example, "docker.io/library/redis" will have the familiar
|
// For example, "docker.io/library/redis" will have the familiar
|
||||||
// name "redis" and "docker.io/dmcgowan/myapp" will be "dmcgowan/myapp".
|
// name "redis" and "docker.io/dmcgowan/myapp" will be "dmcgowan/myapp".
|
||||||
// Returns a familiarized named only reference.
|
// Returns a familiarized named only reference.
|
||||||
func familiarizeName(named NamedRepository) repository {
|
func familiarizeName(named namedRepository) repository {
|
||||||
repo := repository{
|
repo := repository{
|
||||||
domain: named.Domain(),
|
domain: named.Domain(),
|
||||||
path: named.Path(),
|
path: named.Path(),
|
||||||
@ -96,7 +96,7 @@ func familiarizeName(named NamedRepository) repository {
|
|||||||
|
|
||||||
func (r reference) Familiar() Named {
|
func (r reference) Familiar() Named {
|
||||||
return reference{
|
return reference{
|
||||||
NamedRepository: familiarizeName(r.NamedRepository),
|
namedRepository: familiarizeName(r.namedRepository),
|
||||||
tag: r.tag,
|
tag: r.tag,
|
||||||
digest: r.digest,
|
digest: r.digest,
|
||||||
}
|
}
|
||||||
@ -108,14 +108,14 @@ func (r repository) Familiar() Named {
|
|||||||
|
|
||||||
func (t taggedReference) Familiar() Named {
|
func (t taggedReference) Familiar() Named {
|
||||||
return taggedReference{
|
return taggedReference{
|
||||||
NamedRepository: familiarizeName(t.NamedRepository),
|
namedRepository: familiarizeName(t.namedRepository),
|
||||||
tag: t.tag,
|
tag: t.tag,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c canonicalReference) Familiar() Named {
|
func (c canonicalReference) Familiar() Named {
|
||||||
return canonicalReference{
|
return canonicalReference{
|
||||||
NamedRepository: familiarizeName(c.NamedRepository),
|
namedRepository: familiarizeName(c.namedRepository),
|
||||||
digest: c.digest,
|
digest: c.digest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,9 +135,9 @@ type Canonical interface {
|
|||||||
Digest() digest.Digest
|
Digest() digest.Digest
|
||||||
}
|
}
|
||||||
|
|
||||||
// NamedRepository is a reference to a repository with a name.
|
// namedRepository is a reference to a repository with a name.
|
||||||
// A NamedRepository has both domain and path components.
|
// A namedRepository has both domain and path components.
|
||||||
type NamedRepository interface {
|
type namedRepository interface {
|
||||||
Named
|
Named
|
||||||
Domain() string
|
Domain() string
|
||||||
Path() string
|
Path() string
|
||||||
@ -145,7 +145,7 @@ type NamedRepository interface {
|
|||||||
|
|
||||||
// Domain returns the domain part of the Named reference
|
// Domain returns the domain part of the Named reference
|
||||||
func Domain(named Named) string {
|
func Domain(named Named) string {
|
||||||
if r, ok := named.(NamedRepository); ok {
|
if r, ok := named.(namedRepository); ok {
|
||||||
return r.Domain()
|
return r.Domain()
|
||||||
}
|
}
|
||||||
domain, _ := splitDomain(named.Name())
|
domain, _ := splitDomain(named.Name())
|
||||||
@ -154,7 +154,7 @@ func Domain(named Named) string {
|
|||||||
|
|
||||||
// Path returns the name without the domain part of the Named reference
|
// Path returns the name without the domain part of the Named reference
|
||||||
func Path(named Named) (name string) {
|
func Path(named Named) (name string) {
|
||||||
if r, ok := named.(NamedRepository); ok {
|
if r, ok := named.(namedRepository); ok {
|
||||||
return r.Path()
|
return r.Path()
|
||||||
}
|
}
|
||||||
_, path := splitDomain(named.Name())
|
_, path := splitDomain(named.Name())
|
||||||
@ -175,7 +175,7 @@ func splitDomain(name string) (string, string) {
|
|||||||
// is returned as name
|
// is returned as name
|
||||||
// DEPRECATED: Use Domain or Path
|
// DEPRECATED: Use Domain or Path
|
||||||
func SplitHostname(named Named) (string, string) {
|
func SplitHostname(named Named) (string, string) {
|
||||||
if r, ok := named.(NamedRepository); ok {
|
if r, ok := named.(namedRepository); ok {
|
||||||
return r.Domain(), r.Path()
|
return r.Domain(), r.Path()
|
||||||
}
|
}
|
||||||
return splitDomain(named.Name())
|
return splitDomain(named.Name())
|
||||||
@ -212,7 +212,7 @@ func Parse(s string) (Reference, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ref := reference{
|
ref := reference{
|
||||||
NamedRepository: repo,
|
namedRepository: repo,
|
||||||
tag: matches[2],
|
tag: matches[2],
|
||||||
}
|
}
|
||||||
if matches[3] != "" {
|
if matches[3] != "" {
|
||||||
@ -272,7 +272,7 @@ func WithTag(name Named, tag string) (NamedTagged, error) {
|
|||||||
return nil, ErrTagInvalidFormat
|
return nil, ErrTagInvalidFormat
|
||||||
}
|
}
|
||||||
var repo repository
|
var repo repository
|
||||||
if r, ok := name.(NamedRepository); ok {
|
if r, ok := name.(namedRepository); ok {
|
||||||
repo.domain = r.Domain()
|
repo.domain = r.Domain()
|
||||||
repo.path = r.Path()
|
repo.path = r.Path()
|
||||||
} else {
|
} else {
|
||||||
@ -280,13 +280,13 @@ func WithTag(name Named, tag string) (NamedTagged, error) {
|
|||||||
}
|
}
|
||||||
if canonical, ok := name.(Canonical); ok {
|
if canonical, ok := name.(Canonical); ok {
|
||||||
return reference{
|
return reference{
|
||||||
NamedRepository: repo,
|
namedRepository: repo,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
digest: canonical.Digest(),
|
digest: canonical.Digest(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
return taggedReference{
|
return taggedReference{
|
||||||
NamedRepository: repo,
|
namedRepository: repo,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -298,7 +298,7 @@ func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
|
|||||||
return nil, ErrDigestInvalidFormat
|
return nil, ErrDigestInvalidFormat
|
||||||
}
|
}
|
||||||
var repo repository
|
var repo repository
|
||||||
if r, ok := name.(NamedRepository); ok {
|
if r, ok := name.(namedRepository); ok {
|
||||||
repo.domain = r.Domain()
|
repo.domain = r.Domain()
|
||||||
repo.path = r.Path()
|
repo.path = r.Path()
|
||||||
} else {
|
} else {
|
||||||
@ -306,13 +306,13 @@ func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
|
|||||||
}
|
}
|
||||||
if tagged, ok := name.(Tagged); ok {
|
if tagged, ok := name.(Tagged); ok {
|
||||||
return reference{
|
return reference{
|
||||||
NamedRepository: repo,
|
namedRepository: repo,
|
||||||
tag: tagged.Tag(),
|
tag: tagged.Tag(),
|
||||||
digest: digest,
|
digest: digest,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
return canonicalReference{
|
return canonicalReference{
|
||||||
NamedRepository: repo,
|
namedRepository: repo,
|
||||||
digest: digest,
|
digest: digest,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@ -347,15 +347,15 @@ func getBestReferenceType(ref reference) Reference {
|
|||||||
if ref.tag == "" {
|
if ref.tag == "" {
|
||||||
if ref.digest != "" {
|
if ref.digest != "" {
|
||||||
return canonicalReference{
|
return canonicalReference{
|
||||||
NamedRepository: ref.NamedRepository,
|
namedRepository: ref.namedRepository,
|
||||||
digest: ref.digest,
|
digest: ref.digest,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ref.NamedRepository
|
return ref.namedRepository
|
||||||
}
|
}
|
||||||
if ref.digest == "" {
|
if ref.digest == "" {
|
||||||
return taggedReference{
|
return taggedReference{
|
||||||
NamedRepository: ref.NamedRepository,
|
namedRepository: ref.namedRepository,
|
||||||
tag: ref.tag,
|
tag: ref.tag,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -364,7 +364,7 @@ func getBestReferenceType(ref reference) Reference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type reference struct {
|
type reference struct {
|
||||||
NamedRepository
|
namedRepository
|
||||||
tag string
|
tag string
|
||||||
digest digest.Digest
|
digest digest.Digest
|
||||||
}
|
}
|
||||||
@ -416,7 +416,7 @@ func (d digestReference) Digest() digest.Digest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type taggedReference struct {
|
type taggedReference struct {
|
||||||
NamedRepository
|
namedRepository
|
||||||
tag string
|
tag string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +429,7 @@ func (t taggedReference) Tag() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type canonicalReference struct {
|
type canonicalReference struct {
|
||||||
NamedRepository
|
namedRepository
|
||||||
digest digest.Digest
|
digest digest.Digest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user