EngineConfiguration_SecretService
What it is
Pydantic-based configuration models for wiring the Secret service with one or more secret adapters (dotenv, Naas, base64-wrapped, or custom via GenericLoader).
Public API
DotenvSecretConfiguration (BaseModel)- Purpose: Configure loading secrets from a
.envfile. - Fields:
path: str = ".env"
- Purpose: Configure loading secrets from a
NaasSecretConfiguration (BaseModel)- Purpose: Configure loading secrets from Naas API.
- Fields:
naas_api_key: strnaas_api_url: str
Base64SecretConfiguration (BaseModel)- Purpose: Configure a base64 secret adapter that wraps another secret adapter.
- Fields:
secret_adapter: SecretAdapterConfigurationbase64_secret_key: str
- Methods:
load() -> Base64Secret: ConstructsBase64Secret(self.secret_adapter.load(), self.base64_secret_key).
SecretAdapterConfiguration (GenericLoader)- Purpose: Select and validate a secret adapter type and construct the corresponding adapter instance.
- Fields:
adapter: Literal["dotenv", "naas", "base64", "custom"]config: DotenvSecretConfiguration | NaasSecretConfiguration | Base64SecretConfiguration | None = None
- Methods:
validate_adapter() -> Self: Enforcesconfigpresence for non-customadapters and validates config model type fordotenv,naas,base64.load() -> ISecretAdapter: Lazily imports and instantiates the configured adapter; delegates toGenericLoader.load()whenadapter == "custom".
SecretServiceConfiguration (BaseModel)- Purpose: Top-level configuration for the
Secretservice. - Fields:
secret_adapters: List[SecretAdapterConfiguration]
- Methods:
load() -> Secret: BuildsSecret(adapters=[adapter.load() ...]).
- Purpose: Top-level configuration for the
Configuration/Dependencies
- Uses Pydantic v2 (
BaseModel,model_validator,ConfigDict(extra="forbid")). - Adapter implementations are imported lazily:
dotenv→DotenvSecretSecondaryAdaptornaas→NaasSecretbase64→Base64Secret(wraps another adapter)
customadapter relies onGenericLoaderbehavior (not defined in this file).- Validation helper:
pydantic_model_validator(...)is used to validateconfigagainst the expected model.
Usage
from naas_abi_core.engine.engine_configuration.EngineConfiguration_SecretService import (
SecretServiceConfiguration,
SecretAdapterConfiguration,
DotenvSecretConfiguration,
)
cfg = SecretServiceConfiguration(
secret_adapters=[
SecretAdapterConfiguration(
adapter="dotenv",
config=DotenvSecretConfiguration(path=".env"),
)
]
)
secret_service = cfg.load() # returns naas_abi_core.services.secret.Secret.Secret
Caveats
- For
adapter != "custom",configis required (assertion). - For
adapter == "base64",configmust be aBase64SecretConfigurationand must provideload()(assertions). - All config models shown set
extra="forbid"; unknown fields will fail validation.