Gordon Janitor’s Plugin System¶
Module for loading plugins distributed via third-party packages.
Plugin discovery is done via entry_points
defined in a package’s
setup.py
, registered under 'gordon.plugins'
. For example:
# setup.py
from setuptools import setup
setup(
name=NAME,
# snip
entry_points={
'gordon.plugins': [
'gcp.gpubsub = gordon_gcp.gpubsub:EventClient',
'gcp.gce.a = gordon_gcp.gce.a:ReferenceSourceClient',
'gcp.gce.b = gordon_gcp.gce.b:ReferenceSourceClient',
'gcp.gdns = gordon_gcp.gdns:DNSProviderClient',
],
},
# snip
)
Plugins are initialized with any config defined in gordon-user.toml
and gordon.toml
. See Configuring the Gordon Janitor Service for more details.
Once a plugin is found, the loader looks up its configuration via the
same key defined in its entry point, e.g. gcp.gpubsub
.
The value of the entry point (e.g. gordon_gcp.gpubsub:EventClient
)
must point to a class. The plugin class is instantiated with its config.
A plugin will not have access to another plugin’s configuration. For
example, the gcp.gpusub
will not have access to the configuration
for gcp.gdns
.
See Gordon Janitor’s Plugin System for details on how to write a plugin for Gordon.
-
gordon.plugins_loader.
load_plugins
(config, plugin_kwargs)[source] Discover and instantiate plugins.
Parameters: Returns: list of names of plugins, list of instantiated plugin objects, and any errors encountered while loading/instantiating plugins. A tuple of three empty lists is returned if there are no plugins found or activated in gordon config.
Return type: Tuple of 3 lists
Writing a Plugin¶
Todo
Add documentation once interfaces are firmed up