diff --git a/README.md b/README.md index 340614a..f2ac55a 100644 --- a/README.md +++ b/README.md @@ -109,8 +109,8 @@ Source database configuration, currently only support MySQL and PostgreSQL and M MeiliSearch configuration. -- `api_url`: the MeiliSearch API URL. -- `api_key`: the MeiliSearch API key. +- `api_url`: the MeiliSearch API URL. This can be set from the `MEILI_HTTP_ADDR` environment variable. +- `api_key`: the MeiliSearch API key. This can be set with the `MEILI_MASTER_KEY` environment varable. ### sync diff --git a/meilisync/settings.py b/meilisync/settings.py index a9d5f15..2c254c9 100644 --- a/meilisync/settings.py +++ b/meilisync/settings.py @@ -1,6 +1,6 @@ from typing import List, Optional -from pydantic import BaseModel, BaseSettings, Extra +from pydantic import BaseModel, BaseSettings, Extra, Field from meilisync.enums import ProgressType, SourceType from meilisync.plugin import load_plugin @@ -16,9 +16,9 @@ class Config: extra = Extra.allow -class MeiliSearch(BaseModel): - api_url: str - api_key: Optional[str] +class MeiliSearch(BaseSettings): + api_url: str = Field(..., env="MEILI_HTTP_ADDR") + api_key: Optional[str] = Field(None, env="MEILI_MASTER_KEY") class BasePlugin(BaseModel):