From 24aa85b8518b5da7f520073c3a6e41bc5e846094 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Fri, 14 Jun 2024 18:29:49 -0700 Subject: [PATCH] add arm64/v9 matching vectors Allow arm64/v9 to fall back to arm64/v8 Signed-off-by: Tonis Tiigi --- compare.go | 11 +++++++++++ compare_test.go | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/compare.go b/compare.go index 3913ef6..7390e78 100644 --- a/compare.go +++ b/compare.go @@ -72,6 +72,17 @@ func platformVector(platform specs.Platform) []specs.Platform { if variant == "" { variant = "v8" } + if arm64Version, err := strconv.Atoi(strings.TrimPrefix(platform.Variant, "v")); err == nil && arm64Version > 8 { + for arm64Version--; arm64Version >= 8; arm64Version-- { + vector = append(vector, specs.Platform{ + Architecture: platform.Architecture, + OS: platform.OS, + OSVersion: platform.OSVersion, + OSFeatures: platform.OSFeatures, + Variant: "v" + strconv.Itoa(arm64Version), + }) + } + } vector = append(vector, platformVector(specs.Platform{ Architecture: "arm", OS: platform.OS, diff --git a/compare_test.go b/compare_test.go index 2c276d0..60043f3 100644 --- a/compare_test.go +++ b/compare_test.go @@ -201,12 +201,36 @@ func TestOnly(t *testing.T) { "linux/amd64", "linux/arm/v4", "linux/arm/v9", + "linux/arm64/v7", "linux/arm64/v9", "windows/amd64", "windows/arm", }, }, }, + { + platform: "linux/arm64/v9", + matches: map[bool][]string{ + true: { + "linux/arm", + "linux/arm/v5", + "linux/arm/v6", + "linux/arm/v7", + "linux/arm/v8", + "linux/arm64", + "linux/arm64/v8", + "linux/arm64/v9", + }, + false: { + "linux/amd64", + "linux/arm/v4", + "linux/arm64/v7", + "linux/arm64/v10", + "windows/arm64", + "windows/arm", + }, + }, + }, } { testcase := tc t.Run(testcase.platform, func(t *testing.T) { @@ -406,12 +430,35 @@ func TestOnlyStrict(t *testing.T) { "linux/amd64", "linux/arm/v4", "linux/arm/v9", + "linux/arm64/v7", "linux/arm64/v9", "windows/amd64", "windows/arm", }, }, }, + { + platform: "linux/arm64/v9", + matches: map[bool][]string{ + true: { + "linux/arm64/v9", + }, + false: { + "linux/arm", + "linux/arm/v7", + "linux/arm/v8", + "linux/arm/v9", + "linux/arm64/v7", + "linux/arm64", + "linux/arm64/v8", + "linux/arm/v4", + "linux/arm64/v10", + "linux/amd64", + "windows/arm64", + "windows/arm", + }, + }, + }, } { testcase := tc t.Run(testcase.platform, func(t *testing.T) {