Skip to content

Commit

Permalink
Import mage targets whenever possible for metricbeat. (#13906)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemadden42 authored Oct 4, 2019
1 parent 1ff1703 commit 4ec2854
Showing 1 changed file with 17 additions and 42 deletions.
59 changes: 17 additions & 42 deletions metricbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,30 @@ import (
"time"

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"

devtools "github.com/elastic/beats/dev-tools/mage"
metricbeat "github.com/elastic/beats/metricbeat/scripts/mage"

// mage:import
build "github.com/elastic/beats/dev-tools/mage/target/build"
// mage:import
"github.com/elastic/beats/dev-tools/mage/target/common"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/dashboards"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/docs"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/pkg"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/test"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/unittest"
// mage:import
update "github.com/elastic/beats/dev-tools/mage/target/update"
)

func init() {
common.RegisterCheckDeps(Update)
common.RegisterCheckDeps(update.Update)

devtools.BeatDescription = "Metricbeat is a lightweight shipper for metrics."
}
Expand All @@ -47,32 +60,6 @@ func CollectAll() {
mg.Deps(CollectDocs, FieldsDocs)
}

// Build builds the Beat binary.
func Build() error {
return devtools.Build(devtools.DefaultBuildArgs())
}

// GolangCrossBuild build the Beat binary inside of the golang-builder.
// Do not use directly, use crossBuild instead.
func GolangCrossBuild() error {
return devtools.GolangCrossBuild(devtools.DefaultGolangCrossBuildArgs())
}

// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon).
func BuildGoDaemon() error {
return devtools.BuildGoDaemon()
}

// CrossBuild cross-builds the beat for all target platforms.
func CrossBuild() error {
return devtools.CrossBuild()
}

// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker.
func CrossBuildGoDaemon() error {
return devtools.CrossBuildGoDaemon()
}

// Package packages the Beat for distribution.
// Use SNAPSHOT=true to build snapshots.
// Use PLATFORMS to control the target platforms.
Expand All @@ -84,8 +71,8 @@ func Package() {
devtools.UseElasticBeatOSSPackaging()
metricbeat.CustomizePackaging()

mg.Deps(Update, metricbeat.PrepareModulePackagingOSS)
mg.Deps(CrossBuild, CrossBuildGoDaemon)
mg.Deps(update.Update, metricbeat.PrepareModulePackagingOSS)
mg.Deps(build.CrossBuild, build.CrossBuildGoDaemon)
mg.SerialDeps(devtools.Package, TestPackages)
}

Expand All @@ -108,18 +95,6 @@ func configYML() error {
return devtools.Config(devtools.AllConfigTypes, metricbeat.OSSConfigFileParams(), ".")
}

// Update updates the generated files (aka make update).
func Update() error {
// TODO to replace by a pure mage implementation:
// - Generate docs/fields.asciidoc
/*
mg.SerialDeps(Fields, Dashboards, Config,
metricbeat.PrepareModulePackagingOSS,
devtools.GenerateModuleIncludeListGo)
*/
return sh.Run("make", "update")
}

// MockedTests runs the HTTP tests using the mocked data inside each {module}/{metricset}/testdata folder.
// Use MODULE={module_name} to run only mocked tests with a single module.
// Use GENERATE=true or GENERATE=1 to regenerate JSON files.
Expand Down

0 comments on commit 4ec2854

Please sign in to comment.