MCPcopy Create free account
hub / github.com/containers/common / normalizeTaggedDigestedNamed

Function normalizeTaggedDigestedNamed

libimage/normalize.go:162–181  ·  view source on GitHub ↗

normalizeTaggedDigestedNamed strips the tag off the specified named reference iff it is tagged and digested. Note that the tag is entirely ignored to match Docker behavior.

(named reference.Named)

Source from the content-addressed store, hash-verified

160// reference iff it is tagged and digested. Note that the tag is entirely
161// ignored to match Docker behavior.
162func normalizeTaggedDigestedNamed(named reference.Named) (reference.Named, error) {
163 _, isTagged := named.(reference.NamedTagged)
164 if !isTagged {
165 return named, nil
166 }
167 digested, isDigested := named.(reference.Digested)
168 if !isDigested {
169 return named, nil
170 }
171
172 // Now strip off the tag.
173 newNamed := reference.TrimNamed(named)
174 // And re-add the digest.
175 newNamed, err := reference.WithDigest(newNamed, digested.Digest())
176 if err != nil {
177 return named, err
178 }
179 logrus.Debugf("Stripped off tag from tagged and digested reference %q", named.String())
180 return newNamed, nil
181}

Callers 2

NormalizeNameFunction · 0.85

Calls 2

DigestMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…