Skip to content

Commit

Permalink
Make functionbeat build process depends on linux/amd64
Browse files Browse the repository at this point in the history
Functionbeat packaging depends on a linux binary that will be send to
the serverless platform, previously the magefile for the project did not express
that dependencies. This was causing problem when you were building the
packages only for a specific platform. This commit fixes that problem by
introducing `mage.WithPlatforms` this allow you to specific dependency
when you define the cross build logic.
  • Loading branch information
ph committed Nov 1, 2018
1 parent cfdea3d commit 61d3cc3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-developer.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,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.WithPlatforms` to allow to specify dependent platforms when building a beat. {pull}8889[8889]
10 changes: 10 additions & 0 deletions dev-tools/mage/crossbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ func ImageSelector(f ImageSelectorFunc) func(params *crossBuildParams) {
}
}

// WithPlatforms sets dependencies on others platforms.
func WithPlatforms(expressions ...string) func(params *crossBuildParams) {
return func(params *crossBuildParams) {
for _, expr := range expressions {
list := NewPlatformList(expr)
params.Platforms = params.Platforms.Merge(list)
}
}
}

type crossBuildParams struct {
Platforms BuildPlatformList
Target string
Expand Down
6 changes: 6 additions & 0 deletions dev-tools/mage/platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@ 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 := append(list, with...)
return out.deduplicate()
}

// deduplicate removes duplicate platforms and sorts the list.
func (list BuildPlatformList) deduplicate() BuildPlatformList {
set := map[string]BuildPlatform{}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/functionbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.WithPlatforms("linux/amd64"))
}

// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker.
Expand Down

0 comments on commit 61d3cc3

Please sign in to comment.