Merge pull request #3776 from thaJeztah/ref_replace_deprecated
reference: replace deprecated function SplitHostname
This commit is contained in:
commit
fee8c686bb
1 changed files with 8 additions and 5 deletions
|
@ -177,7 +177,8 @@ func splitDomain(name string) (string, string) {
|
||||||
// hostname and name string. If no valid hostname is
|
// hostname and name string. If no valid hostname is
|
||||||
// found, the hostname is empty and the full value
|
// found, the hostname is empty and the full value
|
||||||
// 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()
|
||||||
|
@ -322,11 +323,13 @@ func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
|
||||||
|
|
||||||
// TrimNamed removes any tag or digest from the named reference.
|
// TrimNamed removes any tag or digest from the named reference.
|
||||||
func TrimNamed(ref Named) Named {
|
func TrimNamed(ref Named) Named {
|
||||||
domain, path := SplitHostname(ref)
|
repo := repository{}
|
||||||
return repository{
|
if r, ok := ref.(namedRepository); ok {
|
||||||
domain: domain,
|
repo.domain, repo.path = r.Domain(), r.Path()
|
||||||
path: path,
|
} else {
|
||||||
|
repo.domain, repo.path = splitDomain(ref.Name())
|
||||||
}
|
}
|
||||||
|
return repo
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBestReferenceType(ref reference) Reference {
|
func getBestReferenceType(ref reference) Reference {
|
||||||
|
|
Loading…
Reference in a new issue