Skip to content

Commit

Permalink
Support normalizing any arm64/v9.x variants
Browse files Browse the repository at this point in the history
Signed-off-by: Chongyi Zheng <[email protected]>
Signed-off-by: Samuel Karp <[email protected]>
  • Loading branch information
harryzcy authored and samuelkarp committed Nov 4, 2024
1 parent 41c2c97 commit 8cf0cb3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
24 changes: 24 additions & 0 deletions compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,30 @@ func TestOnlyStrict(t *testing.T) {
},
},
},
{
platform: "linux/arm64/v9.5",
matches: map[bool][]string{
true: {
"linux/arm64/v9.5",
},
false: {
"linux/arm",
"linux/arm/v5",
"linux/arm/v6",
"linux/arm/v7",
"linux/arm/v8",
"linux/amd64",
"linux/arm/v4",
"linux/arm64/v8",
"linux/arm64/v8.1",
"linux/arm64/v9",
"linux/arm64/v9.1",
"linux/arm64/v9.4",
"windows/amd64",
"windows/arm",
},
},
},
{
platform: "linux/arm64/v9",
matches: map[bool][]string{
Expand Down
22 changes: 15 additions & 7 deletions database.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,22 @@ func normalizeArch(arch, variant string) (string, string) {
}
case "aarch64", "arm64":
arch = "arm64"
switch variant {
case "8", "v8", "8.0", "v8.0":
majorVariant, minorVariant, hasMinor := strings.Cut(variant, ".")
majorVariant = strings.TrimPrefix(majorVariant, "v")
if minorVariant == "0" {
minorVariant = ""
hasMinor = false
}

if (majorVariant == "" || majorVariant == "8") && !hasMinor {
// normalize v8 to empty string
variant = ""
case "9", "9.0", "v9.0":
variant = "v9"
case "8.1", "8.2", "8.3", "8.4", "8.5", "8.6", "8.7", "8.8", "8.9",
"9.1", "9.2", "9.3", "9.4", "9.5":
variant = "v" + variant
} else {
// otherwise to v8.x or v9 or v9.x
variant = "v" + majorVariant
if hasMinor {
variant = variant + "." + minorVariant
}
}
case "armhf":
arch = "arm"
Expand Down

0 comments on commit 8cf0cb3

Please sign in to comment.