EngineConfiguration_SecretService
What it is
Pydantic-based configuration models for wiring the Secret service with one or more secret adapters (dotenv, naas, base64, or custom). Provides validation and lazy loading of the configured adapter implementations.
Public API
-
DotenvSecretConfiguration(Pydantic model)- Purpose: Configuration for the
dotenvsecret adapter. - Fields:
path: str = ".env": Path to the dotenv file.
- Purpose: Configuration for the
-
NaasSecretConfiguration(Pydantic model)- Purpose: Configuration for the
naassecret adapter. - Fields:
naas_api_key: strnaas_api_url: str
- Purpose: Configuration for the
-
Base64SecretConfiguration(Pydantic model)- Purpose: Configuration for the
base64adapter, which wraps another secret adapter. - Fields:
secret_adapter: SecretAdapterConfiguration: The underlying adapter configuration to wrap.base64_secret_key: str
- Methods:
load() -> Base64Secret: Instantiates theBase64Secretadapter (lazy import).
- Purpose: Configuration for the
-
SecretAdapterConfiguration(GenericLoader)- Purpose: Selects and validates an adapter type and loads an
ISecretAdapter. - Fields:
adapter: Literal["dotenv", "naas", "base64", "custom"]config: DotenvSecretConfiguration | NaasSecretConfiguration | Base64SecretConfiguration | None
- Methods:
validate_adapter() -> Self: Ensuresconfigis present for non-customadapters and validates it against the expected config model.load() -> ISecretAdapter: Lazily imports and instantiates the configured adapter; forcustom, delegates toGenericLoader.load().
- Purpose: Selects and validates an adapter type and loads an
-
SecretServiceConfiguration(Pydantic model)- Purpose: Top-level configuration for the
Secretservice. - Fields:
secret_adapters: List[SecretAdapterConfiguration]
- Methods:
load() -> Secret: Builds aSecretinstance with all configured adapters loaded.
- Purpose: Top-level configuration for the
Configuration/Dependencies
- Depends on:
pydantic(BaseModel,ConfigDict,model_validator)naas_abi_core.services.secret.Secret.Secretnaas_abi_core.services.secret.SecretPorts.ISecretAdapter- Adapter implementations (loaded lazily):
DotenvSecretSecondaryAdaptorNaasSecretBase64Secret
- Validation behavior:
- Extra fields are forbidden in
DotenvSecretConfiguration,NaasSecretConfiguration, andBase64SecretConfiguration(extra="forbid"). - For
adapter != "custom",configmust be provided.
- Extra fields are forbidden in
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() # naas_abi_core.services.secret.Secret.Secret
Caveats
SecretAdapterConfiguration.configis required unlessadapter="custom"; otherwise an assertion error is raised.- Adapter imports are lazy; missing optional adapter packages/modules will only error when
load()is called for that adapter. - For
adapter="base64",configmust be aBase64SecretConfigurationand must provide aload()method (asserted at runtime).