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

Method hasDifferentDigestWithSystemContext

libimage/image.go:809–852  ·  view source on GitHub ↗
(ctx context.Context, remoteRef types.ImageReference, sys *types.SystemContext)

Source from the content-addressed store, hash-verified

807}
808
809func (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
855func (i *Image) driverData() (*DriverData, error) {

Callers 2

HasDifferentDigestMethod · 0.95

Calls 6

ManifestMethod · 0.95
DigestMethod · 0.95
DigestsMethod · 0.95
NewImageMethod · 0.80
ValidateMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected