From 1715a5d57c0cb314a966f56723de3431a6db4af6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 14:30:41 +0000 Subject: [PATCH] Revert "add flag.Parse so HandlFlags works correctly (#14214)" (#14292) (#14314) This reverts commit 7efa6d5. Require beats bump / revert #14310 (8.x: #14309 ) Part of #14280 (cherry picked from commit 01237c435cb7dab24cf40838ee6bbb7ade34ec70) Co-authored-by: Carson Ip --- cmd/apm-server/main.go | 1 - internal/beatcmd/init.go | 4 +--- x-pack/apm-server/main.go | 1 - x-pack/apm-server/root_test.go | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/cmd/apm-server/main.go b/cmd/apm-server/main.go index 30a4789c57e..72244c3d3d3 100644 --- a/cmd/apm-server/main.go +++ b/cmd/apm-server/main.go @@ -25,7 +25,6 @@ import ( ) func main() { - beatcmd.InitBeatCmd() rootCmd := beatcmd.NewRootCommand(beatcmd.BeatParams{ NewRunner: func(args beatcmd.RunnerParams) (beatcmd.Runner, error) { return beater.NewRunner(beater.RunnerParams{ diff --git a/internal/beatcmd/init.go b/internal/beatcmd/init.go index 2ccecda29f5..bbf657006ac 100644 --- a/internal/beatcmd/init.go +++ b/internal/beatcmd/init.go @@ -19,7 +19,6 @@ package beatcmd import ( cryptorand "crypto/rand" - "flag" "log" "math" "math/big" @@ -39,7 +38,7 @@ import ( _ "github.com/elastic/beats/v7/libbeat/publisher/queue/memqueue" ) -func InitBeatCmd() { +func init() { initRand() initFlags() } @@ -63,7 +62,6 @@ func initFlags() { } } - flag.Parse() if err := cfgfile.HandleFlags(); err != nil { log.Fatal(err) } diff --git a/x-pack/apm-server/main.go b/x-pack/apm-server/main.go index 6c5a4666603..893681c966a 100644 --- a/x-pack/apm-server/main.go +++ b/x-pack/apm-server/main.go @@ -275,7 +275,6 @@ func cleanup() error { } func Main() error { - beatcmd.InitBeatCmd() rootCmd := newXPackRootCommand( func(args beatcmd.RunnerParams) (beatcmd.Runner, error) { return beater.NewRunner(beater.RunnerParams{ diff --git a/x-pack/apm-server/root_test.go b/x-pack/apm-server/root_test.go index d916a0e73f8..39fbf2aa30d 100644 --- a/x-pack/apm-server/root_test.go +++ b/x-pack/apm-server/root_test.go @@ -13,7 +13,6 @@ import ( ) func TestSubCommands(t *testing.T) { - beatcmd.InitBeatCmd() rootCmd := newXPackRootCommand(func(beatcmd.RunnerParams) (beatcmd.Runner, error) { panic("unexpected call") })