Add amd64->386 fallback
Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
This commit is contained in:
parent
6bf5650450
commit
5fa5f15de5
@ -37,6 +37,14 @@ func platformVector(platform specs.Platform) []specs.Platform {
|
|||||||
vector := []specs.Platform{platform}
|
vector := []specs.Platform{platform}
|
||||||
|
|
||||||
switch platform.Architecture {
|
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":
|
case "arm":
|
||||||
if armVersion, err := strconv.Atoi(strings.TrimPrefix(platform.Variant, "v")); err == nil && armVersion > 5 {
|
if armVersion, err := strconv.Atoi(strings.TrimPrefix(platform.Variant, "v")); err == nil && armVersion > 5 {
|
||||||
for armVersion--; armVersion >= 5; armVersion-- {
|
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/v8, will also match arm/v7, arm/v6 and arm/v5
|
||||||
// For arm/v7, will also match 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 arm/v6, will also match arm/v5
|
||||||
|
// For amd64, will also match 386
|
||||||
func Only(platform specs.Platform) MatchComparer {
|
func Only(platform specs.Platform) MatchComparer {
|
||||||
return Ordered(platformVector(Normalize(platform))...)
|
return Ordered(platformVector(Normalize(platform))...)
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,9 @@ func TestOnly(t *testing.T) {
|
|||||||
matches: map[bool][]string{
|
matches: map[bool][]string{
|
||||||
true: {
|
true: {
|
||||||
"linux/amd64",
|
"linux/amd64",
|
||||||
|
"linux/386",
|
||||||
},
|
},
|
||||||
false: {
|
false: {
|
||||||
"linux/386",
|
|
||||||
"linux/arm/v7",
|
"linux/arm/v7",
|
||||||
"linux/arm64",
|
"linux/arm64",
|
||||||
"windows/amd64",
|
"windows/amd64",
|
||||||
|
Loading…
Reference in New Issue
Block a user