Skip to content

Commit f15c3be

Browse files
Merge pull request #2417 from dmcgowan/update-arm64-normalize
Normalize arm64 to an empty variant
2 parents 47a128d + db3c5af commit f15c3be

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

platforms/database.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func normalizeArch(arch, variant string) (string, string) {
9292
case "aarch64", "arm64":
9393
arch = "arm64"
9494
switch variant {
95-
case "", "8":
96-
variant = "v8"
95+
case "8", "v8":
96+
variant = ""
9797
}
9898
case "armhf":
9999
arch = "arm"
@@ -112,15 +112,3 @@ func normalizeArch(arch, variant string) (string, string) {
112112

113113
return arch, variant
114114
}
115-
116-
// defaultVariant detects default variants on normalized arch/variant
117-
func defaultVariant(arch, variant string) bool {
118-
switch arch {
119-
case "arm64":
120-
return variant == "v8"
121-
case "arm":
122-
return variant == "v7"
123-
default:
124-
return true
125-
}
126-
}

platforms/platforms.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func Parse(specifier string) (specs.Platform, error) {
197197
}
198198

199199
p.Architecture, p.Variant = normalizeArch(parts[0], "")
200-
if defaultVariant(p.Architecture, p.Variant) {
200+
if p.Architecture == "arm" && p.Variant == "v7" {
201201
p.Variant = ""
202202
}
203203
if isKnownArch(p.Architecture) {
@@ -211,7 +211,7 @@ func Parse(specifier string) (specs.Platform, error) {
211211
// about whether or not we know of the platform.
212212
p.OS = normalizeOS(parts[0])
213213
p.Architecture, p.Variant = normalizeArch(parts[1], "")
214-
if defaultVariant(p.Architecture, p.Variant) {
214+
if p.Architecture == "arm" && p.Variant == "v7" {
215215
p.Variant = ""
216216
}
217217

@@ -220,6 +220,9 @@ func Parse(specifier string) (specs.Platform, error) {
220220
// we have a fully specified variant, this is rare
221221
p.OS = normalizeOS(parts[0])
222222
p.Architecture, p.Variant = normalizeArch(parts[1], parts[2])
223+
if p.Architecture == "arm64" && p.Variant == "" {
224+
p.Variant = "v8"
225+
}
223226

224227
return p, nil
225228
}

0 commit comments

Comments
 (0)