-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate fields.yml using Mage (#7670)
Make will now delegate to mage for generating fields.yml. Make will check if the mage command exists and go install it if not. The FIELDS_FILE_PATH make variable is not longer used because the path(s) are specified in magefile.go. This allows fields.yml to be generated on Windows using Mage. The CI scripts for Windows have been updated so that fields.yml is generated for all Beats during testing. This also adds a make.bat in each directory where building occurs to give Windows users a starting point. Some fixes were made to the generators because: - rsync was excluding important source files contained in a directory named "build" - the generated project needed to be `git init` before running certain magefile targets that detect project's root dir and import path.
- Loading branch information
1 parent
2b142fa
commit 5406745
Showing
36 changed files
with
317 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@echo off | ||
|
||
REM Windows wrapper for Mage (https://magefile.org/) that installs it | ||
REM to %GOPATH%\bin from the Beats vendor directory. | ||
REM | ||
REM After running this once you may invoke mage.exe directly. | ||
|
||
WHERE mage | ||
IF %ERRORLEVEL% NEQ 0 go install github.com/elastic/beats/vendor/github.com/magefile/mage | ||
|
||
mage %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package mage | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/magefile/mage/sh" | ||
) | ||
|
||
// GenerateFieldsYAML generates a fields.yml file for a Beat. This will include | ||
// the common fields specified by libbeat, the common fields for the Beat, | ||
// and any additional fields.yml files you specify. | ||
// | ||
// fieldsFiles specifies additional directories to search recursively for files | ||
// named fields.yml. The contents of each fields.yml will be included in the | ||
// generated file. | ||
func GenerateFieldsYAML(fieldsFiles ...string) error { | ||
const globalFieldsCmdPath = "libbeat/scripts/cmd/global_fields/main.go" | ||
|
||
beatsDir, err := ElasticBeatsDir() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
globalFieldsCmd := sh.RunCmd("go", "run", | ||
filepath.Join(beatsDir, globalFieldsCmdPath), | ||
"-es_beats_path", beatsDir, | ||
"-beat_path", CWD(), | ||
) | ||
|
||
return globalFieldsCmd(fieldsFiles...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
REM Batch script to build and test on Windows. You can use this in conjunction | ||
REM with the Vagrant machine. | ||
go build | ||
go test ./... | ||
go test -c -cover -covermode=count -coverpkg ./... | ||
cd tests\system | ||
nosetests | ||
@echo off | ||
|
||
REM Windows wrapper for Mage (https://magefile.org/) that installs it | ||
REM to %GOPATH%\bin from the Beats vendor directory. | ||
REM | ||
REM After running this once you may invoke mage.exe directly. | ||
|
||
WHERE mage | ||
IF %ERRORLEVEL% NEQ 0 go install github.com/elastic/beats/vendor/github.com/magefile/mage | ||
|
||
mage %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
override FIELDS_FILE_PATH= | ||
export FIELDS_FILE_PATH | ||
|
||
include ../common/Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@echo off | ||
|
||
REM Windows wrapper for Mage (https://magefile.org/) that installs it | ||
REM to %GOPATH%\bin from the Beats vendor directory. | ||
REM | ||
REM After running this once you may invoke mage.exe directly. | ||
|
||
WHERE mage | ||
IF %ERRORLEVEL% NEQ 0 go install {beat_path}/vendor/github.com/magefile/mage | ||
|
||
mage %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
BEAT_TYPE=metricbeat | ||
PREPARE_COMMAND=MODULE=elastic METRICSET=test make create-metricset ; FIELDS_FILE_PATH=module | ||
override FIELDS_FILE_PATH= | ||
export FIELDS_FILE_PATH | ||
|
||
BEAT_TYPE = metricbeat | ||
PREPARE_COMMAND = MODULE=elastic METRICSET=test make create-metricset; | ||
|
||
include ../common/Makefile | ||
|
||
.PHONY: prepare-test | ||
prepare-test:: python-env | ||
|
||
mkdir -p ${BEAT_PATH}/scripts | ||
rsync -a --exclude=build ${PWD}/../../metricbeat/scripts/generate_imports_helper.py ${BEAT_PATH}/scripts | ||
|
||
# Collects all dependencies and then calls update | ||
.PHONY: collect | ||
collect: fields | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@echo off | ||
|
||
REM Windows wrapper for Mage (https://magefile.org/) that installs it | ||
REM to %GOPATH%\bin from the Beats vendor directory. | ||
REM | ||
REM After running this once you may invoke mage.exe directly. | ||
|
||
WHERE mage | ||
IF %ERRORLEVEL% NEQ 0 go install {beat_path}/vendor/github.com/magefile/mage | ||
|
||
mage %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@echo off | ||
|
||
REM Windows wrapper for Mage (https://magefile.org/) that installs it | ||
REM to %GOPATH%\bin from the Beats vendor directory. | ||
REM | ||
REM After running this once you may invoke mage.exe directly. | ||
|
||
WHERE mage | ||
IF %ERRORLEVEL% NEQ 0 go install github.com/elastic/beats/vendor/github.com/magefile/mage | ||
|
||
mage %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
BEAT_NAME=libbeat | ||
TEST_ENVIRONMENT?=true | ||
SYSTEM_TESTS=true | ||
FIELDS_FILE_PATH=processors | ||
|
||
include scripts/Makefile | ||
|
||
|
Oops, something went wrong.
@andrewkroh @ruflin this also applies to apm-server, right?
will it make it to 6.4?