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

basic: allow one or more when param list having choices #34537

Merged
merged 4 commits into from Feb 8, 2018
Merged

basic: allow one or more when param list having choices #34537

merged 4 commits into from Feb 8, 2018

Conversation

resmo
Copy link
Contributor

@resmo resmo commented Jan 6, 2018

SUMMARY

Allow one or more when type='list' with choices.

e.g.

TASK [test_vr_user : test fail param not in choices] ****************************************************************************************************************************
fatal: [localhost -> localhost]: FAILED! => {"attempts": 1, "changed": false, "msg": "value of acls must be one or more of: manage_users, subscriptions, provisioning, billing, support, abuse, dns, upgrade, got: ['bad', 'dns', 'manage_users']"}
ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

basic

ANSIBLE VERSION
2.5
ADDITIONAL INFORMATION

@ansibot ansibot added affects_2.5 This issue/PR affects Ansible v2.5 feature_pull_request needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jan 6, 2018
@gundalow
Copy link
Contributor

gundalow commented Jan 6, 2018

Oh, nice. If we want this we should add unit test.
Remind me that I need to dig out my draft docs for basic.py.

@dagwieers
Copy link
Member

dagwieers commented Jan 8, 2018

This is a duplicate of #31637 :-)

PS #31637 includes tests.

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 8, 2018
@gundalow gundalow removed the needs_triage Needs a first human triage before being processed. label Jan 8, 2018
@resmo
Copy link
Contributor Author

resmo commented Jan 8, 2018

lol, ok :)

@resmo resmo closed this Jan 8, 2018
@resmo resmo reopened this Jan 8, 2018
@ansibot ansibot added the test This PR relates to tests. label Jan 8, 2018
@resmo

This comment has been minimized.

@ansibot

This comment has been minimized.

@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Jan 8, 2018
@gundalow
Copy link
Contributor

@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?

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Jan 16, 2018
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])
Copy link
Member

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.

@dagwieers
Copy link
Member

Well, that's the original implementation here: https://github.com/ansible/ansible/pull/31637/files#diff-90085fdcec6ed8b273ba885eaee60328R1758

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 7, 2018
@nitzmahone
Copy link
Member

rebuild_merge

@@ -157,7 +157,7 @@
except ImportError:
pass

from ansible.module_utils.pycompat24 import get_exception, literal_eval
Copy link
Member

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

@ansibot

This comment has been minimized.

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Feb 8, 2018
* a number of existing modules expect to be able to get it from basic.py
@nitzmahone
Copy link
Member

rebuild_merge

@nitzmahone
Copy link
Member

unrelated CI issues; merging

@nitzmahone nitzmahone merged commit 2f36b9e into ansible:devel Feb 8, 2018
dagwieers added a commit to dagwieers/ansible that referenced this pull request Feb 9, 2018
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
dagwieers added a commit that referenced this pull request Feb 9, 2018
This PR includes:
- Fixes related to the recent merge of #31637 and #34537
- A generic fix for a reference for assignment issue
- Fixes to aci.boolean() in order to catch exception
nitzmahone pushed a commit that referenced this pull request Feb 16, 2018
This PR includes:
- Fixes related to the recent merge of #31637 and #34537
- A generic fix for a reference for assignment issue
- Fixes to aci.boolean() in order to catch exception
(cherry picked from commit 01ba3a4)
@ansibot ansibot added feature This issue/PR relates to a feature request. and removed feature_pull_request labels Mar 5, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 feature This issue/PR relates to a feature request. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants