| 807 | } |
| 808 | |
| 809 | func (i *Image) hasDifferentDigestWithSystemContext(ctx context.Context, remoteRef types.ImageReference, sys *types.SystemContext) (bool, error) { |
| 810 | remoteImg, err := remoteRef.NewImage(ctx, sys) |
| 811 | if err != nil { |
| 812 | return false, err |
| 813 | } |
| 814 | |
| 815 | rawManifest, rawManifestMIMEType, err := remoteImg.Manifest(ctx) |
| 816 | if err != nil { |
| 817 | return false, err |
| 818 | } |
| 819 | |
| 820 | // If the remote ref's manifest is a list, try to zero in on the image |
| 821 | // in the list that we would eventually try to pull. |
| 822 | var remoteDigest digest.Digest |
| 823 | if manifest.MIMETypeIsMultiImage(rawManifestMIMEType) { |
| 824 | list, err := manifest.ListFromBlob(rawManifest, rawManifestMIMEType) |
| 825 | if err != nil { |
| 826 | return false, err |
| 827 | } |
| 828 | remoteDigest, err = list.ChooseInstance(sys) |
| 829 | if err != nil { |
| 830 | return false, err |
| 831 | } |
| 832 | } else { |
| 833 | remoteDigest, err = manifest.Digest(rawManifest) |
| 834 | if err != nil { |
| 835 | return false, err |
| 836 | } |
| 837 | } |
| 838 | |
| 839 | // Check if we already have that image's manifest in this image. A |
| 840 | // single image can have multiple manifests that describe the same |
| 841 | // config blob and layers, so treat any match as a successful match. |
| 842 | for _, digest := range append(i.Digests(), i.Digest()) { |
| 843 | if digest.Validate() != nil { |
| 844 | continue |
| 845 | } |
| 846 | if digest.String() == remoteDigest.String() { |
| 847 | return false, nil |
| 848 | } |
| 849 | } |
| 850 | // No matching digest found in the local image. |
| 851 | return true, nil |
| 852 | } |
| 853 | |
| 854 | // driverData gets the driver data from the store on a layer |
| 855 | func (i *Image) driverData() (*DriverData, error) { |