Skip to content

Commit 90cd777

Browse files
committed
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 <[email protected]>
1 parent 0d276ec commit 90cd777

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

platforms/platforms.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ func Parse(specifier string) (specs.Platform, error) {
189189
if isKnownOS(p.OS) {
190190
// picks a default architecture
191191
p.Architecture = runtime.GOARCH
192-
if p.Architecture == "arm" {
193-
// TODO(stevvooe): Resolve arm variant, if not v6 (default)
194-
return specs.Platform{}, errors.Wrapf(errdefs.ErrNotImplemented, "arm support not fully implemented")
192+
if p.Architecture == "arm" && cpuVariant != "v7" {
193+
p.Variant = cpuVariant
195194
}
196195

197196
return p, nil

platforms/platforms_test.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ import (
2626

2727
func TestParseSelector(t *testing.T) {
2828
var (
29-
defaultOS = runtime.GOOS
30-
defaultArch = runtime.GOARCH
29+
defaultOS = runtime.GOOS
30+
defaultArch = runtime.GOARCH
31+
defaultVariant = ""
3132
)
3233

34+
if defaultArch == "arm" && cpuVariant != "v7" {
35+
defaultVariant = cpuVariant
36+
}
37+
3338
for _, testcase := range []struct {
3439
skip bool
3540
input string
@@ -255,8 +260,9 @@ func TestParseSelector(t *testing.T) {
255260
expected: specs.Platform{
256261
OS: "linux",
257262
Architecture: defaultArch,
263+
Variant: defaultVariant,
258264
},
259-
formatted: joinNotEmpty("linux", defaultArch),
265+
formatted: joinNotEmpty("linux", defaultArch, defaultVariant),
260266
},
261267
{
262268
input: "s390x",
@@ -279,8 +285,9 @@ func TestParseSelector(t *testing.T) {
279285
expected: specs.Platform{
280286
OS: "darwin",
281287
Architecture: defaultArch,
288+
Variant: defaultVariant,
282289
},
283-
formatted: joinNotEmpty("darwin", defaultArch),
290+
formatted: joinNotEmpty("darwin", defaultArch, defaultVariant),
284291
},
285292
} {
286293
t.Run(testcase.input, func(t *testing.T) {

0 commit comments

Comments
 (0)