From f84ae499c02d3e7ba6830c819720daefc12932b3 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 6 Apr 2021 10:33:02 +0200 Subject: [PATCH] fix local image lookup for custom platform Move the platform check into `resolveLocalImage` and inspect each of the candidates in the given order. This preserves the local lookup order and fixes a bug reported in containers/podman/issues/9915. Signed-off-by: Valentin Rothberg --- new.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/new.go b/new.go index f29af1f5d1f..be67a3bfba7 100644 --- a/new.go +++ b/new.go @@ -122,6 +122,10 @@ func resolveLocalImage(systemContext *types.SystemContext, store storage.Store, if err != nil { return nil, "", "", nil, errors.Wrapf(err, "error parsing reference to image %q", img.ID) } + if !imageMatch(context.Background(), ref, systemContext) { + logrus.Debugf("Found local image %s but it does not match the provided context", imageName) + continue + } return ref, ref.Transport().Name(), imageName, img, nil } @@ -188,7 +192,7 @@ func resolveImage(ctx context.Context, systemContext *types.SystemContext, store } if options.PullPolicy == define.PullNever || options.PullPolicy == define.PullIfMissing { - if localImage != nil && imageMatch(ctx, localImageRef, systemContext) { + if localImage != nil { return localImageRef, localImageRef.Transport().Name(), localImage, nil } if options.PullPolicy == define.PullNever {