-
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
Added version argument to @depends decorator to enforce a minimum ver... #53658
Added version argument to @depends decorator to enforce a minimum ver... #53658
Conversation
…sion requirement.
Nice! Could this be merged to Neon? |
Hmm, apparently somewhere, a unicode character (the triple-dots) was introduced into the commit description, and that is causing several tests to fail (at least that is what it looks like to me). Is this something I can fix on my end (and how)? |
Fixed logic path when version is insufficient. Added version parameter in unloading log message if used.
Ok, that seems to have fixed the failing builds. |
Ask someone from SaltStack if that is possible, and if they agree then rebase against neon branch. |
Closed in favor of #55590 |
...sion requirement.
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