Fix deprecation handling. (#572)

pull/576/head
Felix Fontein 2023-02-09 15:36:23 +01:00 committed by GitHub
parent aea3713484
commit 70c4585b88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- "action plugin helper - fix handling of deprecations for ansible-core 2.14.2 (https://github.com/ansible-collections/community.crypto/pull/572)."

View File

@ -145,9 +145,14 @@ class AnsibleActionModule(object):
# warnings and deprecations that do not work in plugins. This is a copy of that code adjusted # warnings and deprecations that do not work in plugins. This is a copy of that code adjusted
# for our use-case: # for our use-case:
for d in self._validation_result._deprecations: for d in self._validation_result._deprecations:
# Before ansible-core 2.14.2, deprecations were always for aliases:
if 'name' in d:
self.deprecate( self.deprecate(
"Alias '{name}' is deprecated. See the module docs for more information".format(name=d['name']), "Alias '{name}' is deprecated. See the module docs for more information".format(name=d['name']),
version=d.get('version'), date=d.get('date'), collection_name=d.get('collection_name')) version=d.get('version'), date=d.get('date'), collection_name=d.get('collection_name'))
# Since ansible-core 2.14.2, a message is present that can be directly printed:
if 'msg' in d:
self.deprecate(d['msg'], version=d.get('version'), date=d.get('date'), collection_name=d.get('collection_name'))
for w in self._validation_result._warnings: for w in self._validation_result._warnings:
self.warn('Both option {option} and its alias {alias} are set.'.format(option=w['option'], alias=w['alias'])) self.warn('Both option {option} and its alias {alias} are set.'.format(option=w['option'], alias=w['alias']))