Skip to content

Conversation

@thrau
Copy link
Member

@thrau thrau commented May 31, 2024

Motivation

Sometimes we want to re-use code that injects plugins we don't want to use. To facilitate this, I added a way to filter plugins based on simple fnmatch rules. You can disable plugins by namespaces, names, or even values.

Here are some examples of how it can be used:

from plux.runtime.filter import global_plugin_filter

# disables all plugins in the `localstack.aws.provider` namespace
global_plugin_filter.add_pattern(namespace = "localstack.aws.provider")

# disables all plugins in namespaces that start with `localstack.aws.`
global_plugin_filter.add_pattern(namespace = "localstack.aws.*")

# disables all plugins that come from the `localstack.services` package, regardless in which namespace
global_plugin_filter.add_pattern(value = "localstack.services.*")

# disables all plugins that come from the `localstack.services` package, but only if they are in the `localstack.aws.provider` namespace
global_plugin_filter.add_pattern(namespace = "localstack.aws.provider", value = "localstack.services.*")

# disables any plugin named "iam-enforcement"
global_plugin_filter.add_pattern(name = "iam-enforcement")

Changes

  • a global filter is added by default to every PluginManager, that does nothing unless configured otherwise

@thrau thrau requested a review from dominikschubert May 31, 2024 21:51
Copy link
Member

@dominikschubert dominikschubert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but a few minor "UX" nits 👍

Great addition allowing more flexibility now when reusing code without having to completely rip out all the existing plugins 🥳

@thrau thrau merged commit 8e8f376 into main Jun 4, 2024
@thrau thrau deleted the filter-plugins branch June 4, 2024 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants