Skip to content

Commit

Permalink
Stop using mage:import in custom beats
Browse files Browse the repository at this point in the history
mage:import doesn't take into account vendorized dependencies, this is a
problen for custom beats, because by default they have libbeat as a
vendorized dependency. The solution would be to use go modules, but in
the meantime lets remove the use of mage:import from the magefiles
intended to be used by custom beats.
  • Loading branch information
jsoriano committed Oct 21, 2019
1 parent 5718890 commit 08e3c18
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG-developer.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ The list below covers the major changes between 7.0.0-rc2 and master only.

==== Bugfixes

- Stop using `mage:import` in community beats. This was ignoring the vendorized beats directory for some mage targets, using the code available in GOPATH, this causes inconsistencies and compilation problems if the version of the code in the GOPATH is different to the vendored one. Use of `mage:import` will continue to be unsupported in custom beats till beats is migrated to go modules, or mage supports vendored dependencies. {issue}13998[13998] {pull}14162[14162]

==== Added

- Metricset generator generates beta modules by default now. {pull}10657[10657]
Expand Down
32 changes: 19 additions & 13 deletions generator/beat/{beat}/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,10 @@ import (
"github.com/magefile/mage/sh"

devtools "github.com/elastic/beats/dev-tools/mage"
"github.com/elastic/beats/generator/common/beatgen"

// mage:import
"github.com/elastic/beats/dev-tools/mage/target/pkg"
// mage:import
"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/test"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/unittest"
// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/integtest"
"github.com/elastic/beats/dev-tools/mage/target/common"
"github.com/elastic/beats/dev-tools/mage/target/pkg"
"github.com/elastic/beats/generator/common/beatgen"
)

func init() {
Expand Down Expand Up @@ -66,3 +56,19 @@ func Fields() error {
func Config() error {
return devtools.Config(devtools.AllConfigTypes, devtools.ConfigFileParams{}, ".")
}

// Clean cleans all generated files and build artifacts.
func Clean() error {
return devtools.Clean()
}

// Check formats code, updates generated content, check for common errors, and
// checks for any modified files.
func Check() {
common.Check()
}

// Fmt formats source code (.go and .py) and adds license headers.
func Fmt() {
common.Fmt()
}
41 changes: 25 additions & 16 deletions generator/metricbeat/{beat}/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,13 @@ import (
"github.com/magefile/mage/mg"

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

// mage:import
_ "github.com/elastic/beats/dev-tools/mage/target/common"
// mage:import
"github.com/elastic/beats/dev-tools/mage/target/build"
// 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
_ "github.com/elastic/beats/dev-tools/mage/target/integtest"
// mage:import
"github.com/elastic/beats/dev-tools/mage/target/collectors"
// mage:import
"github.com/elastic/beats/dev-tools/mage/target/common"
"github.com/elastic/beats/dev-tools/mage/target/pkg"
"github.com/elastic/beats/dev-tools/mage/target/update"
"github.com/elastic/beats/generator/common/beatgen"
metricbeat "github.com/elastic/beats/metricbeat/scripts/mage"
)

func init() {
Expand Down Expand Up @@ -93,3 +81,24 @@ func configYML() error {
}
return devtools.Config(devtools.AllConfigTypes, customDeps, ".")
}

// Clean cleans all generated files and build artifacts.
func Clean() error {
return devtools.Clean()
}

// Check formats code, updates generated content, check for common errors, and
// checks for any modified files.
func Check() {
common.Check()
}

// Fmt formats source code (.go and .py) and adds license headers.
func Fmt() {
common.Fmt()
}

// Update updates the generated files (aka make update).
func Update() error {
return update.Update()
}

0 comments on commit 08e3c18

Please sign in to comment.