Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions deployment/helm/datamate/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public:
database: 1Gi
operator: 1Gi
secrets:
# Set to false when using Sealed Secrets (managed by install script)
create: false
# Set to true so the chart creates the datamate-conf Secret.
# The install script writes secrets into this block via sed before helm install.
create: true
data:
DB_PASSWORD: "" # Set via install script or --set
CERT_PASS: "" # Set via install script for encrypted SSL keys
Expand Down
21 changes: 18 additions & 3 deletions runtime/datamate-python/app/core/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pydantic_settings import BaseSettings
from pydantic import model_validator
from sqlalchemy import URL
from typing import Optional

class Settings(BaseSettings):
Expand Down Expand Up @@ -55,15 +56,29 @@ class Config:

@model_validator(mode='after')
def build_database_url(self):
"""如果没有提供 database_url,则根据 MySQL 配置构建"""
"""如果没有提供 database_url,则根据数据库配置构建。"""
if not self.database_url:
if self.pgsql_host:
if self.pgsql_password and self.pgsql_user:
self.database_url = f"postgresql+asyncpg://{self.pgsql_user}:{self.pgsql_password}@{self.pgsql_host}:{self.pgsql_port}/{self.pgsql_database}"
self.database_url = URL.create(
"postgresql+asyncpg",
username=self.pgsql_user,
password=self.pgsql_password,
host=self.pgsql_host,
port=self.pgsql_port,
database=self.pgsql_database,
).render_as_string(hide_password=False)
else:
self.database_url = f"postgresql+asyncpg://{self.pgsql_host}:{self.pgsql_port}/{self.pgsql_database}"
elif self.mysql_password and self.mysql_user:
self.database_url = f"mysql+aiomysql://{self.mysql_user}:{self.mysql_password}@{self.mysql_host}:{self.mysql_port}/{self.mysql_database}"
self.database_url = URL.create(
"mysql+aiomysql",
username=self.mysql_user,
password=self.mysql_password,
host=self.mysql_host,
port=self.mysql_port,
database=self.mysql_database,
).render_as_string(hide_password=False)
else:
self.database_url = f"mysql+aiomysql://{self.mysql_host}:{self.mysql_port}/{self.mysql_database}"
return self
Expand Down
Loading