Merge pull request #4032 from thaJeztah/2.8_backport_ref_replace_deprecated

[release/2.8 backport] reference: replace deprecated function SplitHostname
This commit is contained in:
Milos Gajdos 2023-08-31 15:20:59 +01:00 committed by GitHub
commit 10a7e4c483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -175,7 +175,8 @@ func splitDomain(name string) (string, string) {
// hostname and name string. If no valid hostname is
// found, the hostname is empty and the full value
// is returned as name
// DEPRECATED: Use Domain or Path
//
// Deprecated: Use [Domain] or [Path].
func SplitHostname(named Named) (string, string) {
if r, ok := named.(namedRepository); ok {
return r.Domain(), r.Path()
@ -320,11 +321,13 @@ func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
// TrimNamed removes any tag or digest from the named reference.
func TrimNamed(ref Named) Named {
domain, path := SplitHostname(ref)
return repository{
domain: domain,
path: path,
repo := repository{}
if r, ok := ref.(namedRepository); ok {
repo.domain, repo.path = r.Domain(), r.Path()
} else {
repo.domain, repo.path = splitDomain(ref.Name())
}
return repo
}
func getBestReferenceType(ref reference) Reference {