mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Deprecate check_invalid_arguments (#34004)
* Deprecate check_invalid_arguments Check_invalid_arguments is a piece of functionality from the early days of Ansible that should not be used. We'll remove it in Ansible 2.9. Deprecating it for now.
This commit is contained in:
parent
7bc754674c
commit
cc7a5228b0
6 changed files with 82 additions and 16 deletions
|
@ -135,7 +135,6 @@ def main():
|
|||
url=dict(required=False, default='https://api.bigpanda.io'),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
check_invalid_arguments=False,
|
||||
)
|
||||
|
||||
token = module.params['token']
|
||||
|
|
|
@ -101,8 +101,8 @@ options:
|
|||
- Any parameter starting with "HEADER_" is a sent with your request as a header.
|
||||
For example, HEADER_Content-Type="application/json" would send the header
|
||||
"Content-Type" along with your request with a value of "application/json".
|
||||
This option is deprecated as of C(2.1) and may be removed in a future
|
||||
release. Use I(headers) instead.
|
||||
This option is deprecated as of C(2.1) and will be removed in Ansible-2.9.
|
||||
Use I(headers) instead.
|
||||
headers:
|
||||
description:
|
||||
- Add custom HTTP headers to a request in the format of a YAML hash. As
|
||||
|
@ -386,6 +386,7 @@ def main():
|
|||
|
||||
module = AnsibleModule(
|
||||
argument_spec=argument_spec,
|
||||
# TODO: Remove check_invalid_arguments in 2.9
|
||||
check_invalid_arguments=False,
|
||||
add_file_common_args=True
|
||||
)
|
||||
|
@ -411,15 +412,16 @@ def main():
|
|||
if 'content-type' not in lower_header_keys:
|
||||
dict_headers['Content-Type'] = 'application/json'
|
||||
|
||||
# TODO: Deprecated section. Remove in Ansible 2.9
|
||||
# Grab all the http headers. Need this hack since passing multi-values is
|
||||
# currently a bit ugly. (e.g. headers='{"Content-Type":"application/json"}')
|
||||
for key, value in six.iteritems(module.params):
|
||||
if key.startswith("HEADER_"):
|
||||
module.deprecate('Supplying headers via HEADER_* is deprecated and '
|
||||
'will be removed in a future version. Please use '
|
||||
'`headers` to supply headers for the request')
|
||||
module.deprecate('Supplying headers via HEADER_* is deprecated. Please use `headers` to'
|
||||
' supply headers for the request', version='2.9')
|
||||
skey = key.replace("HEADER_", "")
|
||||
dict_headers[skey] = value
|
||||
# End deprecated section
|
||||
|
||||
if creates is not None:
|
||||
# do not run the command if the line contains creates=filename
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright: (c) 2013, Johan Wiren <johan.wiren.se@gmail.com>
|
||||
# Copyright: (c) 2017, Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
|
@ -35,8 +36,15 @@ options:
|
|||
- Snapshot from which to create a clone.
|
||||
key_value:
|
||||
description:
|
||||
- (**DEPRECATED**) This will be removed in Ansible-2.9. Set these values in the
|
||||
- C(extra_zfs_properties) option instead.
|
||||
- The C(zfs) module takes key=value pairs for zfs properties to be set.
|
||||
- See the zfs(8) man page for more information.
|
||||
extra_zfs_properties:
|
||||
description:
|
||||
- A dictionary of zfs properties to be set.
|
||||
- See the zfs(8) man page for more information.
|
||||
version_added: "2.5"
|
||||
author:
|
||||
- Johan Wiren (@johanwiren)
|
||||
'''
|
||||
|
@ -46,13 +54,15 @@ EXAMPLES = '''
|
|||
zfs:
|
||||
name: rpool/myfs
|
||||
state: present
|
||||
setuid: off
|
||||
extra_zfs_properties:
|
||||
setuid: off
|
||||
|
||||
- name: Create a new volume called myvol in pool rpool.
|
||||
zfs:
|
||||
name: rpool/myvol
|
||||
state: present
|
||||
volsize: 10M
|
||||
extra_zfs_properties:
|
||||
volsize: 10M
|
||||
|
||||
- name: Create a snapshot of rpool/myfs file system.
|
||||
zfs:
|
||||
|
@ -63,13 +73,15 @@ EXAMPLES = '''
|
|||
zfs:
|
||||
name: rpool/myfs2
|
||||
state: present
|
||||
snapdir: enabled
|
||||
extra_zfs_properties:
|
||||
snapdir: enabled
|
||||
|
||||
- name: Create a new file system by cloning a snapshot
|
||||
zfs:
|
||||
name: rpool/cloned_fs
|
||||
state: present
|
||||
origin: rpool/myfs@mysnapshot
|
||||
extra_zfs_properties:
|
||||
origin: rpool/myfs@mysnapshot
|
||||
|
||||
- name: Destroy a filesystem
|
||||
zfs:
|
||||
|
@ -216,22 +228,24 @@ def main():
|
|||
argument_spec=dict(
|
||||
name=dict(type='str', required=True),
|
||||
state=dict(type='str', required=True, choices=['absent', 'present']),
|
||||
# No longer used. Kept here to not interfere with zfs properties
|
||||
createparent=dict(type='bool'),
|
||||
# No longer used. Deprecated and due for removal
|
||||
createparent=dict(type='bool', default=None),
|
||||
extra_zfs_properties=dict(type='dict', default={}),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
# Remove this in Ansible 2.9
|
||||
check_invalid_arguments=False,
|
||||
)
|
||||
|
||||
state = module.params.pop('state')
|
||||
name = module.params.pop('name')
|
||||
|
||||
# The following is deprecated. Remove in Ansible 2.9
|
||||
# Get all valid zfs-properties
|
||||
properties = dict()
|
||||
for prop, value in module.params.items():
|
||||
# All freestyle params are zfs properties
|
||||
if prop not in module.argument_spec:
|
||||
# Reverse the boolification of freestyle zfs properties
|
||||
if isinstance(value, bool):
|
||||
if value is True:
|
||||
properties[prop] = 'on'
|
||||
|
@ -240,12 +254,33 @@ def main():
|
|||
else:
|
||||
properties[prop] = value
|
||||
|
||||
if properties:
|
||||
module.deprecate('Passing zfs properties as arbitrary parameters to the zfs module is'
|
||||
' deprecated. Send them as a dictionary in the extra_zfs_properties'
|
||||
' parameter instead.', version='2.9')
|
||||
# Merge, giving the module_params precedence
|
||||
for prop, value in module.params['extra_zfs_properties'].items():
|
||||
properties[prop] = value
|
||||
|
||||
module.params['extras_zfs_properties'] = properties
|
||||
# End deprecated section
|
||||
|
||||
# Reverse the boolification of zfs properties
|
||||
for prop, value in module.params['extra_zfs_properties'].items():
|
||||
if isinstance(value, bool):
|
||||
if value is True:
|
||||
module.params['extra_zfs_properties'][prop] = 'on'
|
||||
else:
|
||||
module.params['extra_zfs_properties'][prop] = 'off'
|
||||
else:
|
||||
module.params['extra_zfs_properties'][prop] = value
|
||||
|
||||
result = dict(
|
||||
name=name,
|
||||
state=state,
|
||||
)
|
||||
|
||||
zfs = Zfs(module, name, properties)
|
||||
zfs = Zfs(module, name, module.params['extra_zfs_properties'])
|
||||
|
||||
if state == 'present':
|
||||
if zfs.exists():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue