Merge pull request #3939 from zhsj/fix-arm

platforms: fill default arm variant when parse platform specifier
This commit is contained in:
Michael Crosby
2020-01-08 11:00:56 -05:00
committed by GitHub
2 changed files with 13 additions and 7 deletions

View File

@@ -189,9 +189,8 @@ func Parse(specifier string) (specs.Platform, error) {
if isKnownOS(p.OS) {
// picks a default architecture
p.Architecture = runtime.GOARCH
if p.Architecture == "arm" {
// TODO(stevvooe): Resolve arm variant, if not v6 (default)
return specs.Platform{}, errors.Wrapf(errdefs.ErrNotImplemented, "arm support not fully implemented")
if p.Architecture == "arm" && cpuVariant != "v7" {
p.Variant = cpuVariant
}
return p, nil

View File

@@ -28,8 +28,13 @@ func TestParseSelector(t *testing.T) {
var (
defaultOS = runtime.GOOS
defaultArch = runtime.GOARCH
defaultVariant = ""
)
if defaultArch == "arm" && cpuVariant != "v7" {
defaultVariant = cpuVariant
}
for _, testcase := range []struct {
skip bool
input string
@@ -255,8 +260,9 @@ func TestParseSelector(t *testing.T) {
expected: specs.Platform{
OS: "linux",
Architecture: defaultArch,
Variant: defaultVariant,
},
formatted: joinNotEmpty("linux", defaultArch),
formatted: joinNotEmpty("linux", defaultArch, defaultVariant),
},
{
input: "s390x",
@@ -279,8 +285,9 @@ func TestParseSelector(t *testing.T) {
expected: specs.Platform{
OS: "darwin",
Architecture: defaultArch,
Variant: defaultVariant,
},
formatted: joinNotEmpty("darwin", defaultArch),
formatted: joinNotEmpty("darwin", defaultArch, defaultVariant),
},
} {
t.Run(testcase.input, func(t *testing.T) {