From 80b7e8b5d723f7f64aa10edd0942099ab7700518 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 19 Oct 2021 17:10:34 +0200 Subject: [PATCH] buildkit: normalize build target and local platform Signed-off-by: CrazyMax (cherry picked from commit b4e056d556f1318f146acd66ff916d2df79fb564) --- .../builder-next/adapters/containerimage/pull.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/builder/builder-next/adapters/containerimage/pull.go b/builder/builder-next/adapters/containerimage/pull.go index 6b791f1064..7a5a4e1424 100644 --- a/builder/builder-next/adapters/containerimage/pull.go +++ b/builder/builder-next/adapters/containerimage/pull.go @@ -22,6 +22,7 @@ import ( "github.com/containerd/containerd/remotes/docker" "github.com/containerd/containerd/remotes/docker/schema1" distreference "github.com/docker/distribution/reference" + dimages "github.com/docker/docker/daemon/images" "github.com/docker/docker/distribution" "github.com/docker/docker/distribution/metadata" "github.com/docker/docker/distribution/xfer" @@ -854,11 +855,11 @@ func resolveModeToString(rm source.ResolveMode) string { } func platformMatches(img *image.Image, p *ocispec.Platform) bool { - if img.Architecture != p.Architecture { - return false - } - if img.Variant != "" && img.Variant != p.Variant { - return false - } - return img.OS == p.OS + return dimages.OnlyPlatformWithFallback(*p).Match(ocispec.Platform{ + Architecture: img.Architecture, + OS: img.OS, + OSVersion: img.OSVersion, + OSFeatures: img.OSFeatures, + Variant: img.Variant, + }) }