Skip to content

Commit

Permalink
Set ElasticLicensed for enabling wildcard support.
Browse files Browse the repository at this point in the history
Pulling in changes from elastic/beats#22521
  • Loading branch information
simitt committed Nov 12, 2020
1 parent 56afc07 commit af9df7f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 8 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,25 @@ 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",
},
IndexManagement: idxmgmt.MakeDefaultSupporter,
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)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion x-pack/apm-server/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit af9df7f

Please sign in to comment.