Skip to content
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

feat: Extend plugin configuration loader to support dynamic levels #107

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

fernandodpr
Copy link
Contributor

Problem

The configuration loader in BasePlugin was designed to load plugin configurations exclusively from the plugins section of config.yaml. This approach was rigid and incompatible with newer configuration structures that introduced sections like community-plugins and custom-plugins.

This limitation caused plugins defined outside the plugins section to fail to load their configurations.

Solution

The configuration loader was enhanced to support dynamic levels (plugins, community-plugins, custom-plugins) without breaking existing setups:

  • Added a list of levels to search for plugin configurations.
  • Iterated through these levels to find the appropriate configuration for each plugin.
  • Ensured backward compatibility by prioritizing plugins.

Usage

Plugin developers can access their configuration options dynamically through self.config, which contains all the options defined in the configuration file for that plugin.

Example:

gpx_directory = self.config.get("gpx_directory", "./default/path")
allowed_device_ids = self.config.get("allowed_device_ids", [])

Backward Compatibility

  • Existing plugins defined in plugins continue to work as before.
  • Additional sections like community-plugins and custom-plugins are seamlessly supported.

Previously, the configuration loader in `BasePlugin` only supported loading plugin configurations from the `plugins` section of the `config.yaml` file. This approach limited flexibility and made it incompatible with new configuration structures.

With this update, the configuration loader now supports additional sections, such as `community-plugins` and `custom-plugins`, while maintaining backward compatibility. Plugins can access their configurations regardless of where they are defined in the file.

- Added dynamic search across multiple levels: `plugins`, `community-plugins`, and `custom-plugins`.
- Ensured `plugins` is prioritized to avoid breaking existing setups.
- Plugins retain access to their full configuration through `self.config`.

How to access configuration in plugins:
- Use `self.config` to retrieve plugin-specific options.
- Example: `self.config.get('active', False)` checks if the plugin is active.
- All configuration options from the corresponding section (e.g., `plugins`, `community-plugins`) are available dynamically.
@fernandodpr
Copy link
Contributor Author

fernandodpr commented Nov 27, 2024

I did some testing from my side but would really appreciate more testing before merging. Specially check the core plugins.

Copy link
Collaborator

@jeremiah-k jeremiah-k left a comment

Choose a reason for hiding this comment

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

lgtm

I tested the core plugins a bit. No issues here.

@jeremiah-k jeremiah-k merged commit 952186b into geoffwhittington:main Nov 28, 2024
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.

2 participants