diff --git a/image/cache/compare.go b/image/cache/compare.go index c13b11a06d..7633b0e966 100644 --- a/image/cache/compare.go +++ b/image/cache/compare.go @@ -26,6 +26,13 @@ func comparePlatform(builderPlatform, imagePlatform ocispec.Platform) bool { builderParts := strings.Split(builderPlatform.OSVersion, ".") imageParts := strings.Split(imagePlatform.OSVersion, ".") + // Major and minor must match. + for i := 0; i < 2; i++ { + if len(builderParts) > i && len(imageParts) > i && builderParts[i] != imageParts[i] { + return false + } + } + if len(builderParts) >= 3 && len(imageParts) >= 3 { // Keep only Major & Minor. builderParts[0] = imageParts[0] diff --git a/image/cache/compare_test.go b/image/cache/compare_test.go index 8d6ce735e2..7cffbdad1b 100644 --- a/image/cache/compare_test.go +++ b/image/cache/compare_test.go @@ -193,12 +193,6 @@ func TestPlatformCompare(t *testing.T) { }, } { tc := tc - // OSVersion comparison is only performed by containerd platform - // matcher if built on Windows. - if (tc.image.OSVersion != "" || tc.builder.OSVersion != "") && runtime.GOOS != "windows" { - continue - } - t.Run(tc.name, func(t *testing.T) { assert.Check(t, is.Equal(comparePlatform(tc.builder, tc.image), tc.expected)) })