platforms: fill default arm variant when parse platform specifier

arm has been supported, but something is missing, causes test failure

    --- FAIL: TestParseSelector/linux (0.00s)
        platforms_test.go:292: arm support not fully implemented: not implemented
    --- FAIL: TestParseSelector/macOS (0.00s)
        platforms_test.go:292: arm support not fully implemented: not implemented

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
This commit is contained in:
Shengjing Zhu 2020-01-07 23:53:05 +08:00
parent 0d276ece0e
commit 90cd777a6c
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

@ -26,10 +26,15 @@ import (
func TestParseSelector(t *testing.T) {
var (
defaultOS = runtime.GOOS
defaultArch = runtime.GOARCH
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) {