Add amd64->386 fallback

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
This commit is contained in:
Tianon Gravi 2020-09-03 17:15:26 -07:00
parent 6bf5650450
commit 5fa5f15de5
2 changed files with 10 additions and 1 deletions

View File

@ -37,6 +37,14 @@ func platformVector(platform specs.Platform) []specs.Platform {
vector := []specs.Platform{platform}
switch platform.Architecture {
case "amd64":
vector = append(vector, specs.Platform{
Architecture: "386",
OS: platform.OS,
OSVersion: platform.OSVersion,
OSFeatures: platform.OSFeatures,
Variant: platform.Variant,
})
case "arm":
if armVersion, err := strconv.Atoi(strings.TrimPrefix(platform.Variant, "v")); err == nil && armVersion > 5 {
for armVersion--; armVersion >= 5; armVersion-- {
@ -60,6 +68,7 @@ func platformVector(platform specs.Platform) []specs.Platform {
// For arm/v8, will also match arm/v7, arm/v6 and arm/v5
// For arm/v7, will also match arm/v6 and arm/v5
// For arm/v6, will also match arm/v5
// For amd64, will also match 386
func Only(platform specs.Platform) MatchComparer {
return Ordered(platformVector(Normalize(platform))...)
}

View File

@ -30,9 +30,9 @@ func TestOnly(t *testing.T) {
matches: map[bool][]string{
true: {
"linux/amd64",
"linux/386",
},
false: {
"linux/386",
"linux/arm/v7",
"linux/arm64",
"windows/amd64",