mirror of
https://github.com/tiqi-group/pydase_service_base.git
synced 2026-02-19 01:28:51 +01:00
updating config to new confz version, db connections take config folder as argument
This commit is contained in:
@@ -1,37 +1,24 @@
|
||||
from pathlib import Path
|
||||
from typing import Literal
|
||||
|
||||
from confz import ConfZ, ConfZEnvSource, ConfZFileSource
|
||||
from confz import BaseConfig, EnvSource
|
||||
from pydantic import AnyUrl, SecretStr
|
||||
|
||||
CONFIG_DIR = Path(__file__).parent.parent.parent.resolve() / "config"
|
||||
|
||||
|
||||
class OperationMode(ConfZ): # type: ignore
|
||||
class OperationMode(BaseConfig): # type: ignore
|
||||
environment: Literal["development"] | Literal["production"] = "development"
|
||||
|
||||
CONFIG_SOURCES = ConfZEnvSource(allow=["ENVIRONMENT"])
|
||||
CONFIG_SOURCES = EnvSource(allow=["ENVIRONMENT"])
|
||||
|
||||
|
||||
class PostgreSQLConfig(ConfZ): # type: ignore
|
||||
class PostgreSQLConfig(BaseConfig): # type: ignore
|
||||
host: AnyUrl
|
||||
port: int
|
||||
database: str
|
||||
user: str
|
||||
password: SecretStr
|
||||
|
||||
CONFIG_SOURCES = [
|
||||
ConfZFileSource(f"{CONFIG_DIR}/postgres_{OperationMode().environment}.yaml"),
|
||||
ConfZEnvSource(prefix="POSTGRES_", allow=["user", "password"], file=".env"),
|
||||
]
|
||||
|
||||
|
||||
class InfluxDBConfig(ConfZ): # type: ignore
|
||||
class InfluxDBConfig(BaseConfig): # type: ignore
|
||||
url: AnyUrl
|
||||
org: str
|
||||
token: SecretStr
|
||||
|
||||
CONFIG_SOURCES = [
|
||||
ConfZFileSource(f"{CONFIG_DIR}/influxdb_config.yaml"),
|
||||
ConfZEnvSource(prefix="INFLUXDB_V2_", allow=["token"], file=".env"),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user