Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for arbitrary key 'context' in argument spec (#82183)
* Allow for arbitrary key 'context' in argument spec
- Loading branch information
Showing
6 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
minor_changes: | ||
- module argument spec - Allow module authors to include arbitrary additional context in the argument spec, by making use of a new top level key | ||
called ``context``. This key should be a dict type. This allows for users to customize what they place in the argument spec, without having to | ||
ignore sanity tests that validate the schema. |
36 changes: 36 additions & 0 deletions
36
...ate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_extra_key.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/python | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import annotations | ||
|
||
DOCUMENTATION = ''' | ||
module: invalid_argument_spec_extra_key | ||
short_description: Invalid argument spec extra key schema test module | ||
description: Invalid argument spec extra key schema test module | ||
author: | ||
- Ansible Core Team | ||
options: | ||
foo: | ||
description: foo | ||
type: str | ||
''' | ||
|
||
EXAMPLES = '''#''' | ||
RETURN = '''''' | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
|
||
|
||
def main(): | ||
AnsibleModule( | ||
argument_spec=dict( | ||
foo=dict( | ||
type='str', | ||
extra_key='bar', | ||
), | ||
), | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
36 changes: 36 additions & 0 deletions
36
...les/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_incorrect_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/python | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import annotations | ||
|
||
DOCUMENTATION = ''' | ||
module: invalid_argument_spec_incorrect_context | ||
short_description: Invalid argument spec incorrect context schema test module | ||
description: Invalid argument spec incorrect context schema test module | ||
author: | ||
- Ansible Core Team | ||
options: | ||
foo: | ||
description: foo | ||
type: str | ||
''' | ||
|
||
EXAMPLES = '''#''' | ||
RETURN = '''''' | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
|
||
|
||
def main(): | ||
AnsibleModule( | ||
argument_spec=dict( | ||
foo=dict( | ||
type='str', | ||
context='bar', | ||
), | ||
), | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
38 changes: 38 additions & 0 deletions
38
...alidate-modules/ansible_collections/ns/col/plugins/modules/valid_argument_spec_context.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/python | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
from __future__ import annotations | ||
|
||
DOCUMENTATION = ''' | ||
module: valid_argument_spec_context | ||
short_description: Valid argument spec context schema test module | ||
description: Valid argument spec context schema test module | ||
author: | ||
- Ansible Core Team | ||
options: | ||
foo: | ||
description: foo | ||
type: str | ||
''' | ||
|
||
EXAMPLES = '''#''' | ||
RETURN = '''''' | ||
|
||
from ansible.module_utils.basic import AnsibleModule | ||
|
||
|
||
def main(): | ||
AnsibleModule( | ||
argument_spec=dict( | ||
foo=dict( | ||
type='str', | ||
context=dict( | ||
extra_key='bar', | ||
), | ||
), | ||
), | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters