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

Method HasDifferentDigest

libimage/image.go:782–807  ·  view source on GitHub ↗

HasDifferentDigest returns true if the image specified by `remoteRef` has a different digest than the local one. This check can be useful to check for updates on remote registries.

(ctx context.Context, remoteRef types.ImageReference, options *HasDifferentDigestOptions)

Source from the content-addressed store, hash-verified

780// different digest than the local one. This check can be useful to check for
781// updates on remote registries.
782func (i *Image) HasDifferentDigest(ctx context.Context, remoteRef types.ImageReference, options *HasDifferentDigestOptions) (bool, error) {
783 // We need to account for the arch that the image uses. It seems
784 // common on ARM to tweak this option to pull the correct image. See
785 // github.com/containers/podman/issues/6613.
786 inspectInfo, err := i.inspectInfo(ctx)
787 if err != nil {
788 return false, err
789 }
790
791 sys := i.runtime.systemContextCopy()
792 sys.ArchitectureChoice = inspectInfo.Architecture
793 // OS and variant may not be set, so let's check to avoid accidental
794 // overrides of the runtime settings.
795 if inspectInfo.Os != "" {
796 sys.OSChoice = inspectInfo.Os
797 }
798 if inspectInfo.Variant != "" {
799 sys.VariantChoice = inspectInfo.Variant
800 }
801
802 if options != nil && options.AuthFilePath != "" {
803 sys.AuthFilePath = options.AuthFilePath
804 }
805
806 return i.hasDifferentDigestWithSystemContext(ctx, remoteRef, sys)
807}
808
809func (i *Image) hasDifferentDigestWithSystemContext(ctx context.Context, remoteRef types.ImageReference, sys *types.SystemContext) (bool, error) {
810 remoteImg, err := remoteRef.NewImage(ctx, sys)

Callers 1

TestImageFunctionsFunction · 0.80

Calls 3

inspectInfoMethod · 0.95
systemContextCopyMethod · 0.80

Tested by 1

TestImageFunctionsFunction · 0.64