@@ -38,23 +38,28 @@ var Name = "heartbeat"
3838// RootCmd to handle beats cli
3939var RootCmd * cmd.BeatsRootCmd
4040
41- func init () {
42- settings := instance.Settings {
41+ // HeartbeatSettings contains the default settings for heartbeat
42+ func HeartbeatSettings () instance.Settings {
43+ return instance.Settings {
4344 Name : Name ,
4445 Processing : processing .MakeDefaultSupport (true , processing .WithECS , processing .WithAgentMeta ()),
4546 HasDashboards : false ,
4647 }
47- RootCmd = cmd .GenRootCmdWithSettings (beater .New , settings )
48+ }
49+
50+ // Initialize initializes the entrypoint commands for heartbeat
51+ func Initialize (settings instance.Settings ) * cmd.BeatsRootCmd {
52+ rootCmd := cmd .GenRootCmdWithSettings (beater .New , settings )
4853
4954 // remove dashboard from export commands
50- for _ , cmd := range RootCmd .ExportCmd .Commands () {
55+ for _ , cmd := range rootCmd .ExportCmd .Commands () {
5156 if cmd .Name () == "dashboard" {
52- RootCmd .ExportCmd .RemoveCommand (cmd )
57+ rootCmd .ExportCmd .RemoveCommand (cmd )
5358 }
5459 }
5560
5661 // only add defined flags to setup command
57- setup := RootCmd .SetupCmd
62+ setup := rootCmd .SetupCmd
5863 setup .Short = "Setup Elasticsearch index template and pipelines"
5964 setup .Long = `This command does initial setup of the environment:
6065 * Index mapping template in Elasticsearch to ensure fields are mapped.
@@ -66,4 +71,10 @@ func init() {
6671 setup .Flags ().MarkDeprecated (cmd .ILMPolicyKey , fmt .Sprintf ("use --%s instead" , cmd .IndexManagementKey ))
6772 setup .Flags ().Bool (cmd .TemplateKey , false , "Setup index template" )
6873 setup .Flags ().Bool (cmd .ILMPolicyKey , false , "Setup ILM policy" )
74+
75+ return rootCmd
76+ }
77+
78+ func init () {
79+ RootCmd = Initialize (HeartbeatSettings ())
6980}
0 commit comments