-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Depends decorator version master #55590
Depends decorator version master #55590
Conversation
…sion requirement.
Fixed logic path when version is insufficient. Added version parameter in unloading log message if used.
|
||
log.trace( | ||
'Unloading %s.%s because dependency (%s) is not met', | ||
mod_name, func_name, dependency | ||
'Unloading %s.%s because dependency (%s%s) is not met', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this missing a .
?
'Unloading %s.%s because dependency (%s%s) is not met', | |
'Unloading %s.%s because dependency (%s.%s) is not met', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the 4th %s
placeholder is filled with https://github.com/saltstack/salt/pull/55590/files#diff-7bd4f0af6512326b8c5a14e4ecb70b40R211 which starts with a space. Alternatively, I could move the space to this line (207) if you prefer.
Hey, thanks for this PR! I went a-looking to see what I could see Re: tests: In I think similar functions could be added to the existing Let me know if you need any more help on this! |
This is #53658, rebased on master.
What does this PR do?
It adds a
version
kwarg to the @Depends decorator, which can handle any value that is able to be parsed withsalt.utils.version.LooseVersion
. The value of this version kwarg will be compared to the__version__
-attribute of the module mentioned in the decorator (if it cannot be found (because it is a command or the module does not have the attribute), it will silently default toNone
). If the version is not equal or larger than the determined version (noting that when the latter isNone
, everything will be either equal (alsoNone
) or greater (any value)), the specific function will be removed byenforce_dependencies
.What issues does this PR fix or reference?
None that I know of
Previous Behavior
The @Depends decorator can only specify whether or not a module needs to be loaded.
New Behavior
The @Depends decorator can also specify a specific minimum version for the module that needs to be loaded.
Tests written?
No, there are tests in
tests/integration/modules/test_decorators.py
, but I have no idea how those work.Commits signed with GPG?
Yes