From 48ca1ca4766b5dcdf1af7722b046888f21837e37 Mon Sep 17 00:00:00 2001 From: Kostas Stamatakis Date: Mon, 29 Jul 2024 11:10:57 +0300 Subject: [PATCH] simplify --- dev-tools/mage/crossbuild.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dev-tools/mage/crossbuild.go b/dev-tools/mage/crossbuild.go index 21509efc5784..bd171bfd725f 100644 --- a/dev-tools/mage/crossbuild.go +++ b/dev-tools/mage/crossbuild.go @@ -349,14 +349,13 @@ func (b GolangCrossBuilder) Build() error { // This fixes an issue where during arm64 linux build for the currently used docker image // docker.elastic.co/beats-dev/golang-crossbuild:1.22.5-arm the image for amd64 arch is pulled // and causes problems when using native arch tools on the binaries that are built for arm64 arch. - if strings.HasPrefix(b.Platform, "linux/") && !b.UseHostPlatform { - args = append(args, - "--platform", b.Platform, - ) - } else if strings.HasPrefix(b.Platform, "linux/") && b.UseHostPlatform { - args = append(args, - "--platform", dockerHostPlatform(), - ) + // Unless the flag UseHostPlatform is set, in which case the host platform is used for container runtime. + if strings.HasPrefix(b.Platform, "linux/") { + platform := b.Platform + if b.UseHostPlatform { + platform = dockerHostPlatform() + } + args = append(args, "--platform", platform) } args = append(args,