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) { if isKnownOS(p.OS) {
// picks a default architecture // picks a default architecture
p.Architecture = runtime.GOARCH p.Architecture = runtime.GOARCH
if p.Architecture == "arm" { if p.Architecture == "arm" && cpuVariant != "v7" {
// TODO(stevvooe): Resolve arm variant, if not v6 (default) p.Variant = cpuVariant
return specs.Platform{}, errors.Wrapf(errdefs.ErrNotImplemented, "arm support not fully implemented")
} }
return p, nil return p, nil

View File

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