Skip to content

Commit

Permalink
Revert "[Heartbeat] Add Magefile to X-Pack (elastic#20549)"
Browse files Browse the repository at this point in the history
This reverts commit d036955.
  • Loading branch information
jsoriano committed Aug 11, 2020
1 parent 7dc49ec commit cd7c245
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 181 deletions.
36 changes: 30 additions & 6 deletions heartbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

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

devtools "github.com/elastic/beats/v7/dev-tools/mage"
"github.com/elastic/beats/v7/generator/common/beatgen"
Expand Down Expand Up @@ -94,7 +95,7 @@ func Package() {
defer func() { fmt.Println("package ran for", time.Since(start)) }()

devtools.UseElasticBeatPackaging()
heartbeat.CustomizePackaging()
customizePackaging()

mg.Deps(Update)
mg.Deps(CrossBuild, CrossBuildXPack, CrossBuildGoDaemon)
Expand All @@ -106,13 +107,14 @@ func TestPackages() error {
return devtools.TestPackages(devtools.WithMonitorsD())
}

func Fields() error {
return heartbeat.Fields()
// Update updates the generated files (aka make update).
func Update() error {
return sh.Run("make", "update")
}

// Update updates the generated files (aka make update).
func Update() {
mg.SerialDeps(Fields, Config)
// Fields generates a fields.yml for the Beat.
func Fields() error {
return devtools.GenerateFieldsYAML("monitors/active")
}

// Imports generates an include/list.go file containing
Expand All @@ -125,6 +127,28 @@ func Imports() error {
return devtools.GenerateIncludeListGo(options)
}

func customizePackaging() {
monitorsDTarget := "monitors.d"
unixMonitorsDir := "/etc/{{.BeatName}}/monitors.d"
monitorsD := devtools.PackageFile{
Mode: 0644,
Source: "monitors.d",
}

for _, args := range devtools.Packages {
pkgType := args.Types[0]
switch pkgType {
case devtools.Docker:
args.Spec.ExtraVar("linux_capabilities", "cap_net_raw=eip")
args.Spec.Files[monitorsDTarget] = monitorsD
case devtools.TarGz, devtools.Zip:
args.Spec.Files[monitorsDTarget] = monitorsD
case devtools.Deb, devtools.RPM, devtools.DMG:
args.Spec.Files[unixMonitorsDir] = monitorsD
}
}
}

// Config generates both the short/reference/docker configs.
func Config() error {
return devtools.Config(devtools.AllConfigTypes, heartbeat.ConfigFileParams(), ".")
Expand Down
55 changes: 0 additions & 55 deletions heartbeat/scripts/mage/package.go

This file was deleted.

119 changes: 0 additions & 119 deletions x-pack/heartbeat/magefile.go

This file was deleted.

1 change: 0 additions & 1 deletion x-pack/heartbeat/main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package main

// This file is mandatory as otherwise the heartbeat.test binary is not generated correctly.
Expand Down

0 comments on commit cd7c245

Please sign in to comment.