Skip to content

Replace runtime model mutation with an explicit plugin registry #595

@bschwedler

Description

@bschwedler

After plugin discovery, `rebuild_tool_models()` performs deferred imports of `Image`, `ImageVariant`, `ImageVersion`, and `BakeryConfigDocument` to reconstruct Pydantic discriminated unions with plugin-contributed tool options. This is a circular-import workaround. If config loads before plugins are discovered, tool options fail silently — no error, no warning. Adding a new model that uses `ToolField` requires manually updating the rebuild function with no static guarantee of completeness. Plugins also import from `cli.common`, coupling the plugin system to the CLI layer.

Replace with a plugin registry that config models query at validation time rather than mutating model annotations at import time. This makes initialization order explicit, turns silent failures into loud ones, and makes plugins independently testable.

Files: `config/tools/init.py`, `plugins/`, `config/image/variant.py`, `config/image/version.py`

Metadata

Metadata

Assignees

No one assigned

    Labels

    cvp:0Necessary projects we are undertaking that don’t directly deliver value to the customerdockerRelated to container images we producetdp:2The team notices.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions