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

Method RepoDigests

libimage/image.go:679–707  ·  view source on GitHub ↗

RepoDigests returns a string array of repodigests associated with the image.

()

Source from the content-addressed store, hash-verified

677
678// RepoDigests returns a string array of repodigests associated with the image.
679func (i *Image) RepoDigests() ([]string, error) {
680 repoDigests := []string{}
681 added := make(map[string]struct{})
682
683 for _, name := range i.Names() {
684 for _, imageDigest := range append(i.Digests(), i.Digest()) {
685 if imageDigest == "" {
686 continue
687 }
688
689 named, err := reference.ParseNormalizedNamed(name)
690 if err != nil {
691 return nil, err
692 }
693
694 canonical, err := reference.WithDigest(reference.TrimNamed(named), imageDigest)
695 if err != nil {
696 return nil, err
697 }
698
699 if _, alreadyInList := added[canonical.String()]; !alreadyInList {
700 repoDigests = append(repoDigests, canonical.String())
701 added[canonical.String()] = struct{}{}
702 }
703 }
704 }
705 sort.Strings(repoDigests)
706 return repoDigests, nil
707}
708
709// Mount the image with the specified mount options and label, both of which
710// are directly passed down to the containers storage. Returns the fully

Callers 2

InspectMethod · 0.95
TestImageFunctionsFunction · 0.80

Calls 4

NamesMethod · 0.95
DigestsMethod · 0.95
DigestMethod · 0.95
StringMethod · 0.45

Tested by 1

TestImageFunctionsFunction · 0.64