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

Function WithDigest

docker/reference/reference.go:297–319  ·  view source on GitHub ↗

WithDigest combines the name from "name" and the digest from "digest" to form a reference incorporating both the name and the digest.

(name Named, digest digest.Digest)

Source from the content-addressed store, hash-verified

295// WithDigest combines the name from "name" and the digest from "digest" to form
296// a reference incorporating both the name and the digest.
297func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
298 if !anchoredDigestRegexp.MatchString(digest.String()) {
299 return nil, ErrDigestInvalidFormat
300 }
301 var repo repository
302 if r, ok := name.(namedRepository); ok {
303 repo.domain = r.Domain()
304 repo.path = r.Path()
305 } else {
306 repo.path = name.Name()
307 }
308 if tagged, ok := name.(Tagged); ok {
309 return reference{
310 namedRepository: repo,
311 tag: tagged.Tag(),
312 digest: digest,
313 }, nil
314 }
315 return canonicalReference{
316 namedRepository: repo,
317 digest: digest,
318 }, nil
319}
320
321// TrimNamed removes any tag or digest from the named reference.
322func TrimNamed(ref Named) Named {

Callers 6

ResolveFunction · 0.92
ResolveLocallyFunction · 0.92
ParseDockerRefFunction · 0.85
TestWithTagFunction · 0.85
TestWithDigestFunction · 0.85

Calls 5

StringMethod · 0.65
DomainMethod · 0.65
PathMethod · 0.65
NameMethod · 0.65
TagMethod · 0.65

Tested by 3

TestWithTagFunction · 0.68
TestWithDigestFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…