Skip to content

Commit fa7dfb0

Browse files
authored
x-pack/dockerlogbeat: fix mage build failing on cross-arch platform (#48957)
Build() was missing the platform filter that Package() relied on, causing it to attempt an arm64 cross-build on amd64 hosts (and vice versa). Rename isSupportedPlatform to filterPlatformsForNativeArch to make the side-effect explicit, and call it from Build() as well.
1 parent d880646 commit fa7dfb0

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

x-pack/dockerlogbeat/magefile.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ func CrossBuild() error {
360360

361361
// Build builds the base container used by the docker plugin
362362
func Build() {
363+
if !filterPlatformsForNativeArch() {
364+
fmt.Println(">> build: skipping because no supported platform is enabled")
365+
return
366+
}
363367
mg.SerialDeps(CrossBuild, BuildContainer)
364368
}
365369

@@ -381,7 +385,7 @@ func Package() {
381385
start := time.Now()
382386
defer func() { fmt.Println("package ran for", time.Since(start)) }()
383387

384-
if !isSupportedPlatform() {
388+
if !filterPlatformsForNativeArch() {
385389
fmt.Println(">> package: skipping because no supported platform is enabled")
386390
return
387391
}
@@ -397,7 +401,9 @@ func Ironbank() error {
397401
return nil
398402
}
399403

400-
func isSupportedPlatform() bool {
404+
// filterPlatformsForNativeArch removes cross-architecture platforms that
405+
// can't be built on the current host, and reports whether any remain.
406+
func filterPlatformsForNativeArch() bool {
401407
_, isAMD64Selected := devtools.Platforms.Get("linux/amd64")
402408
_, isARM64Selected := devtools.Platforms.Get("linux/arm64")
403409
arch := runtime.GOARCH

0 commit comments

Comments
 (0)