Skip to content

Commit

Permalink
Update beats framework to 8f170ac
Browse files Browse the repository at this point in the history
* partially reverts #1301 since mage goTestUnit has not been backported yet
  • Loading branch information
graphaelli committed Sep 11, 2018
1 parent 27dee6f commit 13dced6
Show file tree
Hide file tree
Showing 175 changed files with 1,443 additions and 5,933 deletions.
8 changes: 4 additions & 4 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--------------------------------------------------------------------
Dependency: github.com/elastic/beats
Version: master
Revision: 9828935bb1896ea620a77a328a351fd6e828112f
Version: 6.x
Revision: 8f170ac2dabbb528d437354db7c52b8fcacd1bab
License type (autodetected): Apache-2.0
./vendor/github.com/elastic/beats/LICENSE.txt:
--------------------------------------------------------------------
Expand Down Expand Up @@ -325,7 +325,7 @@ Elasticsearch, B.V. (https://www.elastic.co/).

--------------------------------------------------------------------
Dependency: github.com/elastic/go-structform
Revision: 1425975cf4eb470099fcf02cbe9389cf3a7028a3
Revision: 0a66add879601f69f55663f4c913c72988218982
License type (autodetected): Apache-2.0
./vendor/github.com/elastic/go-structform/LICENSE:
--------------------------------------------------------------------
Expand Down Expand Up @@ -1026,7 +1026,7 @@ THE SOFTWARE.

--------------------------------------------------------------------
Dependency: github.com/jstemmer/go-junit-report
Revision: 385fac0ced9acaae6dc5b39144194008ded00697
Revision: 9828935bb1896ea620a77a328a351fd6e828112f
License type (autodetected): MIT
./vendor/github.com/jstemmer/go-junit-report/LICENSE:
--------------------------------------------------------------------
Expand Down
15 changes: 3 additions & 12 deletions _beats/dev-tools/cmd/asset/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,18 @@ import (
"os"

"github.com/elastic/beats/libbeat/asset"
"github.com/elastic/beats/licenses"
)

var (
pkg string
input string
output string
license = "ASL2"
pkg string
input string
output string
)

func init() {
flag.StringVar(&pkg, "pkg", "", "Package name")
flag.StringVar(&input, "in", "-", "Source of input. \"-\" means reading from stdin")
flag.StringVar(&output, "out", "-", "Output path. \"-\" means writing to stdout")
flag.StringVar(&license, "license", "ASL2", "License header for generated file.")
}

func main() {
Expand Down Expand Up @@ -85,17 +82,11 @@ func main() {
os.Exit(1)
}

licenseHeader, err := licenses.Find(license)
if err != nil {
fmt.Fprintf(os.Stderr, "Invalid license: %s\n", err)
os.Exit(1)
}
var buf bytes.Buffer
asset.Template.Execute(&buf, asset.Data{
Beat: beatName,
Name: file,
Data: encData,
License: licenseHeader,
Package: pkg,
})

Expand Down
96 changes: 0 additions & 96 deletions _beats/dev-tools/cmd/license/license_generate.go

This file was deleted.

6 changes: 1 addition & 5 deletions _beats/dev-tools/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,10 @@ jenkins_setup() {
: "${HOME:?Need to set HOME to a non-empty value.}"
: "${WORKSPACE:?Need to set WORKSPACE to a non-empty value.}"

if [ -z ${GO_VERSION:-} ]; then
get_go_version
fi

# Setup Go.
export GOPATH=${WORKSPACE}
export PATH=${GOPATH}/bin:${PATH}
eval "$(gvm ${GO_VERSION})"
eval "$(gvm $(cat .go-version))"

# Workaround for Python virtualenv path being too long.
export TEMP_PYTHON_ENV=$(mktemp -d)
Expand Down
4 changes: 0 additions & 4 deletions _beats/dev-tools/mage/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ var DefaultCleanPaths = []string{
"_meta/kibana.generated",
"_meta/kibana/5/index-pattern/{{.BeatName}}.json",
"_meta/kibana/6/index-pattern/{{.BeatName}}.json",

"../x-pack/{{.BeatName}}/build",
"../x-pack/{{.BeatName}}/{{.BeatName}}",
"../x-pack/{{.BeatName}}/{{.BeatName}}.exe",
}

// Clean clean generated build artifacts.
Expand Down
58 changes: 16 additions & 42 deletions _beats/dev-tools/mage/crossbuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ func WithTarget(target string) func(params *crossBuildParams) {
}
}

// InDir specifies the base directory to use when cross-building.
func InDir(path ...string) func(params *crossBuildParams) {
return func(params *crossBuildParams) {
params.InDir = filepath.Join(path...)
}
}

// Serially causes each cross-build target to be executed serially instead of
// in parallel.
func Serially() func(params *crossBuildParams) {
Expand All @@ -82,7 +75,6 @@ type crossBuildParams struct {
Platforms BuildPlatformList
Target string
Serial bool
InDir string
}

// CrossBuild executes a given build target once for each target platform.
Expand Down Expand Up @@ -111,7 +103,8 @@ func CrossBuild(options ...CrossBuildOption) error {
if !buildPlatform.Flags.CanCrossBuild() {
return fmt.Errorf("unsupported cross build platform %v", buildPlatform.Name)
}
builder := GolangCrossBuilder{buildPlatform.Name, params.Target, params.InDir}

builder := GolangCrossBuilder{buildPlatform.Name, params.Target}
if params.Serial {
if err := builder.Build(); err != nil {
return errors.Wrapf(err, "failed cross-building target=%v for platform=%v",
Expand All @@ -127,15 +120,6 @@ func CrossBuild(options ...CrossBuildOption) error {
return nil
}

// CrossBuildXPack executes the 'golangCrossBuild' target in the Beat's
// associated x-pack directory to produce a version of the Beat that contains
// Elastic licensed content.
func CrossBuildXPack(options ...CrossBuildOption) error {
o := []CrossBuildOption{InDir("x-pack", BeatName)}
o = append(o, options...)
return CrossBuild(o...)
}

// buildMage pre-compiles the magefile to a binary using the native GOOS/GOARCH
// values for Docker. This is required to so that we can later pass GOOS and
// GOARCH to mage for the cross-build. It has the benefit of speeding up the
Expand Down Expand Up @@ -182,7 +166,6 @@ func crossBuildImage(platform string) (string, error) {
type GolangCrossBuilder struct {
Platform string
Target string
InDir string
}

// Build executes the build inside of Docker.
Expand All @@ -195,16 +178,9 @@ func (b GolangCrossBuilder) Build() error {
}

mountPoint := filepath.ToSlash(filepath.Join("/go", "src", repoInfo.RootImportPath))
// use custom dir for build if given, subdir if not:
cwd := repoInfo.SubDir
if b.InDir != "" {
cwd = b.InDir
}
workDir := filepath.ToSlash(filepath.Join(mountPoint, cwd))

buildCmd, err := filepath.Rel(workDir, filepath.Join(mountPoint, repoInfo.SubDir, "build/mage-linux-amd64"))
if err != nil {
return errors.Wrap(err, "failed to determine mage-linux-amd64 relative path")
workDir := mountPoint
if repoInfo.SubDir != "" {
workDir = filepath.ToSlash(filepath.Join(workDir, repoInfo.SubDir))
}

dockerRun := sh.RunCmd("docker", "run")
Expand All @@ -230,7 +206,7 @@ func (b GolangCrossBuilder) Build() error {
"-v", repoInfo.RootDir+":"+mountPoint,
"-w", workDir,
image,
"--build-cmd", buildCmd+" "+b.Target,
"--build-cmd", "build/mage-linux-amd64 "+b.Target,
"-p", b.Platform,
)

Expand All @@ -239,27 +215,25 @@ func (b GolangCrossBuilder) Build() error {

// DockerChown chowns files generated during build. EXEC_UID and EXEC_GID must
// be set in the containers environment otherwise this is a noop.
func DockerChown(path string) {
func DockerChown(file string) {
// Chown files generated during build that are root owned.
uid, _ := strconv.Atoi(EnvOr("EXEC_UID", "-1"))
gid, _ := strconv.Atoi(EnvOr("EXEC_GID", "-1"))
if uid > 0 && gid > 0 {
if err := chownPaths(uid, gid, path); err != nil {
if err := chownPaths(uid, gid, file); err != nil {
log.Println(err)
}
}
}

// chownPaths will chown the file and all of the dirs specified in the path.
func chownPaths(uid, gid int, path string) error {
return filepath.Walk(path, func(name string, _ os.FileInfo, err error) error {
if err != nil {
return err
}
log.Printf("chown line: %s\n", name)
if err := os.Chown(name, uid, gid); err != nil {
return errors.Wrapf(err, "failed to chown path=%v", name)
func chownPaths(uid, gid int, file string) error {
pathParts := strings.Split(file, string(filepath.Separator))
for i := range pathParts {
chownDir := filepath.Join(pathParts[:i+1]...)
if err := os.Chown(chownDir, uid, gid); err != nil {
return errors.Wrapf(err, "failed to chown path=%v", chownDir)
}
return err
})
}
return nil
}
Loading

0 comments on commit 13dced6

Please sign in to comment.