mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
remove ignore_list
This commit is contained in:
parent
3e18925289
commit
8744762580
3 changed files with 17 additions and 21 deletions
|
@ -69,11 +69,10 @@ How do I deprecate a Salt module to a Salt extension
|
|||
To indicate that a Salt module is being deprecated in favor of a Salt extension,
|
||||
for each Salt module include ``__deprecated__`` tuple in the module. The tuple
|
||||
should include the version of Salt that the module will be removed, the name of the
|
||||
collection of modules that are being deprecated, the URL where the source for
|
||||
the new extension can be found, and optionally any functions within the module that
|
||||
should be ignored when applying the warning. The version should be 2 major versions
|
||||
from the next major release. For example, if the next major release of Salt is 3100,
|
||||
the deprecation version should be set to 3102.
|
||||
collection of modules that are being deprecated, and the URL where the source for
|
||||
the new extension can be found should be ignored when applying the warning.
|
||||
The version should be 2 major versions from the next major release. For example,
|
||||
if the next major release of Salt is 3100, the deprecation version should be set to 3102.
|
||||
|
||||
.. code-block: python
|
||||
|
||||
|
@ -82,10 +81,3 @@ the deprecation version should be set to 3102.
|
|||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
ignore_list=["get_all_eip_addresses"],
|
||||
)
|
||||
|
|
|
@ -11,7 +11,9 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
def extension_deprecation_message(
|
||||
version, extension_name, extension_repo, ignore_list=None
|
||||
version,
|
||||
extension_name,
|
||||
extension_repo,
|
||||
):
|
||||
"""
|
||||
Decorator wrapper to warn about deprecation
|
||||
|
@ -20,7 +22,11 @@ def extension_deprecation_message(
|
|||
def decorator(function):
|
||||
@wraps(function)
|
||||
def wrapper(*args, **kwargs):
|
||||
if not ignore_list or function.__name__ not in ignore_list:
|
||||
# Any functions that should not be decorated
|
||||
# as they're used when attempting when determining
|
||||
# what modules to load, eg. Salt Cloud
|
||||
ignore_list = ("get_configured_provider",)
|
||||
if function.__name__ not in ignore_list:
|
||||
salt.utils.versions.warn_until(
|
||||
version,
|
||||
f"The '{extension_name}' functionality in Salt has been deprecated and its "
|
||||
|
|
|
@ -4,14 +4,12 @@ from salt.utils.decorators.extension_deprecation import extension_deprecation_me
|
|||
|
||||
|
||||
@extension_deprecation_message(3009, "salt_mod", "http://www.example.com")
|
||||
def salt_func_one():
|
||||
def salt_func():
|
||||
return True
|
||||
|
||||
|
||||
@extension_deprecation_message(
|
||||
3009, "salt_mod", "http://www.example.com", ignore_list=["salt_func_two"]
|
||||
)
|
||||
def salt_func_two():
|
||||
@extension_deprecation_message(3009, "salt_mod", "http://www.example.com")
|
||||
def get_configured_provider():
|
||||
return True
|
||||
|
||||
|
||||
|
@ -27,13 +25,13 @@ def test_extension_deprecation():
|
|||
"in favor of the saltext.salt_mod Salt Extension. (http://www.example.com)"
|
||||
)
|
||||
with warnings.catch_warnings(record=True) as catch_warnings:
|
||||
ret = salt_func_one()
|
||||
ret = salt_func()
|
||||
assert ret
|
||||
assert len(catch_warnings) == 1
|
||||
assert issubclass(catch_warnings[-1].category, DeprecationWarning)
|
||||
assert str(catch_warnings[-1].message) == expected_deprecation_message
|
||||
|
||||
with warnings.catch_warnings(record=True) as catch_warnings:
|
||||
ret = salt_func_two()
|
||||
ret = get_configured_provider()
|
||||
assert ret
|
||||
assert len(catch_warnings) == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue