From 8cc39fc143cce204ffde1cd0afb4f01bb7f30f37 Mon Sep 17 00:00:00 2001 From: Pier-Hugues Pellerin Date: Wed, 14 Nov 2018 19:59:25 -0500 Subject: [PATCH] Make functionbeat build process depends on linux/amd64 (#8889) (#8903) Functionbeat packaging depends on a Linux binary that will be sent to the serverless platform, previously the magefile for the project did not express that dependency. This was causing problems when you were building the packages only for a specific platform. This commit fixes that problem by introducing `mage.WithPlatforms` this allows you to specific dependency when you define the cross build logic. (cherry picked from commit f71fc5c243dddfdfb2b1e4c2139e2e19b7c724aa) --- CHANGELOG-developer.asciidoc | 1 + dev-tools/mage/crossbuild.go | 11 +++++++++++ dev-tools/mage/platforms.go | 8 ++++++++ x-pack/functionbeat/magefile.go | 2 +- 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-developer.asciidoc b/CHANGELOG-developer.asciidoc index 5c31ba9d8eb..5e07694adb8 100644 --- a/CHANGELOG-developer.asciidoc +++ b/CHANGELOG-developer.asciidoc @@ -60,3 +60,4 @@ The list below covers the major changes between 6.3.0 and master only. - Add `mage.GenerateFieldsGo` for generating fields.go files. {pull}8615[8615] - Add `mage.KibanaDashboards` for collecting Kibana dashboards and generating index patterns. {pull}8615[8615] - Allow to disable config resolver using the `Settings.DisableConfigResolver` field when initializing libbeat. {pull}8769[8769] +- Add `mage.AddPlatforms` to allow to specify dependent platforms when building a beat. {pull}8889[8889] diff --git a/dev-tools/mage/crossbuild.go b/dev-tools/mage/crossbuild.go index 33fb14f4b1b..f32d5a2dac3 100644 --- a/dev-tools/mage/crossbuild.go +++ b/dev-tools/mage/crossbuild.go @@ -88,6 +88,17 @@ func ImageSelector(f ImageSelectorFunc) func(params *crossBuildParams) { } } +// AddPlatforms sets dependencies on others platforms. +func AddPlatforms(expressions ...string) func(params *crossBuildParams) { + return func(params *crossBuildParams) { + var list BuildPlatformList + for _, expr := range expressions { + list = NewPlatformList(expr) + params.Platforms = params.Platforms.Merge(list) + } + } +} + type crossBuildParams struct { Platforms BuildPlatformList Target string diff --git a/dev-tools/mage/platforms.go b/dev-tools/mage/platforms.go index c6039c55aba..8dbfc1c7b82 100644 --- a/dev-tools/mage/platforms.go +++ b/dev-tools/mage/platforms.go @@ -445,6 +445,14 @@ func (list BuildPlatformList) Filter(expr string) BuildPlatformList { return out.deduplicate() } +// Merge creates a new list with the two list merged. +func (list BuildPlatformList) Merge(with BuildPlatformList) BuildPlatformList { + out := make(BuildPlatformList, 0, len(list)+len(with)) + out = append(list, with...) + out = append(out, with...) + return out.deduplicate() +} + // deduplicate removes duplicate platforms and sorts the list. func (list BuildPlatformList) deduplicate() BuildPlatformList { set := map[string]BuildPlatform{} diff --git a/x-pack/functionbeat/magefile.go b/x-pack/functionbeat/magefile.go index e6d2b416a5a..d379baeb734 100644 --- a/x-pack/functionbeat/magefile.go +++ b/x-pack/functionbeat/magefile.go @@ -39,7 +39,7 @@ func BuildGoDaemon() error { // CrossBuild cross-builds the beat for all target platforms. func CrossBuild() error { - return mage.CrossBuild() + return mage.CrossBuild(mage.AddPlatforms("linux/amd64")) } // CrossBuildGoDaemon cross-builds the go-daemon binary using Docker.