Dynamic Adapters¶
Volundr uses a dynamic adapter pattern for most infrastructure components. Config specifies what class to load and what arguments to pass. No factory functions, no match/case chains.
How It Works¶
- Config specifies a fully-qualified class path in the
adapterkey. - Remaining keys under
kwargsare passed as**kwargsto the constructor. - Some adapters accept injected ports (e.g., StoragePort, CredentialStorePort). These are wired automatically by the application at startup.
- Sensitive kwargs can come from Kubernetes Secrets via
secretKwargs(Helm) orsecret_kwargs_env(config.yaml).
Import Mechanism¶
The container resolves the class at startup:
module_path, class_name = dotted_path.rsplit(".", 1)
module = importlib.import_module(module_path)
cls = getattr(module, class_name)
instance = cls(**kwargs)
No registration step. If the class exists on the Python path, it works.
Writing Your Own Adapter¶
- Implement the relevant port interface (e.g.,
PodManager,CredentialStorePort). - Accept your config as constructor kwargs.
- Use
**_extrato ignore injected kwargs you don't need. - Set the
adapterkey in config to your class path.
from volundr.ports.credential_store import CredentialStorePort
class MyCredentialStore(CredentialStorePort):
def __init__(self, api_url: str, api_key: str, **_extra):
self._url = api_url
self._key = api_key
async def get_credential(self, user_id: str, name: str) -> str | None:
...
credentialStore:
adapter: "mypackage.creds.MyCredentialStore"
kwargs:
api_url: "https://secrets.internal"
secretKwargs:
api_key:
secretName: my-creds
key: api-key
All Adapter-Driven Components¶
| Component | Port | Default Adapter |
|---|---|---|
| Pod manager | PodManager | FluxPodManager |
| Identity | IdentityPort | AllowAllIdentityAdapter |
| Authorization | AuthorizationPort | AllowAllAuthorizationAdapter |
| Credential store | CredentialStorePort | MemoryCredentialStore |
| Secret injection | SecretInjectionPort | InMemorySecretInjectionAdapter |
| Storage | StoragePort | InMemoryStorageAdapter |
| Gateway | GatewayPort | InMemoryGatewayAdapter |
| Resource provider | ResourceProvider | StaticResourceProvider |
| Session contributors | SessionContributor | (10 default contributors) |
Each component page in this section documents the available adapters and their configuration.