mirror of https://github.com/ansible/ansible.git
Allow for arbitrary key 'context' in argument spec (#82183)
* Allow for arbitrary key 'context' in argument specpull/82628/head
parent
7a0c321054
commit
e458cbac61
@ -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.
|
||||||
@ -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()
|
||||||
@ -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()
|
||||||
@ -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()
|
||||||
Loading…
Reference in New Issue