diff --git a/libbeat/cmd/root.go b/libbeat/cmd/root.go index 14cb068a2d34..2702ba32f57a 100644 --- a/libbeat/cmd/root.go +++ b/libbeat/cmd/root.go @@ -50,7 +50,6 @@ type BeatsRootCmd struct { ExportCmd *cobra.Command TestCmd *cobra.Command KeystoreCmd *cobra.Command - EnrollCmd *cobra.Command } // GenRootCmd returns the root command to use for your beat. It takes @@ -87,7 +86,6 @@ func GenRootCmdWithIndexPrefixWithRunFlags(name, indexPrefix, version string, be rootCmd.ExportCmd = genExportCmd(name, indexPrefix, version) rootCmd.TestCmd = genTestCmd(name, version, beatCreator) rootCmd.KeystoreCmd = genKeystoreCmd(name, indexPrefix, version, runFlags) - rootCmd.EnrollCmd = genEnrollCmd(name, version) // Root command is an alias for run rootCmd.Run = rootCmd.RunCmd.Run @@ -119,7 +117,6 @@ func GenRootCmdWithIndexPrefixWithRunFlags(name, indexPrefix, version string, be rootCmd.AddCommand(rootCmd.ExportCmd) rootCmd.AddCommand(rootCmd.TestCmd) rootCmd.AddCommand(rootCmd.KeystoreCmd) - rootCmd.AddCommand(rootCmd.EnrollCmd) return rootCmd } diff --git a/x-pack/auditbeat/cmd/root.go b/x-pack/auditbeat/cmd/root.go index 24a64781a3d5..682c61362b40 100644 --- a/x-pack/auditbeat/cmd/root.go +++ b/x-pack/auditbeat/cmd/root.go @@ -4,11 +4,14 @@ package cmd -import "github.com/elastic/beats/auditbeat/cmd" +import ( + "github.com/elastic/beats/auditbeat/cmd" + xpackcmd "github.com/elastic/beats/x-pack/libbeat/cmd" +) // RootCmd to handle beats cli var RootCmd = cmd.RootCmd func init() { - // TODO inject x-pack features + xpackcmd.AddXPack(RootCmd, cmd.Name) } diff --git a/x-pack/filebeat/cmd/root.go b/x-pack/filebeat/cmd/root.go index dd76fced042f..781b473bb5a1 100644 --- a/x-pack/filebeat/cmd/root.go +++ b/x-pack/filebeat/cmd/root.go @@ -4,11 +4,14 @@ package cmd -import "github.com/elastic/beats/filebeat/cmd" +import ( + "github.com/elastic/beats/filebeat/cmd" + xpackcmd "github.com/elastic/beats/x-pack/libbeat/cmd" +) // RootCmd to handle beats cli var RootCmd = cmd.RootCmd func init() { - // TODO inject x-pack features + xpackcmd.AddXPack(RootCmd, cmd.Name) } diff --git a/x-pack/heartbeat/cmd/root.go b/x-pack/heartbeat/cmd/root.go index 61146591b513..154d2cf7dcf3 100644 --- a/x-pack/heartbeat/cmd/root.go +++ b/x-pack/heartbeat/cmd/root.go @@ -4,11 +4,14 @@ package cmd -import "github.com/elastic/beats/heartbeat/cmd" +import ( + "github.com/elastic/beats/heartbeat/cmd" + xpackcmd "github.com/elastic/beats/x-pack/libbeat/cmd" +) // RootCmd to handle beats cli var RootCmd = cmd.RootCmd func init() { - // TODO inject x-pack features + xpackcmd.AddXPack(RootCmd, cmd.Name) } diff --git a/libbeat/cmd/enroll.go b/x-pack/libbeat/cmd/enroll.go similarity index 80% rename from libbeat/cmd/enroll.go rename to x-pack/libbeat/cmd/enroll.go index e2a82db003eb..e07c2ae2e4af 100644 --- a/libbeat/cmd/enroll.go +++ b/x-pack/libbeat/cmd/enroll.go @@ -1,3 +1,7 @@ +// 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 ( @@ -8,7 +12,7 @@ import ( "github.com/elastic/beats/libbeat/cmd/instance" "github.com/elastic/beats/libbeat/common/cli" - "github.com/elastic/beats/libbeat/management" + "github.com/elastic/beats/x-pack/libbeat/management" ) func getBeat(name, version string) (*instance.Beat, error) { diff --git a/x-pack/libbeat/cmd/inject.go b/x-pack/libbeat/cmd/inject.go new file mode 100644 index 000000000000..2a60409321f0 --- /dev/null +++ b/x-pack/libbeat/cmd/inject.go @@ -0,0 +1,12 @@ +// 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/libbeat/cmd" + +// AddXPack extends the given root folder with XPack features +func AddXPack(root *cmd.BeatsRootCmd, name string) { + root.AddCommand(genEnrollCmd(name, "")) +} diff --git a/libbeat/management/api/client.go b/x-pack/libbeat/management/api/client.go similarity index 89% rename from libbeat/management/api/client.go rename to x-pack/libbeat/management/api/client.go index 4c2e12eea48a..54c836958e76 100644 --- a/libbeat/management/api/client.go +++ b/x-pack/libbeat/management/api/client.go @@ -1,3 +1,7 @@ +// 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 api import ( diff --git a/libbeat/management/api/client_test.go b/x-pack/libbeat/management/api/client_test.go similarity index 72% rename from libbeat/management/api/client_test.go rename to x-pack/libbeat/management/api/client_test.go index 891cf28f67de..1222e21f1923 100644 --- a/libbeat/management/api/client_test.go +++ b/x-pack/libbeat/management/api/client_test.go @@ -1,3 +1,7 @@ +// 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 api import ( diff --git a/libbeat/management/api/enroll.go b/x-pack/libbeat/management/api/enroll.go similarity index 76% rename from libbeat/management/api/enroll.go rename to x-pack/libbeat/management/api/enroll.go index 2a4ddd54313f..4d73dbf76d5d 100644 --- a/libbeat/management/api/enroll.go +++ b/x-pack/libbeat/management/api/enroll.go @@ -1,3 +1,7 @@ +// 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 api import ( diff --git a/libbeat/management/api/enroll_test.go b/x-pack/libbeat/management/api/enroll_test.go similarity index 87% rename from libbeat/management/api/enroll_test.go rename to x-pack/libbeat/management/api/enroll_test.go index 7d793e2b6c4d..5ee1c9bf02e2 100644 --- a/libbeat/management/api/enroll_test.go +++ b/x-pack/libbeat/management/api/enroll_test.go @@ -1,3 +1,7 @@ +// 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 api import ( diff --git a/libbeat/management/config.go b/x-pack/libbeat/management/config.go similarity index 84% rename from libbeat/management/config.go rename to x-pack/libbeat/management/config.go index 68cc027870d9..8d92b8a20fce 100644 --- a/libbeat/management/config.go +++ b/x-pack/libbeat/management/config.go @@ -1,3 +1,7 @@ +// 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 management import ( diff --git a/libbeat/management/enroll.go b/x-pack/libbeat/management/enroll.go similarity index 73% rename from libbeat/management/enroll.go rename to x-pack/libbeat/management/enroll.go index 2bd1c0d24747..c610b9115a1f 100644 --- a/libbeat/management/enroll.go +++ b/x-pack/libbeat/management/enroll.go @@ -1,8 +1,12 @@ +// 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 management import ( "github.com/elastic/beats/libbeat/cmd/instance" - "github.com/elastic/beats/libbeat/management/api" + "github.com/elastic/beats/x-pack/libbeat/management/api" ) // Enroll this beat to the given kibana diff --git a/x-pack/metricbeat/cmd/root.go b/x-pack/metricbeat/cmd/root.go index fc086b2340a4..8a26219bb4e7 100644 --- a/x-pack/metricbeat/cmd/root.go +++ b/x-pack/metricbeat/cmd/root.go @@ -4,11 +4,14 @@ package cmd -import "github.com/elastic/beats/metricbeat/cmd" +import ( + "github.com/elastic/beats/metricbeat/cmd" + xpackcmd "github.com/elastic/beats/x-pack/libbeat/cmd" +) // RootCmd to handle beats cli var RootCmd = cmd.RootCmd func init() { - // TODO inject x-pack features + xpackcmd.AddXPack(RootCmd, cmd.Name) } diff --git a/x-pack/packetbeat/cmd/root.go b/x-pack/packetbeat/cmd/root.go index 904eb99dac89..1ddfbdcfd1b7 100644 --- a/x-pack/packetbeat/cmd/root.go +++ b/x-pack/packetbeat/cmd/root.go @@ -4,11 +4,14 @@ package cmd -import "github.com/elastic/beats/packetbeat/cmd" +import ( + "github.com/elastic/beats/packetbeat/cmd" + xpackcmd "github.com/elastic/beats/x-pack/libbeat/cmd" +) // RootCmd to handle beats cli var RootCmd = cmd.RootCmd func init() { - // TODO inject x-pack features + xpackcmd.AddXPack(RootCmd, cmd.Name) } diff --git a/x-pack/winlogbeat/cmd/root.go b/x-pack/winlogbeat/cmd/root.go index 5a7236a07d40..b1da4f69a547 100644 --- a/x-pack/winlogbeat/cmd/root.go +++ b/x-pack/winlogbeat/cmd/root.go @@ -4,11 +4,14 @@ package cmd -import "github.com/elastic/beats/winlogbeat/cmd" +import ( + "github.com/elastic/beats/winlogbeat/cmd" + xpackcmd "github.com/elastic/beats/x-pack/libbeat/cmd" +) // RootCmd to handle beats cli var RootCmd = cmd.RootCmd func init() { - // TODO inject x-pack features + xpackcmd.AddXPack(RootCmd, cmd.Name) }