Update magefile

This commit is contained in:
Blerim Sheqa 2019-08-15 14:05:42 +02:00
parent 97a5b11407
commit 7357b0f489

View File

@ -27,44 +27,44 @@ import (
"github.com/magefile/mage/mg" "github.com/magefile/mage/mg"
"github.com/magefile/mage/sh" "github.com/magefile/mage/sh"
"github.com/elastic/beats/dev-tools/mage" devtools "github.com/elastic/beats/dev-tools/mage"
) )
func init() { func init() {
mage.SetBuildVariableSources(mage.DefaultBeatBuildVariableSources) devtools.SetBuildVariableSources(devtools.DefaultBeatBuildVariableSources)
mage.BeatDescription = "One sentence description of the Beat." devtools.BeatDescription = "One sentence description of the Beat."
} }
// Build builds the Beat binary. // Build builds the Beat binary.
func Build() error { func Build() error {
return mage.Build(mage.DefaultBuildArgs()) return devtools.Build(devtools.DefaultBuildArgs())
} }
// GolangCrossBuild build the Beat binary inside of the golang-builder. // GolangCrossBuild build the Beat binary inside of the golang-builder.
// Do not use directly, use crossBuild instead. // Do not use directly, use crossBuild instead.
func GolangCrossBuild() error { func GolangCrossBuild() error {
return mage.GolangCrossBuild(mage.DefaultGolangCrossBuildArgs()) return devtools.GolangCrossBuild(devtools.DefaultGolangCrossBuildArgs())
} }
// BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). // BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon).
func BuildGoDaemon() error { func BuildGoDaemon() error {
return mage.BuildGoDaemon() return devtools.BuildGoDaemon()
} }
// CrossBuild cross-builds the beat for all target platforms. // CrossBuild cross-builds the beat for all target platforms.
func CrossBuild() error { func CrossBuild() error {
return mage.CrossBuild() return devtools.CrossBuild()
} }
// CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. // CrossBuildGoDaemon cross-builds the go-daemon binary using Docker.
func CrossBuildGoDaemon() error { func CrossBuildGoDaemon() error {
return mage.CrossBuildGoDaemon() return devtools.CrossBuildGoDaemon()
} }
// Clean cleans all generated files and build artifacts. // Clean cleans all generated files and build artifacts.
func Clean() error { func Clean() error {
return mage.Clean() return devtools.Clean()
} }
// Package packages the Beat for distribution. // Package packages the Beat for distribution.
@ -74,16 +74,16 @@ func Package() {
start := time.Now() start := time.Now()
defer func() { fmt.Println("package ran for", time.Since(start)) }() defer func() { fmt.Println("package ran for", time.Since(start)) }()
mage.UseCommunityBeatPackaging() devtools.UseCommunityBeatPackaging()
mg.Deps(Update) mg.Deps(Update)
mg.Deps(CrossBuild, CrossBuildGoDaemon) mg.Deps(CrossBuild, CrossBuildGoDaemon)
mg.SerialDeps(mage.Package, TestPackages) mg.SerialDeps(devtools.Package, TestPackages)
} }
// TestPackages tests the generated packages (i.e. file modes, owners, groups). // TestPackages tests the generated packages (i.e. file modes, owners, groups).
func TestPackages() error { func TestPackages() error {
return mage.TestPackages() return devtools.TestPackages()
} }
// Update updates the generated files (aka make update). // Update updates the generated files (aka make update).
@ -93,19 +93,24 @@ func Update() error {
// Fields generates a fields.yml for the Beat. // Fields generates a fields.yml for the Beat.
func Fields() error { func Fields() error {
return mage.GenerateFieldsYAML() return devtools.GenerateFieldsYAML()
} }
// GoTestUnit executes the Go unit tests. // GoTestUnit executes the Go unit tests.
// Use TEST_COVERAGE=true to enable code coverage profiling. // Use TEST_COVERAGE=true to enable code coverage profiling.
// Use RACE_DETECTOR=true to enable the race detector. // Use RACE_DETECTOR=true to enable the race detector.
func GoTestUnit(ctx context.Context) error { func GoTestUnit(ctx context.Context) error {
return mage.GoTest(ctx, mage.DefaultGoTestUnitArgs()) return devtools.GoTest(ctx, devtools.DefaultGoTestUnitArgs())
} }
// GoTestIntegration executes the Go integration tests. // GoTestIntegration executes the Go integration tests.
// Use TEST_COVERAGE=true to enable code coverage profiling. // Use TEST_COVERAGE=true to enable code coverage profiling.
// Use RACE_DETECTOR=true to enable the race detector. // Use RACE_DETECTOR=true to enable the race detector.
func GoTestIntegration(ctx context.Context) error { func GoTestIntegration(ctx context.Context) error {
return mage.GoTest(ctx, mage.DefaultGoTestIntegrationArgs()) return devtools.GoTest(ctx, devtools.DefaultGoTestIntegrationArgs())
}
// Config generates both the short/reference/docker configs.
func Config() error {
return devtools.Config(devtools.AllConfigTypes, devtools.ConfigFileParams{}, ".")
} }