MCPcopy Create free account
hub / github.com/containers/image / ParseDockerRef

Function ParseDockerRef

docker/reference/normalize.go:64–85  ·  view source on GitHub ↗

ParseDockerRef normalizes the image reference following the docker convention. This is added mainly for backward compatibility. The reference returned can only be either tagged or digested. For reference contains both tag and digest, the function returns digested reference, e.g. docker.io/library/bu

(ref string)

Source from the content-addressed store, hash-verified

62// sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa will be returned as
63// docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa.
64func ParseDockerRef(ref string) (Named, error) {
65 named, err := ParseNormalizedNamed(ref)
66 if err != nil {
67 return nil, err
68 }
69 if _, ok := named.(NamedTagged); ok {
70 if canonical, ok := named.(Canonical); ok {
71 // The reference is both tagged and digested, only
72 // return digested.
73 newNamed, err := WithName(canonical.Name())
74 if err != nil {
75 return nil, err
76 }
77 newCanonical, err := WithDigest(newNamed, canonical.Digest())
78 if err != nil {
79 return nil, err
80 }
81 return newCanonical, nil
82 }
83 }
84 return TagNameOnly(named), nil
85}
86
87// splitDockerDomain splits a repository name to domain and remotename string.
88// If no valid domain is found, the default domain is used. Repository name

Callers 1

TestParseDockerRefFunction · 0.85

Calls 6

ParseNormalizedNamedFunction · 0.85
WithNameFunction · 0.85
WithDigestFunction · 0.85
TagNameOnlyFunction · 0.85
NameMethod · 0.65
DigestMethod · 0.65

Tested by 1

TestParseDockerRefFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…