fix s3 storage
This commit is contained in:
+16
-3
@@ -3,13 +3,24 @@ from pathlib import Path
|
||||
from typing import Literal, Self
|
||||
|
||||
from pydantic import Field, SecretStr, model_validator
|
||||
from pydantic_settings import BaseSettings, PydanticBaseSettingsSource, SettingsConfigDict
|
||||
from pydantic_settings import (
|
||||
BaseSettings,
|
||||
PydanticBaseSettingsSource,
|
||||
SettingsConfigDict,
|
||||
)
|
||||
from sqlalchemy import URL
|
||||
from app.core.s3 import S3Settings
|
||||
|
||||
ASYNC_DRIVER = "postgresql+asyncpg"
|
||||
SECRETS_DIR = next(
|
||||
(path for path in (Path("/run/secrets"), Path(__file__).resolve().parents[2] / "secrets") if (path / "db_password").is_file()),
|
||||
(
|
||||
path
|
||||
for path in (
|
||||
Path("/run/secrets"),
|
||||
Path(__file__).resolve().parents[2] / "secrets",
|
||||
)
|
||||
if (path / "db_password").is_file()
|
||||
),
|
||||
None,
|
||||
)
|
||||
|
||||
@@ -88,7 +99,9 @@ class Settings(BaseSettings):
|
||||
@model_validator(mode="after")
|
||||
def _require_database_source(self) -> Self:
|
||||
if self.shutdown_drain_seconds + self.graceful_shutdown_timeout_seconds >= 8:
|
||||
raise ValueError("Drain и graceful shutdown должны суммарно занимать менее 8 секунд")
|
||||
raise ValueError(
|
||||
"Drain и graceful shutdown должны суммарно занимать менее 8 секунд"
|
||||
)
|
||||
if self.database_url is not None:
|
||||
if not self.database_url.get_secret_value().startswith(ASYNC_DRIVER):
|
||||
raise ValueError(f"DATABASE_URL должен начинаться с {ASYNC_DRIVER}://")
|
||||
|
||||
Reference in New Issue
Block a user