diff --git a/cmd/root.go b/cmd/root.go index 037d0920331..eda0dcd68f4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -74,14 +74,14 @@ var libbeatConfigOverrides = []cfgfile.ConditionalOverride{{ }, } -// NewRootCommand returns the "apm-server" root command. -func NewRootCommand(newBeat beat.Creator) *cmd.BeatsRootCmd { - var runFlags = pflag.NewFlagSet(beatName, pflag.ExitOnError) - settings := instance.Settings{ +// DefaultSettings return the default settings for APM Server to pass into +// the GenRootCmdWithSettings. +func DefaultSettings() instance.Settings { + return instance.Settings{ Name: beatName, IndexPrefix: apmIndexPattern, Version: defaultBeatVersion, - RunFlags: runFlags, + RunFlags: pflag.NewFlagSet(beatName, pflag.ExitOnError), Monitoring: report.Settings{ DefaultUsername: "apm_system", }, @@ -89,7 +89,10 @@ func NewRootCommand(newBeat beat.Creator) *cmd.BeatsRootCmd { Processing: processing.MakeDefaultObserverSupport(false), ConfigOverrides: libbeatConfigOverrides, } +} +// NewRootCommand returns the "apm-server" root command. +func NewRootCommand(newBeat beat.Creator, settings instance.Settings) *cmd.BeatsRootCmd { rootCmd := cmd.GenRootCmdWithSettings(newBeat, settings) rootCmd.AddCommand(genApikeyCmd(settings)) modifyBuiltinCommands(rootCmd, settings) diff --git a/main.go b/main.go index 6b539245033..514f33ec3cb 100644 --- a/main.go +++ b/main.go @@ -27,7 +27,7 @@ import ( "github.com/elastic/apm-server/cmd" ) -var rootCmd = cmd.NewRootCommand(beater.NewCreator(beater.CreatorParams{})) +var rootCmd = cmd.NewRootCommand(beater.NewCreator(beater.CreatorParams{}), cmd.DefaultSettings()) func main() { if err := rootCmd.Execute(); err != nil { diff --git a/x-pack/apm-server/cmd/root.go b/x-pack/apm-server/cmd/root.go index b79745d62c2..4355a1c71e3 100644 --- a/x-pack/apm-server/cmd/root.go +++ b/x-pack/apm-server/cmd/root.go @@ -15,7 +15,9 @@ import ( // NewXPackRootCommand returns the Elastic licensed "apm-server" root command. func NewXPackRootCommand(newBeat beat.Creator) *libbeatcmd.BeatsRootCmd { - rootCmd := cmd.NewRootCommand(newBeat) + settings := cmd.DefaultSettings() + settings.ElasticLicensed = true + rootCmd := cmd.NewRootCommand(newBeat, settings) xpackcmd.AddXPack(rootCmd, rootCmd.Name()) if enrollCmd, _, err := rootCmd.Find([]string{"enroll"}); err == nil { // error is ok => enroll has already been removed