From df9cf368c0bb5ff2f7152402b30a0f27a5571389 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Thu, 14 Jan 2021 17:45:02 +0100 Subject: [PATCH] Always mention the name of the deprecated plugin in routing deprecation messages (#73059) --- .../fragments/73059-improve-deprecation-texts.yml | 2 ++ lib/ansible/plugins/loader.py | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/73059-improve-deprecation-texts.yml diff --git a/changelogs/fragments/73059-improve-deprecation-texts.yml b/changelogs/fragments/73059-improve-deprecation-texts.yml new file mode 100644 index 00000000000..b1ca876858d --- /dev/null +++ b/changelogs/fragments/73059-improve-deprecation-texts.yml @@ -0,0 +1,2 @@ +bugfixes: +- "Always mention the name of the deprecated or tombstoned plugin in routing deprecation/tombstone messages (https://github.com/ansible/ansible/pull/73059)." diff --git a/lib/ansible/plugins/loader.py b/lib/ansible/plugins/loader.py index 02b129d59ff..eaf6df894f7 100644 --- a/lib/ansible/plugins/loader.py +++ b/lib/ansible/plugins/loader.py @@ -134,14 +134,15 @@ class PluginLoadContext(object): if not deprecation: return self - warning_text = deprecation.get('warning_text', None) + # The `or ''` instead of using `.get(..., '')` makes sure that even if the user explicitly + # sets `warning_text` to `~` (None) or `false`, we still get an empty string. + warning_text = deprecation.get('warning_text', None) or '' removal_date = deprecation.get('removal_date', None) removal_version = deprecation.get('removal_version', None) # If both removal_date and removal_version are specified, use removal_date if removal_date is not None: removal_version = None - if not warning_text: - warning_text = '{0} has been deprecated'.format(name) + warning_text = '{0} has been deprecated.{1}{2}'.format(name, ' ' if warning_text else '', warning_text) display.deprecated(warning_text, date=removal_date, version=removal_version, collection_name=collection_name) @@ -459,7 +460,8 @@ class PluginLoader: if tombstone: removal_date = tombstone.get('removal_date') removal_version = tombstone.get('removal_version') - warning_text = tombstone.get('warning_text') or '{0} has been removed.'.format(fq_name) + warning_text = tombstone.get('warning_text') or '' + warning_text = '{0} has been removed.{1}{2}'.format(fq_name, ' ' if warning_text else '', warning_text) removed_msg = display.get_deprecation_message(msg=warning_text, version=removal_version, date=removal_date, removed=True, collection_name=acr.collection)