Print the name of the option being deprecated (#83761)

Fixes #83759
pull/83870/head
Martin Krizek 3 months ago committed by GitHub
parent c6a391c8d8
commit 1f987423fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -167,19 +167,7 @@ class CLI(ABC):
else:
display.v(u"No config file found; using defaults")
# warn about deprecated config options
for deprecated in C.config.DEPRECATED:
name = deprecated[0]
why = deprecated[1]['why']
if 'alternatives' in deprecated[1]:
alt = ', use %s instead' % deprecated[1]['alternatives']
else:
alt = ''
ver = deprecated[1].get('version')
date = deprecated[1].get('date')
collection_name = deprecated[1].get('collection_name')
display.deprecated("%s option, %s%s" % (name, why, alt),
version=ver, date=date, collection_name=collection_name)
C.handle_config_noise(display)
@staticmethod
def split_vault_id(vault_id):

@ -684,5 +684,5 @@ class ConfigManager(object):
removal = f"Will be removed in: Ansible {dep_docs['removed_in']}\n\t"
# TODO: choose to deprecate either singular or plural
alt = dep_docs.get('alternatives', dep_docs.get('alternative', ''))
alt = dep_docs.get('alternatives', dep_docs.get('alternative', 'none'))
return f"Reason: {dep_docs['why']}\n\t{removal}Alternatives: {alt}"

@ -50,14 +50,16 @@ def handle_config_noise(display=None):
d = _deprecated
while config.WARNINGS:
warn = config.WARNINGS.pop(0)
warn = config.WARNINGS.pop()
w(warn)
while config.DEPRECATED:
# tuple with name and options
dep = config.DEPRECATED.pop(0)
msg = config.get_deprecated_msg_from_config(dep[1])
d(msg, version=dep[1]['version'])
# use tabs only for ansible-doc?
msg = msg.replace("\t", "")
d(f"{dep[0]} option. {msg}", version=dep[1]['version'])
def set_constant(name, value, export=vars()):

@ -9,8 +9,8 @@ export ANSIBLE_DEPRECATION_WARNINGS=True
# check for entry key valid, no deprecation
[ "$(ANSIBLE_CONFIG='entry_key_not_deprecated.cfg' ansible -m meta -a 'noop' localhost 2>&1 | grep -c 'DEPRECATION')" -eq "0" ]
# check for entry key deprecation, must be defined to trigger
[ "$(ANSIBLE_CONFIG='entry_key_deprecated.cfg' ansible -m meta -a 'noop' localhost 2>&1 | grep -c 'DEPRECATION')" -eq "1" ]
# check for entry key deprecation including the name of the option, must be defined to trigger
[ "$(ANSIBLE_CONFIG='entry_key_deprecated.cfg' ansible -m meta -a 'noop' localhost 2>&1 | grep -c "\[DEPRECATION WARNING\]: \[testing\]deprecated option.")" -eq "1" ]
# check for deprecation of entry itself, must be consumed to trigger
[ "$(ANSIBLE_TEST_ENTRY2=1 ansible -m debug -a 'msg={{q("config", "_Z_TEST_ENTRY_2")}}' localhost 2>&1 | grep -c 'DEPRECATION')" -eq "1" ]

Loading…
Cancel
Save