From a8847c01fbdf022ebbd747653623700326d88666 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Fri, 25 Jun 2021 10:51:30 +0200 Subject: auto-update: use libimage for image checks Use the `HasDifferentDigest()` method of the image to replace the previous checks if an image needs to be updated. Signed-off-by: Valentin Rothberg --- pkg/autoupdate/autoupdate.go | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'pkg') diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go index 85082dbbb..911e2280b 100644 --- a/pkg/autoupdate/autoupdate.go +++ b/pkg/autoupdate/autoupdate.go @@ -9,7 +9,6 @@ import ( "github.com/containers/common/pkg/config" "github.com/containers/image/v5/docker" "github.com/containers/image/v5/docker/reference" - "github.com/containers/image/v5/manifest" "github.com/containers/image/v5/transports/alltransports" "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod/define" @@ -299,37 +298,7 @@ func newerRemoteImageAvailable(runtime *libpod.Runtime, img *libimage.Image, ori return false, err } - data, err := img.Inspect(context.Background(), false) - if err != nil { - return false, err - } - - sys := runtime.SystemContext() - if authfile != "" { - sys.AuthFilePath = authfile - } - - // We need to account for the arch that the image uses. It seems - // common on ARM to tweak this option to pull the correct image. See - // github.com/containers/podman/issues/6613. - sys.ArchitectureChoice = data.Architecture - - remoteImg, err := remoteRef.NewImage(context.Background(), sys) - if err != nil { - return false, err - } - - rawManifest, _, err := remoteImg.Manifest(context.Background()) - if err != nil { - return false, err - } - - remoteDigest, err := manifest.Digest(rawManifest) - if err != nil { - return false, err - } - - return img.Digest().String() != remoteDigest.String(), nil + return img.HasDifferentDigest(context.Background(), remoteRef) } // newerLocalImageAvailable returns true if the container and local image have different digests -- cgit v1.2.3-54-g00ecf