From 90cd777a6c8c92c105625ba086e2e67a0c32d7ed Mon Sep 17 00:00:00 2001 From: Shengjing Zhu Date: Tue, 7 Jan 2020 23:53:05 +0800 Subject: [PATCH] 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 --- platforms/platforms.go | 5 ++--- platforms/platforms_test.go | 15 +++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/platforms/platforms.go b/platforms/platforms.go index d2b73ac3d..77d3f184e 100644 --- a/platforms/platforms.go +++ b/platforms/platforms.go @@ -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 diff --git a/platforms/platforms_test.go b/platforms/platforms_test.go index e72f71b54..4d7a9e8f1 100644 --- a/platforms/platforms_test.go +++ b/platforms/platforms_test.go @@ -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) {