in magefile.go [236:295]
func PackageAgent() {
beatVersion, found := os.LookupEnv("BEAT_VERSION")
if !found {
beatVersion, _ = devtools.BeatQualifiedVersion()
}
// prepare new drop
dropPath := filepath.Join("build", "elastic-agent-drop")
dropPath, err := filepath.Abs(dropPath)
if err != nil {
panic(err)
}
if err := os.MkdirAll(dropPath, 0o755); err != nil {
panic(err)
}
os.Setenv(agentDropPath, dropPath)
// cleanup after build
defer os.RemoveAll(dropPath)
defer os.Unsetenv(agentDropPath)
platformPackages := []struct {
platform string
packages string
}{
{"darwin/amd64", "darwin-x86_64.tar.gz"},
{"darwin/arm64", "darwin-aarch64.tar.gz"},
{"linux/amd64", "linux-x86_64.tar.gz"},
{"linux/arm64", "linux-arm64.tar.gz"},
{"windows/amd64", "windows-x86_64.zip"},
}
var requiredPackages []string
for _, p := range platformPackages {
if _, enabled := devtools.Platforms.Get(p.platform); enabled {
requiredPackages = append(requiredPackages, p.packages)
}
}
packedBeats := []string{"filebeat", "heartbeat", "metricbeat", "osquerybeat"}
ctx := context.Background()
for _, beat := range packedBeats {
for _, reqPackage := range requiredPackages {
newVersion, packageName := getPackageName(beat, beatVersion, reqPackage)
err := fetchBinaryFromArtifactsApi(ctx, packageName, beat, newVersion, dropPath)
if err != nil {
panic(fmt.Sprintf("fetchBinaryFromArtifactsApi failed: %v", err))
}
}
}
mg.Deps(Package)
// copy to new drop
sourcePath := filepath.Join("build", "distributions")
if err := copyAll(sourcePath, dropPath); err != nil {
panic(err)
}
mg.Deps(bundleAgent)
}