[8.x](backport #41277) refactor beats argument parsing #41373
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Change beats argument parsing behavior.
Beats currently sets some command line flags in an init function, this means that any other project that imports beats will have conflicts if it uses the same options. This change moves this out of init.
Beats currently modifies the Argument list to offer backwards compatibility for flags in an init function. This would convert flags like
-e
to--e
. This means if any other project imports beats, it's argument parsing would be changed. This change adds an allowed list of arguments that can be changed and moves it out of init.Beats currently detects if it is
fleet managed
by looking at the command line flags. This change keeps that behavior, but adds the ability to set this directly. This allows setting the flag without the command line option.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
The goal is none, however if any flags are missed, then the user would have to call them as
--flag
instead of-flag
.Author's Checklist
elastic-agent
(main elastic agent, beats built from this PR, policy had auditd and system metrics)elastic-agent
(main elastic-agent, importing beats and implementing filebeat receiver, beats builts from this PR, policy had auditd and system metrics). Verified filebeatreceiver worked, normal agentbeat worked and that-1s
could be passed as an argument to--fleet-server-timeout
apm-server
. Built apm-server using this PR, had to make changes tointernal/beatcmd/beat.go
andinternal/beatcmd/reloader.go
. This was expected for change to uuidv5 and storage of the reload registry. Also had to upgrade to badgerv4, also expected, but may be a breaking change. Tested thatapm-server -E management.enabled=true -E logging.to_stderr=true
still worked as expected. No changes were required to apm-server argument parsing.How to test this PR locally
Related issues
Use cases
Screenshots
Logs
This is an automatic backport of pull request #41277 done by [Mergify](https://mergify.com).