From 9b7fe65897a919c509925f492c62a0a5fac13c84 Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Fri, 3 Mar 2023 11:43:42 -0500 Subject: [PATCH 1/2] Add option to set meilisearch setting from envoronment variables --- README.md | 4 ++-- meilisync/settings.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 340614a..1a12f0c 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): From 39131a5dce7e0bb3b576c812e0bd8827ea9207ac Mon Sep 17 00:00:00 2001 From: Paul Sanders Date: Fri, 3 Mar 2023 11:51:59 -0500 Subject: [PATCH 2/2] Fix format in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1a12f0c..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. 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 +- `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