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
Support loading entrypoints by passing a module instead of a function #58943
Conversation
96f5192
to
7d8c22a
Compare
404e85e
to
7b56830
Compare
8ea491a
to
f39d4fe
Compare
I think [options.entrypoints]
salt.loader=
myplugin1 = myplugin1module
myplugin2 = myplugin2module At least, I believe this is what was intended for they keys in the configs for entrypoints and can see some value from it. Then in the versions report we could show something like
or simply
Not sure what's really better there.. I could see that in most cases there would be a single plugin and the name would match the package name. |
But then you have the same extension, with the same version, showing up multiple times on the versions report, just because they provide more than one entry point.... I don't see any value added there....
Would be less verbose, but I still don't see added value there.... |
c70ac60
to
16c07ed
Compare
re-run all |
It's not about the extension, it's about the plugin. There can be a case where the package providing the plugin has a whole lot of functionality that has nothing to do with Salt. For instance, boto could provide a salt plugin that they maintain which ships with boto3. |
We only report salt related extensions... I'm not seeing the issue |
And we report that boto3 version X.Y.Z provide extensions for salt... |
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.
I'll look into this closer tomorrow morning, but in the meantime there is the changelog comment
16c07ed
to
6cd8579
Compare
Also add a few helper methods to `VirtualEnv`
6cd8579
to
ab89cd5
Compare
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.
Hey! Sorry this took a bit longer than planned to get back to you. I think this looks excellent!
There are a couple of places where we could add a bit more testing (the negative cases). But otherwise this seems 👍 to me.
I cloned this locally and added my own "extension module" and tried the 3 different styles of loading - list, dict, and ext_types
sub module + /modules/
dir and manually verified that it works.
Oh, one more question: should we also test the other types of dirs? I see that this test includes modules, but don't we have other potential dirs? from my debugging code:
ext_dirs? auth_dirs
ext_dirs? engines_dirs
ext_dirs? fileserver_dirs
ext_dirs? grains_dirs
ext_dirs? log_handlers_dirs
ext_dirs? matchers_dirs
ext_dirs? module_dirs
ext_dirs? returner_dirs
ext_dirs? runner_dirs
ext_dirs? serializers_dirs
ext_dirs? tokens_dirs
ext_dirs? top_dirs
ext_dirs? utils_dirs
ext_dirs? wheel_dirs
What does this PR do?
Support loading entrypoints by passing a module instead of a function.
The old way of defining salt loader entrypoints was, for example, on
setup.cfg
:This old way is still supported in the rare ocasion where you actually
want to pass multiple paths to the loader and to not break backwards
compatibility.
The new way of defining the salt loader entrypoints is, for example, on
setup.cfg
:With this new approach, when the target is a package, Salt looks for the
ext_type
being loaded as submodule of the package and if it exists, itloads from there.
If the target is a callable, then, that callable should return a
dictionary where the keys are the several salt loader names. For
salt execution modules it would be
modules
, for salt state modules it wouldbe
states
, etc. The same directory layout you see in salt.The values for those keys needs to be an iterable(not a string which is
also an iterable), ie, a list, a generator, etc, whose values are the
paths from where to load the salt loader modules.
What issues does this PR fix or reference?
Fixes #58939