Fix calls to `deprecated()` to include `help_text` arg (#85262)

Co-authored-by: Matt Clay <matt@mystile.com>
pull/85275/head
Martin Krizek 6 months ago committed by GitHub
parent 051f7e5944
commit ea7ad90c31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -95,8 +95,9 @@ class AnsibleError(Exception):
self._show_content = False
Display().deprecated(
msg=f"The `suppress_extended_error` argument to `{type(self).__name__}` is deprecated. Use `show_content=False` instead.",
msg=f"The `suppress_extended_error` argument to `{type(self).__name__}` is deprecated.",
version="2.23",
help_text="Use `show_content=False` instead.",
)
@property

@ -21,7 +21,11 @@ def do_vault(data, secret, salt=None, vault_id='filter_default', wrap_object=Fal
raise TypeError(f"Can only vault strings, instead we got {type(data)}.")
if vaultid is not None:
display.deprecated("Use of undocumented 'vaultid', use 'vault_id' instead", version='2.20')
display.deprecated(
msg="Use of undocumented `vaultid`.",
version="2.20",
help_text="Use `vault_id` instead.",
)
if vault_id == 'filter_default':
vault_id = vaultid
@ -58,7 +62,11 @@ def do_unvault(vault, secret, vault_id='filter_default', vaultid=None):
raise TypeError(f"Vault should be in the form of a string, instead we got {type(vault)}.")
if vaultid is not None:
display.deprecated("Use of undocumented 'vaultid', use 'vault_id' instead", version='2.20')
display.deprecated(
msg="Use of undocumented `vaultid`.",
version="2.20",
help_text="Use `vault_id` instead.",
)
if vault_id == 'filter_default':
vault_id = vaultid

@ -325,8 +325,9 @@ class ShellModule(ShellBase):
def checksum(self, path, *args, **kwargs):
display.deprecated(
"The 'ShellModule.checksum' method is deprecated. Use 'ActionBase._execute_remote_stat()' instead.",
version="2.23"
msg="The `ShellModule.checksum` method is deprecated.",
version="2.23",
help_text="Use `ActionBase._execute_remote_stat()` instead.",
)
path = self._escape(self._unquote(path))
script = """

@ -48,8 +48,9 @@ class ShellModule(ShellBase):
def checksum(self, path, python_interp):
display.deprecated(
"The 'ShellModule.checksum' method is deprecated. Use 'ActionBase._execute_remote_stat()' instead.",
version="2.23"
msg="The `ShellModule.checksum` method is deprecated.",
version="2.23",
help_text="Use `ActionBase._execute_remote_stat()` instead.",
)
# In the following test, each condition is a check and logical
# comparison (|| or &&) that sets the rc value. Every check is run so

@ -19,8 +19,9 @@ def __getattr__(name):
raise AttributeError(name)
display.deprecated(
msg='ansible.utils.py3compat.environ is deprecated in favor of os.environ.',
msg='`ansible.utils.py3compat.environ` is deprecated.',
version='2.20',
help_text='Use `os.environ` from the Python standard library instead.',
)
return os.environ

@ -57,8 +57,9 @@ def set_default_transport():
# deal with 'smart' connection .. one time ..
if C.DEFAULT_TRANSPORT == 'smart':
display.deprecated(
msg="The 'smart' option for connections is deprecated. Set the connection plugin directly instead.",
version='2.20',
msg="The `smart` option for connections is deprecated.",
version="2.20",
help_text="Set the connection plugin directly instead.",
)
# see if SSH can support ControlPersist if not use paramiko

@ -35,10 +35,10 @@ def get_plugin_vars(loader, plugin, path, entities):
if hasattr(plugin, 'get_host_vars') or hasattr(plugin, 'get_group_vars'):
display.deprecated(
msg=f"The vars plugin {plugin.ansible_name} from {plugin._original_path} is relying "
"on the deprecated entrypoints 'get_host_vars' and 'get_group_vars'. "
"This plugin should be updated to inherit from BaseVarsPlugin and define "
"a 'get_vars' method as the main entrypoint instead.",
"on the deprecated entrypoints `get_host_vars` and `get_group_vars`.",
version="2.20",
help_text="This plugin should be updated to inherit from `BaseVarsPlugin` and define "
"a `get_vars` method as the main entrypoint instead.",
)
try:
for entity in entities:

@ -14,7 +14,7 @@ export ANSIBLE_VARS_ENABLED=require_enabled
# Test deprecated features
export ANSIBLE_VARS_PLUGINS=./deprecation_warning
WARNING="The vars plugin v2_vars_plugin .* is relying on the deprecated entrypoints 'get_host_vars' and 'get_group_vars'"
WARNING="The vars plugin v2_vars_plugin .* is relying on the deprecated entrypoints \`get_host_vars\` and \`get_group_vars\`"
ANSIBLE_DEPRECATION_WARNINGS=True ANSIBLE_NOCOLOR=True ANSIBLE_FORCE_COLOR=False \
ansible-inventory -i localhost, --list all "$@" 2> err.txt
ansible localhost -m debug -a "msg={{ lookup('file', 'err.txt') | regex_replace('\n', '') }}" | grep "$WARNING"

Loading…
Cancel
Save