Don't mix deprecations messages with warnings messages (#21337)

* Remove unused attribute '_passthrough'

* Don't mix deprecations with warnings

* Return values: add 'deprecations' key used internally

* 'deprecations' and 'warnings' return values: add tests
This commit is contained in:
Pilou 2017-02-14 05:49:39 +01:00 committed by Brian Coca
parent d54bc09fae
commit f2c22109fb
3 changed files with 81 additions and 3 deletions

View file

@ -689,7 +689,6 @@ class AnsibleModule(object):
self.run_command_environ_update = {}
self._warnings = []
self._deprecations = []
self._passthrough = ['warnings', 'deprecations']
self.aliases = {}
self._legal_inputs = ['_ansible_check_mode', '_ansible_no_log', '_ansible_debug', '_ansible_diff', '_ansible_verbosity', '_ansible_selinux_special_fs', '_ansible_module_name', '_ansible_version', '_ansible_syslog_facility', '_ansible_socket']
@ -1949,15 +1948,19 @@ class AnsibleModule(object):
self.warn(w)
else:
self.warn(kwargs['warnings'])
if self._warnings:
kwargs['warnings'] = self._warnings
if 'deprecations' in kwargs:
if isinstance(kwargs['deprecations'], list):
for d in kwargs['deprecations']:
self.deprecate(d)
if isinstance(d, SEQUENCETYPE) and len(d) == 2:
self.deprecate(d[0], version=d[1])
else:
self.deprecate(d)
else:
self.warn(kwargs['deprecations'])
self.deprecate(d)
if self._deprecations:
kwargs['deprecations'] = self._deprecations