Merge pull request #3776 from thaJeztah/ref_replace_deprecated

reference: replace deprecated function SplitHostname
This commit is contained in:
Milos Gajdos 2022-11-08 17:30:59 +00:00 committed by GitHub
commit fee8c686bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {