Skip to main content

Module plugin_config_loader

Module plugin_config_loader 

Source
Expand description

Plugin-scoped config dir loader.

Reads each plugin’s <config_dir>/plugins/<plugin_id>/*.yaml files, deep-merges them with ${ENV_VAR} resolution, validates the merged tree against manifest.config.schema_path’s JSONSchema (when present), and surfaces the result as PluginConfig for the init-loop to thread into PluginInitContext.

Multi-file sharding lets operators split sensitive settings (credentials) from declarative ones (channel allowlists). Files merge alphabetically:

<config_dir>/plugins/slack/
  01-credentials.yaml
  02-channels.yaml
  03-allowlist.yaml

Empty / missing dir is OK — returns an empty mapping. Plugins whose schema declares all fields optional load with no operator action.

Schema validation reuses the lightweight subset validator shipped in nexo-plugin-manifest::config_schema (covers type, required, properties, additionalProperties, enum). Plugins needing oneOf / $ref / pattern get richer validation in 81.4.c.

Hot-reload of plugin config files is OUT OF SCOPE — operators restart the daemon today. 81.4.b wires the post-hook.

Structs§

PluginConfig
Pre-loaded + pre-validated plugin config. Empty mapping when the operator has not placed any yaml files at the per-plugin dir — the plugin still boots; its init decides whether the missing config is acceptable.

Enums§

PluginConfigError
Errors load_plugin_config can return. Boundary type — every failure mode the init-loop needs to discriminate is its own variant.

Functions§

config_error_kind
Stable string discriminator for the JSON shape used by the plugin.lifecycle.<id>.config_load_failed broker event + future doctor surface.
load_plugin_config
Load + validate a single plugin’s config. Reads <config_dir>/plugins/<plugin_id>/*.yaml (alphabetical), resolves ${ENV_VAR} placeholders, deep-merges, and validates against manifest.config.schema_path (resolved relative to plugin_root) when set.
plugin_config_dir_for
<config_dir>/plugins/<plugin_id>/. Convenience for callers that need the path before invoking the loader.