Skip to content
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

Open
wants to merge 2 commits into
base: devel
from

Conversation

Projects
None yet
2 participants
@felixfontein
Copy link
Contributor

felixfontein commented Mar 12, 2019

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:

 - argtest:
      l: 1,2,3
      lalias: 1,2,3,4
      x:
        y: 1
        yy: 2

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 in

 [WARNING]: Both option l and its alias lalias are set.
 [WARNING]: Both option x.y and its alias x.yy are set.
ISSUE TYPE
  • Bugfix Pull Request
  • Feature Pull Request
COMPONENT NAME

lib/ansible/module_utils/basic.py
lib/ansible/module_utils/common/parameters.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.