-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Option parsing: warn if both an option and its alias are specified for a module #53698
Conversation
About the question on IRC on why |
inject the warnings directly into the 'warnings' list and you don't have to deal with log |
If it's ok that they're not sent to log, sure, that makes it a lot easier :-) |
1c8756e
to
a42adb9
Compare
The CI failures seem to be totally unrelated to this PR. ready_for_review |
7b7bc38
to
5ca5b4f
Compare
ready_for_review |
Re-triggering CI. |
@bcoca can you take another look? It has been a while... :) |
rebuild_merge |
bot_status |
Componentschangelogs/fragments/53698-alias-collision-warning.yaml lib/ansible/module_utils/basic.py lib/ansible/module_utils/common/parameters.py test/units/module_utils/basic/test_argument_spec.py Metadatawaiting_on: felixfontein |
@bcoca and everyone on IRC who helped with this: thanks for reviewing! |
SUMMARY
Currently, if both an option and its alias are provided in module options, the value of the alias overwrites the value of the option. (If multiple aliases of that option are specified, the last one appearing in the
aliases
list wins.)I think there should be a warning if that happens. This PR implements such a warning:
Example:
with
argument_spec=dict(l=dict(type='list', elements='int', aliases=['lalias']), x=dict(type='dict', options=dict(y=dict(type='str', aliases=['yy']))))
results inISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/basic.py
lib/ansible/module_utils/common/parameters.py