Skip to content

Commit

Permalink
Adding salt/utils/decorators/extension_deprecation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgreenaway authored and Megan Wilhite committed Jun 30, 2023
1 parent 405fd40 commit 9a2102a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions salt/utils/decorators/extension_deprecation.py
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

0 comments on commit 9a2102a

Please sign in to comment.