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
basic: allow one or more when param list having choices #34537
basic: allow one or more when param list having choices #34537
Conversation
Oh, nice. If we want this we should add unit test. |
lol, ok :) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@dagwieers This has unit tests, which I think area bit better suited, so I'm wondering if this is the better fit. Are you happy with the implementation in this PR? |
lib/ansible/module_utils/basic.py
Outdated
if isinstance(param[k], list): | ||
for item in param[k]: | ||
if item not in choices: | ||
choices_str = ", ".join([to_native(c) for c in choices]) |
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.
not a required change, but it seems a 'difference' comparison between lists would give you any passed params that are not valid choices in 1 shot and a single error message.
Well, that's the original implementation here: https://github.com/ansible/ansible/pull/31637/files#diff-90085fdcec6ed8b273ba885eaee60328R1758 |
rebuild_merge |
lib/ansible/module_utils/basic.py
Outdated
@@ -157,7 +157,7 @@ | |||
except ImportError: | |||
pass | |||
|
|||
from ansible.module_utils.pycompat24 import get_exception, literal_eval |
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.
I think this change might be the cause of all the import sanity test failures
This comment has been minimized.
This comment has been minimized.
* a number of existing modules expect to be able to get it from basic.py
rebuild_merge |
unrelated CI issues; merging |
This PR includes: - Fixes related to the recent merge of ansible#31637 and ansible#34537 - A generic fix for a reference for assignment issue - Fixes to aci.boolean() in order to catch exception
SUMMARY
Allow one or more when type='list' with choices.
e.g.
ISSUE TYPE
COMPONENT NAME
basic
ANSIBLE VERSION
ADDITIONAL INFORMATION