RepoDigests returns a string array of repodigests associated with the image.
()
| 677 | |
| 678 | // RepoDigests returns a string array of repodigests associated with the image. |
| 679 | func (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 |