Skip to content

Commit

Permalink
add arm64/v9 matching vectors
Browse files Browse the repository at this point in the history
Allow arm64/v9 to fall back to arm64/v8

Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Jun 15, 2024
1 parent 163df76 commit 24aa85b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 47 additions & 0 deletions compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 24aa85b

Please sign in to comment.