Skip to content

Commit

Permalink
Fix deprecation handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Feb 9, 2023
1 parent 29fafb9 commit 82d1ef0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/136-action-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "action plugin helper - fix handling of deprecations for ansible-core 2.14.2 (https://github.com/ansible-collections/community.sops/pull/136)."
11 changes: 8 additions & 3 deletions plugins/plugin_utils/action_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,14 @@ def __init__(self, action_plugin, argument_spec, bypass_checks=False,
# 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']))
Expand Down

0 comments on commit 82d1ef0

Please sign in to comment.