forked from saltstack/salt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding salt/utils/decorators/extension_deprecation.py
- Loading branch information
1 parent
405fd40
commit 9a2102a
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
Decorators for deprecation of modules to Salt extensions | ||
""" | ||
import logging | ||
from functools import wraps | ||
|
||
import salt.utils.args | ||
import salt.utils.versions | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
def extension_deprecation_message(version, extension_name, extension_repo): | ||
""" | ||
Decorator wrapper to warn about deprecation | ||
""" | ||
|
||
def decorator(function): | ||
@wraps(function) | ||
def wrapper(*args, **kwargs): | ||
salt.utils.versions.warn_until( | ||
version, | ||
f"The '{extension_name}' functionality in Salt has been deprecated and its " | ||
"functionality will be removed in version {version} in favor of the " | ||
f"saltext.{extension_name} Salt Extension. " | ||
f"({extension_repo})", | ||
category=FutureWarning, | ||
) | ||
return function(*args, **salt.utils.args.clean_kwargs(**kwargs)) | ||
|
||
return wrapper | ||
|
||
return decorator |