Skip to content

Commit 57ab179

Browse files
committed
frontend/dockerui/build: fix "no scan targets for linux/arm64/v8"
Fix issue 5915 Signed-off-by: Akihiro Suda <[email protected]>
1 parent c5d01bc commit 57ab179

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

frontend/dockerui/build.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,15 @@ func extendWindowsPlatform(p, imgP ocispecs.Platform) ocispecs.Platform {
128128
}
129129

130130
func normalizePlatform(p, imgP ocispecs.Platform) exptypes.Platform {
131-
k := platforms.FormatAll(p)
132-
p = extendWindowsPlatform(p, imgP)
133-
p = platforms.Normalize(p)
131+
var k string
132+
if p.OS == "windows" {
133+
k = platforms.FormatAll(p)
134+
p = extendWindowsPlatform(p, imgP)
135+
p = platforms.Normalize(p)
136+
} else {
137+
p = platforms.Normalize(p)
138+
k = platforms.FormatAll(p)
139+
}
134140
return exptypes.Platform{
135141
ID: k,
136142
Platform: p,

frontend/dockerui/build_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package dockerui
2+
3+
import (
4+
"testing"
5+
6+
"github.com/moby/buildkit/exporter/containerimage/exptypes"
7+
ocispecs "github.com/opencontainers/image-spec/specs-go/v1"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestNormalizePlatform(t *testing.T) {
12+
testCases := []struct {
13+
p, imgP ocispecs.Platform
14+
expected exptypes.Platform
15+
}{
16+
{
17+
p: ocispecs.Platform{
18+
Architecture: "arm64",
19+
OS: "linux",
20+
Variant: "v8",
21+
},
22+
imgP: ocispecs.Platform{
23+
Architecture: "arm64",
24+
OS: "linux",
25+
},
26+
expected: exptypes.Platform{
27+
ID: "linux/arm64", // Not "linux/arm64/v8" https://github.com/moby/buildkit/issues/5915
28+
Platform: ocispecs.Platform{
29+
Architecture: "arm64",
30+
OS: "linux",
31+
},
32+
},
33+
},
34+
// TODO: cover Windows https://github.com/moby/buildkit/pull/5837
35+
}
36+
37+
for _, tc := range testCases {
38+
require.Equal(t, tc.expected, normalizePlatform(tc.p, tc.imgP))
39+
}
40+
}

0 commit comments

Comments
 (0)