From 2c4bf1a66407e64b016d37fed681eadbaffff108 Mon Sep 17 00:00:00 2001 From: zounengren Date: Mon, 27 Sep 2021 04:29:46 +0800 Subject: [PATCH] replace deprecated function Signed-off-by: Zou Nengren Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 79d19015492357887313f21c64d6bfa2202549e4) Signed-off-by: Sebastiaan van Stijn --- reference/reference.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/reference/reference.go b/reference/reference.go index b7cd00b0d..4fdf4fd46 100644 --- a/reference/reference.go +++ b/reference/reference.go @@ -320,11 +320,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 {