-
Notifications
You must be signed in to change notification settings - Fork 3.5k
cli: add hidden command-line flag for overriding settings #17582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
When invoking Logstsh in test, it is often necessary to override a setting, but cumbersome to provide a whole `logstash.yml` when there is no provided command-line option paired with the setting. This feature adds a _hidden_ `--setting` option with an `-S` shortname, whose value is a colon- or equals-separated key-value pair. - long-form single arg: `--setting=queue.type:persisted` - long-form arg-pair: `--setting node.name:myname` - short-form: `-Squeue.type=persisted` ~~~ arbitrary settings --setting=key:value formatted options when specifying `--setting=node.name:my-fancy-node-name --setting=api.enabled:false` overrides setting `node.name` to `my-fancy-node-name` overrides setting `api.enabled` to `false` when specifying `--setting=api.enabled:false` overrides setting `api.enabled` to `false` when specifying uncoercible `--setting=api.enabled:yellow` raises a helpful usage error about failed coercion when specifying unregistered `--setting=banana:yellow` raises a helpful usage error about the unknown setting when specifying `--setting=node.name:my-fancy-node-name` overrides setting `node.name` to `my-fancy-node-name` -Skey=value formatted options when specifying unregistered `-Sbanana=yellow` raises a helpful usage error about the unknown setting when specifying `-Snode.name=my-fancy-node-name -Sapi.enabled=false` overrides setting `node.name` to `my-fancy-node-name` overrides setting `api.enabled` to `false` when specifying uncoercible `-Sapi.enabled=yellow` raises a helpful usage error about failed coercion when specifying `-Snode.name=my-fancy-node-name` overrides setting `node.name` to `my-fancy-node-name` when specifying `-Sapi.enabled=false` overrides setting `api.enabled` to `false` --setting key:value formatted options when specifying `--setting api.enabled:false` overrides setting `api.enabled` to `false` when specifying `--setting node.name:my-fancy-node-name --setting api.enabled:false` overrides setting `api.enabled` to `false` overrides setting `node.name` to `my-fancy-node-name` when specifying unregistered `--setting banana:yellow` raises a helpful usage error about the unknown setting when specifying `--setting node.name:my-fancy-node-name` overrides setting `node.name` to `my-fancy-node-name` when specifying uncoercible `--setting api.enabled:yellow` raises a helpful usage error about failed coercion ~~~
This pull request does not have a backport label. Could you fix it @yaauie? 🙏
|
|
💛 Build succeeded, but was flaky
Failed CI Steps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🚀
Looks like this handles bool, numeric, string. Are more complex setting types handled? For example can |
Release notes
[rn: skip]
What does this PR do?
When invoking Logstash in test, it is often necessary to override a setting, but cumbersome to provide a whole
logstash.yml
(or to append specific overrides to a fixture-provided one) when there is no provided command-line option paired with the setting.This feature adds a hidden
--setting
option with an-S
shortname, whose value is a colon- or equals-separated key-value pair.--setting=queue.type:persisted
--setting node.name:myname
-Squeue.type=persisted
Why is it important/What is the impact to the user?
No user impact; improved testability.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files (and/or docker env variables)How to test this PR locally
Invoke logstash with any setting in any of the supported formats and observe that the modified setting value is in the debug output:
short-form
-Skey=value
:long-form arg pair
--setting key:value
:long-form single arg
--setting=key:value
:Invoke with a non-coercible value to observe a helpful error message:
Invoke with an unregistered setting name to observe a helpful error message:
Use cases
Simplifies testing by allowing integration test invocation to include any setting without needing to override the settings.yml that may or may not be provided by a fixture.
Logs