From 837733b4c23208cc1840cb7a9c3f084c295314d5 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 9 Feb 2023 16:25:26 +0100 Subject: [PATCH] Fix deprecation handling. (#572) (#573) (cherry picked from commit 70c4585b88779a27861a60c55258cc47d5141f70) Co-authored-by: Felix Fontein --- changelogs/fragments/572-action-module.yml | 2 ++ plugins/plugin_utils/action_module.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/572-action-module.yml diff --git a/changelogs/fragments/572-action-module.yml b/changelogs/fragments/572-action-module.yml new file mode 100644 index 00000000..86e6ad64 --- /dev/null +++ b/changelogs/fragments/572-action-module.yml @@ -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)." diff --git a/plugins/plugin_utils/action_module.py b/plugins/plugin_utils/action_module.py index ea7ecc78..3cea94c2 100644 --- a/plugins/plugin_utils/action_module.py +++ b/plugins/plugin_utils/action_module.py @@ -144,9 +144,14 @@ class AnsibleActionModule(object): # warnings and deprecations that do not work in plugins. This is a copy of that code adjusted # for our use-case: for d in self._validation_result._deprecations: - self.deprecate( - "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')) + # Before ansible-core 2.14.2, deprecations were always for aliases: + if 'name' in d: + self.deprecate( + "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')) + # 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: self.warn('Both option {option} and its alias {alias} are set.'.format(option=w['option'], alias=w['alias']))