From 328d5e858fb497137541f927b92099de92696e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20P=C3=A9rez-Aradros=20Herce?= Date: Fri, 27 Jul 2018 17:59:03 +0200 Subject: [PATCH] Build Elastic licensed beats separately This commit implements the necessary logic to build licensed beats, before that commit, the OSS and the License binaries were exactly the same. Changes: - Added `mage.CrossBuildXPack()` to build the elastic licensed beat. x-pack/beatname - Changed the packages.yml to include the artifact from the x-pack folder. - Added `mage.UseElasticBeatPackaging()` to build the packages with the new binaries. - Added `mage.UseElasticBeatWithoutXPackPackaging()` allow to keep the previous behavior. - `make check` and `make fmt` will use the right license for the x-pack folder. Co-authored-by: Pier-Hugues Pellerin --- CHANGELOG-developer.asciidoc | 1 + Makefile | 6 ++- auditbeat/magefile.go | 7 ++- dev-tools/mage/clean.go | 4 ++ dev-tools/mage/crossbuild.go | 58 ++++++++++++++++------ dev-tools/mage/pkg.go | 2 +- dev-tools/mage/pkgspecs.go | 20 ++++++++ dev-tools/packaging/packages.yml | 83 ++++++++++++++++++++++++++++++++ filebeat/magefile.go | 7 ++- heartbeat/magefile.go | 7 ++- metricbeat/magefile.go | 7 ++- packetbeat/magefile.go | 30 +++++++++--- winlogbeat/magefile.go | 7 ++- x-pack/.gitignore | 2 + x-pack/auditbeat/cmd/root.go | 14 ++++++ x-pack/auditbeat/main.go | 24 +++++++++ x-pack/filebeat/cmd/root.go | 14 ++++++ x-pack/filebeat/main.go | 25 ++++++++++ x-pack/heartbeat/cmd/root.go | 14 ++++++ x-pack/heartbeat/main.go | 19 ++++++++ x-pack/metricbeat/cmd/root.go | 14 ++++++ x-pack/metricbeat/main.go | 24 +++++++++ x-pack/packetbeat/cmd/root.go | 14 ++++++ x-pack/packetbeat/main.go | 18 +++++++ x-pack/winlogbeat/cmd/root.go | 14 ++++++ x-pack/winlogbeat/main.go | 26 ++++++++++ 26 files changed, 431 insertions(+), 30 deletions(-) create mode 100644 x-pack/.gitignore create mode 100644 x-pack/auditbeat/cmd/root.go create mode 100644 x-pack/auditbeat/main.go create mode 100644 x-pack/filebeat/cmd/root.go create mode 100644 x-pack/filebeat/main.go create mode 100644 x-pack/heartbeat/cmd/root.go create mode 100644 x-pack/heartbeat/main.go create mode 100644 x-pack/metricbeat/cmd/root.go create mode 100644 x-pack/metricbeat/main.go create mode 100644 x-pack/packetbeat/cmd/root.go create mode 100644 x-pack/packetbeat/main.go create mode 100644 x-pack/winlogbeat/cmd/root.go create mode 100644 x-pack/winlogbeat/main.go diff --git a/CHANGELOG-developer.asciidoc b/CHANGELOG-developer.asciidoc index b17a363eca42..74aecefbad1c 100644 --- a/CHANGELOG-developer.asciidoc +++ b/CHANGELOG-developer.asciidoc @@ -44,3 +44,4 @@ The list below covers the major changes between 6.3.0 and master only. 'go test'. This captures the log to a file, summarizes the result, produces a coverage profile (.cov), and produces an HTML coverage report. See `mage -h goTestUnit`. {pull}7766[7766] +- Beats packaging now build non-oss binaries from code located in the x-pack folder. {issue}7783[7783] diff --git a/Makefile b/Makefile index 45f140790252..1d53eadb1016 100644 --- a/Makefile +++ b/Makefile @@ -84,12 +84,14 @@ check: python-env .PHONY: check-headers check-headers: @go get github.com/elastic/go-licenser - @go-licenser -d + @go-licenser -d -exclude x-pack + @go-licenser -d -license Elastic x-pack .PHONY: add-headers add-headers: @go get github.com/elastic/go-licenser - @go-licenser + @go-licenser -exclude x-pack + @go-licenser -license Elastic x-pack # Corrects spelling errors .PHONY: misspell diff --git a/auditbeat/magefile.go b/auditbeat/magefile.go index 21f3f98032ac..cdad957603fd 100644 --- a/auditbeat/magefile.go +++ b/auditbeat/magefile.go @@ -57,6 +57,11 @@ func CrossBuild() error { return mage.CrossBuild() } +// CrossBuildXPack cross-builds the beat with XPack for all target platforms. +func CrossBuildXPack() error { + return mage.CrossBuildXPack() +} + // CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. func CrossBuildGoDaemon() error { return mage.CrossBuildGoDaemon() @@ -78,7 +83,7 @@ func Package() { customizePackaging() mg.Deps(Update) - mg.Deps(makeConfigTemplates, CrossBuild, CrossBuildGoDaemon) + mg.Deps(makeConfigTemplates, CrossBuild, CrossBuildXPack, CrossBuildGoDaemon) mg.SerialDeps(mage.Package, TestPackages) } diff --git a/dev-tools/mage/clean.go b/dev-tools/mage/clean.go index 912d372e1dff..2f170e9e5056 100644 --- a/dev-tools/mage/clean.go +++ b/dev-tools/mage/clean.go @@ -35,6 +35,10 @@ 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. diff --git a/dev-tools/mage/crossbuild.go b/dev-tools/mage/crossbuild.go index 4a41cde08017..4ce927b409b0 100644 --- a/dev-tools/mage/crossbuild.go +++ b/dev-tools/mage/crossbuild.go @@ -63,6 +63,13 @@ 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) { @@ -75,6 +82,7 @@ type crossBuildParams struct { Platforms BuildPlatformList Target string Serial bool + InDir string } // CrossBuild executes a given build target once for each target platform. @@ -103,8 +111,7 @@ 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} + builder := GolangCrossBuilder{buildPlatform.Name, params.Target, params.InDir} if params.Serial { if err := builder.Build(); err != nil { return errors.Wrapf(err, "failed cross-building target=%v for platform=%v", @@ -120,6 +127,15 @@ 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 @@ -166,6 +182,7 @@ func crossBuildImage(platform string) (string, error) { type GolangCrossBuilder struct { Platform string Target string + InDir string } // Build executes the build inside of Docker. @@ -178,9 +195,16 @@ func (b GolangCrossBuilder) Build() error { } mountPoint := filepath.ToSlash(filepath.Join("/go", "src", repoInfo.RootImportPath)) - workDir := mountPoint - if repoInfo.SubDir != "" { - workDir = filepath.ToSlash(filepath.Join(workDir, repoInfo.SubDir)) + // 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") } dockerRun := sh.RunCmd("docker", "run") @@ -206,7 +230,7 @@ func (b GolangCrossBuilder) Build() error { "-v", repoInfo.RootDir+":"+mountPoint, "-w", workDir, image, - "--build-cmd", "build/mage-linux-amd64 "+b.Target, + "--build-cmd", buildCmd+" "+b.Target, "-p", b.Platform, ) @@ -215,25 +239,27 @@ 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(file string) { +func DockerChown(path 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, file); err != nil { + if err := chownPaths(uid, gid, path); err != nil { log.Println(err) } } } // chownPaths will chown the file and all of the dirs specified in the path. -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) +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 } - } - return nil + 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) + } + return err + }) } diff --git a/dev-tools/mage/pkg.go b/dev-tools/mage/pkg.go index c98d3236ea32..6334f4d388fa 100644 --- a/dev-tools/mage/pkg.go +++ b/dev-tools/mage/pkg.go @@ -37,7 +37,7 @@ func Package() error { if len(Packages) == 0 { return errors.New("no package specs are registered. Call " + - "UseCommunityBeatPackaging or UseElasticBeatPackaging first.") + "UseCommunityBeatPackaging, UseElasticBeatPackaging or USeElasticBeatWithoutXPackPackaging first.") } var tasks []interface{} diff --git a/dev-tools/mage/pkgspecs.go b/dev-tools/mage/pkgspecs.go index 11dda2e49f7d..20767d9a4297 100644 --- a/dev-tools/mage/pkgspecs.go +++ b/dev-tools/mage/pkgspecs.go @@ -62,6 +62,26 @@ func UseElasticBeatPackaging() { } } +// UseElasticBeatWithoutXPackPackaging configures the package target to build packages for +// an Elastic Beat. This means it will generate two sets of packages -- one +// that is purely OSS under Apache 2.0 and one that is licensed under the +// Elastic License and may contain additional X-Pack features. +// +// NOTE: This method doesn't use binaries produced in the x-pack folder, this is +// a temporary packaging target for projects that depends on beat but do have concrete x-pack +// binaries. +func UseElasticBeatWithoutXPackPackaging() { + beatsDir, err := ElasticBeatsDir() + if err != nil { + panic(err) + } + + err = LoadNamedSpec("elastic_beat_without_xpack", filepath.Join(beatsDir, packageSpecFile)) + if err != nil { + panic(err) + } +} + // LoadNamedSpec loads a packaging specification with the given name from the // specified YAML file. name should be a sub-key of 'specs'. func LoadNamedSpec(name, file string) error { diff --git a/dev-tools/packaging/packages.yml b/dev-tools/packaging/packages.yml index c4394162032a..33504fe59f7e 100644 --- a/dev-tools/packaging/packages.yml +++ b/dev-tools/packaging/packages.yml @@ -229,6 +229,78 @@ specs: spec: <<: *deb_rpm_spec + elastic_beat_without_xpack: + ### + # OSS Packages + ### + - os: windows + types: [zip] + spec: + <<: *windows_binary_spec + <<: *apache_license_for_binaries + name: '{{.BeatName}}-oss' + + - os: darwin + types: [tgz] + spec: + <<: *binary_spec + <<: *apache_license_for_binaries + name: '{{.BeatName}}-oss' + + - os: darwin + types: [dmg] + spec: + <<: *macos_beat_pkg_spec + <<: *apache_license_for_macos_pkg + name: '{{.BeatName}}-oss' + + - os: linux + types: [tgz] + spec: + <<: *binary_spec + <<: *apache_license_for_binaries + name: '{{.BeatName}}-oss' + + - os: linux + types: [deb, rpm] + spec: + <<: *deb_rpm_spec + <<: *apache_license_for_deb_rpm + name: '{{.BeatName}}-oss' + + ### + # Elastic Licensed Packages + ### + - os: windows + types: [zip] + spec: + <<: *windows_binary_spec + <<: *elastic_license_for_binaries + + - os: darwin + types: [tgz] + spec: + <<: *binary_spec + <<: *elastic_license_for_binaries + + - os: darwin + types: [dmg] + spec: + <<: *macos_beat_pkg_spec + <<: *elastic_license_for_macos_pkg + + - os: linux + types: [tgz] + spec: + <<: *binary_spec + <<: *elastic_license_for_binaries + + - os: linux + types: [deb, rpm] + spec: + <<: *deb_rpm_spec + <<: *elastic_license_for_deb_rpm + # Official Beats elastic_beat: ### @@ -277,12 +349,17 @@ specs: spec: <<: *windows_binary_spec <<: *elastic_license_for_binaries + '{{.BeatName}}{{.BinaryExt}}': + source: ../x-pack/{{.BeatName}}/build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} - os: darwin types: [tgz] spec: <<: *binary_spec <<: *elastic_license_for_binaries + files: + /Library/Application Support/{{.BeatVendor}}/{{.BeatName}}/bin/{{.BeatName}}{{.BinaryExt}}: + source: ../x-pack/{{.BeatName}}/build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} - os: darwin types: [dmg] @@ -295,9 +372,15 @@ specs: spec: <<: *binary_spec <<: *elastic_license_for_binaries + files: + '{{.BeatName}}{{.BinaryExt}}': + source: ../x-pack/{{.BeatName}}/build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} - os: linux types: [deb, rpm] spec: <<: *deb_rpm_spec <<: *elastic_license_for_deb_rpm + files: + /usr/share/{{.BeatName}}/bin/{{.BeatName}}{{.BinaryExt}}: + source: ../x-pack/{{.BeatName}}/build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} diff --git a/filebeat/magefile.go b/filebeat/magefile.go index 8bd078f6d51f..b17373ccb8e9 100644 --- a/filebeat/magefile.go +++ b/filebeat/magefile.go @@ -57,6 +57,11 @@ func CrossBuild() error { return mage.CrossBuild() } +// CrossBuildXPack cross-builds the beat with XPack for all target platforms. +func CrossBuildXPack() error { + return mage.CrossBuildXPack() +} + // CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. func CrossBuildGoDaemon() error { return mage.CrossBuildGoDaemon() @@ -78,7 +83,7 @@ func Package() { customizePackaging() mg.Deps(Update, prepareModulePackaging) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild, CrossBuildXPack, CrossBuildGoDaemon) mg.SerialDeps(mage.Package, TestPackages) } diff --git a/heartbeat/magefile.go b/heartbeat/magefile.go index 507ffc8c75c2..3c751e3effbb 100644 --- a/heartbeat/magefile.go +++ b/heartbeat/magefile.go @@ -57,6 +57,11 @@ func CrossBuild() error { return mage.CrossBuild() } +// CrossBuildXPack cross-builds the beat with XPack for all target platforms. +func CrossBuildXPack() error { + return mage.CrossBuildXPack() +} + // CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. func CrossBuildGoDaemon() error { return mage.CrossBuildGoDaemon() @@ -76,7 +81,7 @@ func Package() { mage.UseElasticBeatPackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild, CrossBuildXPack, CrossBuildGoDaemon) mg.SerialDeps(mage.Package, TestPackages) } diff --git a/metricbeat/magefile.go b/metricbeat/magefile.go index 43723b06280d..d09fb932fdc7 100644 --- a/metricbeat/magefile.go +++ b/metricbeat/magefile.go @@ -47,6 +47,11 @@ func GolangCrossBuild() error { return mage.GolangCrossBuild(mage.DefaultGolangCrossBuildArgs()) } +// CrossBuildXPack cross-builds the beat with XPack for all target platforms. +func CrossBuildXPack() error { + return mage.CrossBuildXPack() +} + // BuildGoDaemon builds the go-daemon binary (use crossBuildGoDaemon). func BuildGoDaemon() error { return mage.BuildGoDaemon() @@ -78,7 +83,7 @@ func Package() { customizePackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild, CrossBuildXPack, CrossBuildGoDaemon) mg.SerialDeps(mage.Package, TestPackages) } diff --git a/packetbeat/magefile.go b/packetbeat/magefile.go index 86e58a24f62d..686f4e28fae2 100644 --- a/packetbeat/magefile.go +++ b/packetbeat/magefile.go @@ -84,6 +84,22 @@ func CrossBuild() error { return mage.CrossBuild(mage.ForPlatforms("!windows")) } +// CrossBuildXPack cross-builds the beat with XPack for all target platforms. +func CrossBuildXPack() error { + mg.Deps(patchCGODirectives) + defer undoPatchCGODirectives() + + // These Windows builds write temporary .s and .o files into the packetbeat + // dir so they cannot be run in parallel. Changing to a different CWD does + // not change where the temp files get written so that cannot be used as a + // fix. + if err := mage.CrossBuildXPack(mage.ForPlatforms("windows"), mage.Serially()); err != nil { + return err + } + + return mage.CrossBuildXPack(mage.ForPlatforms("!windows")) +} + // CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. func CrossBuildGoDaemon() error { return mage.CrossBuildGoDaemon() @@ -105,7 +121,7 @@ func Package() { customizePackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild, CrossBuildXPack, CrossBuildGoDaemon) mg.SerialDeps(mage.Package, TestPackages) } @@ -348,20 +364,22 @@ func installWinpcap() error { func generateWin64StaticWinpcap() error { log.Println(">> Generating 64-bit winpcap static lib") + // Notes: We are using absolute path to make sure the files + // are available for x-pack build. // Ref: https://github.com/elastic/beats/issues/1259 - defer mage.DockerChown("lib/windows-64/wpcap.def") + defer mage.DockerChown(mage.MustExpand("{{elastic_beats_dir}}/{{.BeatName}}/lib")) return mage.RunCmds( // Requires mingw-w64-tools. - []string{"gendef", "lib/windows-64/wpcap.dll"}, - []string{"mv", "wpcap.def", "lib/windows-64/wpcap.def"}, + []string{"gendef", mage.MustExpand("{{elastic_beats_dir}}/{{.BeatName}}/lib/windows-64/wpcap.dll")}, + []string{"mv", "wpcap.def", mage.MustExpand("{{ elastic_beats_dir}}/{{.BeatName}}/lib/windows-64/wpcap.def")}, []string{"x86_64-w64-mingw32-dlltool", "--as-flags=--64", "-m", "i386:x86-64", "-k", "--output-lib", "/libpcap/win/WpdPack/Lib/x64/libwpcap.a", - "--input-def", "lib/windows-64/wpcap.def"}, + "--input-def", mage.MustExpand("{{elastic_beats_dir}}/{{.BeatName}}/lib/windows-64/wpcap.def")}, ) } -const pcapGoFile = "../vendor/github.com/tsg/gopacket/pcap/pcap.go" +var pcapGoFile = mage.MustExpand("{{elastic_beats_dir}}/vendor/github.com/tsg/gopacket/pcap/pcap.go") var cgoDirectiveRegex = regexp.MustCompile(`(?m)#cgo .*(?:LDFLAGS|CFLAGS).*$`) diff --git a/winlogbeat/magefile.go b/winlogbeat/magefile.go index ad93f4feda77..d9f2ecd9f9a9 100644 --- a/winlogbeat/magefile.go +++ b/winlogbeat/magefile.go @@ -57,6 +57,11 @@ func CrossBuild() error { return mage.CrossBuild() } +// CrossBuildXPack cross-builds the beat with XPack for all target platforms. +func CrossBuildXPack() error { + return mage.CrossBuildXPack() +} + // CrossBuildGoDaemon cross-builds the go-daemon binary using Docker. func CrossBuildGoDaemon() error { return mage.CrossBuildGoDaemon() @@ -76,7 +81,7 @@ func Package() { mage.UseElasticBeatPackaging() mg.Deps(Update) - mg.Deps(CrossBuild, CrossBuildGoDaemon) + mg.Deps(CrossBuild, CrossBuildXPack, CrossBuildGoDaemon) mg.SerialDeps(mage.Package, TestPackages) } diff --git a/x-pack/.gitignore b/x-pack/.gitignore new file mode 100644 index 000000000000..8de00a22385c --- /dev/null +++ b/x-pack/.gitignore @@ -0,0 +1,2 @@ +# Directories +*/build diff --git a/x-pack/auditbeat/cmd/root.go b/x-pack/auditbeat/cmd/root.go new file mode 100644 index 000000000000..24a64781a3d5 --- /dev/null +++ b/x-pack/auditbeat/cmd/root.go @@ -0,0 +1,14 @@ +// 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 cmd + +import "github.com/elastic/beats/auditbeat/cmd" + +// RootCmd to handle beats cli +var RootCmd = cmd.RootCmd + +func init() { + // TODO inject x-pack features +} diff --git a/x-pack/auditbeat/main.go b/x-pack/auditbeat/main.go new file mode 100644 index 000000000000..c731b367cc3b --- /dev/null +++ b/x-pack/auditbeat/main.go @@ -0,0 +1,24 @@ +// 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 + +import ( + "os" + + "github.com/elastic/beats/x-pack/auditbeat/cmd" + + // Register modules. + _ "github.com/elastic/beats/auditbeat/module/auditd" + _ "github.com/elastic/beats/auditbeat/module/file_integrity" + + // Register includes. + _ "github.com/elastic/beats/auditbeat/include" +) + +func main() { + if err := cmd.RootCmd.Execute(); err != nil { + os.Exit(1) + } +} diff --git a/x-pack/filebeat/cmd/root.go b/x-pack/filebeat/cmd/root.go new file mode 100644 index 000000000000..dd76fced042f --- /dev/null +++ b/x-pack/filebeat/cmd/root.go @@ -0,0 +1,14 @@ +// 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 cmd + +import "github.com/elastic/beats/filebeat/cmd" + +// RootCmd to handle beats cli +var RootCmd = cmd.RootCmd + +func init() { + // TODO inject x-pack features +} diff --git a/x-pack/filebeat/main.go b/x-pack/filebeat/main.go new file mode 100644 index 000000000000..e0c4b4ac26e6 --- /dev/null +++ b/x-pack/filebeat/main.go @@ -0,0 +1,25 @@ +// 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 + +import ( + "os" + + "github.com/elastic/beats/x-pack/filebeat/cmd" +) + +// The basic model of execution: +// - input: finds files in paths/globs to harvest, starts harvesters +// - harvester: reads a file, sends events to the spooler +// - spooler: buffers events until ready to flush to the publisher +// - publisher: writes to the network, notifies registrar +// - registrar: records positions of files read +// Finally, input uses the registrar information, on restart, to +// determine where in each file to restart a harvester. +func main() { + if err := cmd.RootCmd.Execute(); err != nil { + os.Exit(1) + } +} diff --git a/x-pack/heartbeat/cmd/root.go b/x-pack/heartbeat/cmd/root.go new file mode 100644 index 000000000000..61146591b513 --- /dev/null +++ b/x-pack/heartbeat/cmd/root.go @@ -0,0 +1,14 @@ +// 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 cmd + +import "github.com/elastic/beats/heartbeat/cmd" + +// RootCmd to handle beats cli +var RootCmd = cmd.RootCmd + +func init() { + // TODO inject x-pack features +} diff --git a/x-pack/heartbeat/main.go b/x-pack/heartbeat/main.go new file mode 100644 index 000000000000..a619fe9d3d82 --- /dev/null +++ b/x-pack/heartbeat/main.go @@ -0,0 +1,19 @@ +// 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 + +import ( + "os" + + "github.com/elastic/beats/x-pack/heartbeat/cmd" + + _ "github.com/elastic/beats/heartbeat/include" +) + +func main() { + if err := cmd.RootCmd.Execute(); err != nil { + os.Exit(1) + } +} diff --git a/x-pack/metricbeat/cmd/root.go b/x-pack/metricbeat/cmd/root.go new file mode 100644 index 000000000000..fc086b2340a4 --- /dev/null +++ b/x-pack/metricbeat/cmd/root.go @@ -0,0 +1,14 @@ +// 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 cmd + +import "github.com/elastic/beats/metricbeat/cmd" + +// RootCmd to handle beats cli +var RootCmd = cmd.RootCmd + +func init() { + // TODO inject x-pack features +} diff --git a/x-pack/metricbeat/main.go b/x-pack/metricbeat/main.go new file mode 100644 index 000000000000..6deaf0fbeacc --- /dev/null +++ b/x-pack/metricbeat/main.go @@ -0,0 +1,24 @@ +// 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 metricbeat contains the entrypoint to Metricbeat which is a lightweight +data shipper for operating system and service metrics. It ships events directly +to Elasticsearch or Logstash. The data can then be visualized in Kibana. + +Downloads: https://www.elastic.co/downloads/beats/metricbeat +*/ +package main + +import ( + "os" + + "github.com/elastic/beats/x-pack/metricbeat/cmd" +) + +func main() { + if err := cmd.RootCmd.Execute(); err != nil { + os.Exit(1) + } +} diff --git a/x-pack/packetbeat/cmd/root.go b/x-pack/packetbeat/cmd/root.go new file mode 100644 index 000000000000..904eb99dac89 --- /dev/null +++ b/x-pack/packetbeat/cmd/root.go @@ -0,0 +1,14 @@ +// 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 cmd + +import "github.com/elastic/beats/packetbeat/cmd" + +// RootCmd to handle beats cli +var RootCmd = cmd.RootCmd + +func init() { + // TODO inject x-pack features +} diff --git a/x-pack/packetbeat/main.go b/x-pack/packetbeat/main.go new file mode 100644 index 000000000000..3d7f9946044b --- /dev/null +++ b/x-pack/packetbeat/main.go @@ -0,0 +1,18 @@ +// 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 + +import ( + "os" + + "github.com/elastic/beats/x-pack/packetbeat/cmd" +) + +// Setups and Runs Packetbeat +func main() { + if err := cmd.RootCmd.Execute(); err != nil { + os.Exit(1) + } +} diff --git a/x-pack/winlogbeat/cmd/root.go b/x-pack/winlogbeat/cmd/root.go new file mode 100644 index 000000000000..5a7236a07d40 --- /dev/null +++ b/x-pack/winlogbeat/cmd/root.go @@ -0,0 +1,14 @@ +// 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 cmd + +import "github.com/elastic/beats/winlogbeat/cmd" + +// RootCmd to handle beats cli +var RootCmd = cmd.RootCmd + +func init() { + // TODO inject x-pack features +} diff --git a/x-pack/winlogbeat/main.go b/x-pack/winlogbeat/main.go new file mode 100644 index 000000000000..54e3654bf330 --- /dev/null +++ b/x-pack/winlogbeat/main.go @@ -0,0 +1,26 @@ +// 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 winlogbeat contains the entrypoint to Winlogbeat which is a lightweight +data shipper for Windows event logs. It ships events directly to Elasticsearch +or Logstash. The data can then be visualized in Kibana. + +Downloads: https://www.elastic.co/downloads/beats/winlogbeat +*/ +package main + +import ( + "os" + + _ "github.com/elastic/beats/winlogbeat/include" + + "github.com/elastic/beats/x-pack/winlogbeat/cmd" +) + +func main() { + if err := cmd.RootCmd.Execute(); err != nil { + os.Exit(1) + } +}