From 76c06c811ec84e6186a35824d0820e655c0c972a Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Wed, 29 May 2019 12:27:19 -0500 Subject: [PATCH] [Heartbeat] Remove not needed flags from setup command Backport of #11856 to 6.8 The setup command until now contained all the possible options from the other Beats. As Heartbeat does not ship anymore with dashboards, the --dashboards command is not needed anymore and is only confusing. I also removed all the other commands except --ilm-policy and --template. I'm not aware that --pipelines or --machine-learning would be used. Here the comparison between ./heartbeat setup -h from before and after. --- heartbeat/cmd/root.go | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/heartbeat/cmd/root.go b/heartbeat/cmd/root.go index 0ffda01644e..2c23ee37b19 100644 --- a/heartbeat/cmd/root.go +++ b/heartbeat/cmd/root.go @@ -19,14 +19,36 @@ package cmd import ( // register default heartbeat monitors - _ "github.com/elastic/beats/heartbeat/monitors/defaults" - "github.com/elastic/beats/heartbeat/beater" - cmd "github.com/elastic/beats/libbeat/cmd" + _ "github.com/elastic/beats/heartbeat/monitors/defaults" + "github.com/elastic/beats/libbeat/cmd" + "github.com/elastic/beats/libbeat/cmd/instance" ) // Name of this beat var Name = "heartbeat" // RootCmd to handle beats cli -var RootCmd = cmd.GenRootCmd(Name, "", beater.New) +var RootCmd *cmd.BeatsRootCmd + +func init() { + RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: Name}) + + // remove dashboard from export commands + for _, cmd := range RootCmd.ExportCmd.Commands() { + if cmd.Name() == "dashboard" { + RootCmd.ExportCmd.RemoveCommand(cmd) + } + } + + // only add defined flags to setup command + setup := RootCmd.SetupCmd + setup.Short = "Setup Elasticsearch index template and pipelines" + setup.Long = `This command does initial setup of the environment: + * Index mapping template in Elasticsearch to ensure fields are mapped. + * ILM Policy +` + setup.ResetFlags() + setup.Flags().Bool("template", false, "Setup index template") + setup.Flags().Bool("ilm-policy", false, "Setup ILM policy") +}