Replace util.NormalizeImageRef with reference.ParseDockerRef
Using the utility caused other project to have containerd/cri as a dependency, only for this utility. The new `reference.ParseDockerRef` function does the same (it's a copy of this function). Tests were kept for now, but could be removed in future. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -26,25 +26,8 @@ import (
|
||||
// and digest, the function returns digested reference, e.g. docker.io/library/busybox:latest@
|
||||
// sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa will be returned as
|
||||
// docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa.
|
||||
//
|
||||
// Deprecated: use github.com/docker/reference.ParseDockerRef() instead
|
||||
func NormalizeImageRef(ref string) (reference.Named, error) {
|
||||
named, err := reference.ParseNormalizedNamed(ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, ok := named.(reference.NamedTagged); ok {
|
||||
if canonical, ok := named.(reference.Canonical); ok {
|
||||
// The reference is both tagged and digested, only
|
||||
// return digested.
|
||||
newNamed, err := reference.WithName(canonical.Name())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newCanonical, err := reference.WithDigest(newNamed, canonical.Digest())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return newCanonical, nil
|
||||
}
|
||||
}
|
||||
return reference.TagNameOnly(named), nil
|
||||
return reference.ParseDockerRef(ref)
|
||||
}
|
||||
|
Reference in New Issue
Block a user