diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2023-09-29 20:19:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-29 20:19:16 +0200 |
commit | 4d4c50f856bf844ab47a08a2f64fc9697916b50f (patch) | |
tree | 15e3944db2724fae84243d457b72a91d14c47a64 | |
parent | Add count and mandatory_count parameters in regex_replace filter (#81775) (diff) | |
download | ansible-4d4c50f856bf844ab47a08a2f64fc9697916b50f.tar.xz ansible-4d4c50f856bf844ab47a08a2f64fc9697916b50f.zip |
Provide more info about plugin in deprecation message (#81719)
Provide more information about plugin usage which needs to be
used instead of the deprecated plugin in the deprecation message.
Fixes: #80561
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
-rw-r--r-- | changelogs/fragments/80561.yml | 3 | ||||
-rw-r--r-- | lib/ansible/plugins/loader.py | 10 | ||||
-rwxr-xr-x | test/integration/targets/collections/runme.sh | 3 |
3 files changed, 10 insertions, 6 deletions
diff --git a/changelogs/fragments/80561.yml b/changelogs/fragments/80561.yml new file mode 100644 index 0000000000..af8ce3f093 --- /dev/null +++ b/changelogs/fragments/80561.yml @@ -0,0 +1,3 @@ +--- +bugfixes: +- Provide additional information about the alternative plugin in the deprecation message (https://github.com/ansible/ansible/issues/80561). diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py index d8097f7fbf..dc0eb891a9 100644 --- a/lib/ansible/plugins/loader.py +++ b/lib/ansible/plugins/loader.py @@ -1173,24 +1173,22 @@ class Jinja2Loader(PluginLoader): # check deprecations deprecation_entry = routing_entry.get('deprecation') if deprecation_entry: - warning_text = deprecation_entry.get('warning_text') + warning_text = deprecation_entry.get('warning_text') or '' removal_date = deprecation_entry.get('removal_date') removal_version = deprecation_entry.get('removal_version') - if not warning_text: - warning_text = '{0} "{1}" is deprecated'.format(self.type, key) + warning_text = f'{self.type.title()} "{key}" has been deprecated.{" " if warning_text else ""}{warning_text}' display.deprecated(warning_text, version=removal_version, date=removal_date, collection_name=acr.collection) # check removal tombstone_entry = routing_entry.get('tombstone') if tombstone_entry: - warning_text = tombstone_entry.get('warning_text') + warning_text = tombstone_entry.get('warning_text') or '' removal_date = tombstone_entry.get('removal_date') removal_version = tombstone_entry.get('removal_version') - if not warning_text: - warning_text = '{0} "{1}" has been removed'.format(self.type, key) + warning_text = f'{self.type.title()} "{key}" has been removed.{" " if warning_text else ""}{warning_text}' exc_msg = display.get_deprecation_message(warning_text, version=removal_version, date=removal_date, collection_name=acr.collection, removed=True) diff --git a/test/integration/targets/collections/runme.sh b/test/integration/targets/collections/runme.sh index 5f11abebae..35607088b8 100755 --- a/test/integration/targets/collections/runme.sh +++ b/test/integration/targets/collections/runme.sh @@ -72,8 +72,11 @@ cat out.txt test "$(grep out.txt -ce 'deprecation1' -ce 'deprecation2' -ce 'deprecation3')" == 3 grep out.txt -e 'redirecting (type: filter) testns.testredirect.multi_redirect_filter to testns.testredirect.redirect_filter1' +grep out.txt -e 'Filter "testns.testredirect.multi_redirect_filter"' grep out.txt -e 'redirecting (type: filter) testns.testredirect.redirect_filter1 to testns.testredirect.redirect_filter2' +grep out.txt -e 'Filter "testns.testredirect.redirect_filter1"' grep out.txt -e 'redirecting (type: filter) testns.testredirect.redirect_filter2 to testns.testcoll.testfilter' +grep out.txt -e 'Filter "testns.testredirect.redirect_filter2"' echo "--- validating collections support in playbooks/roles" # run test playbooks |