mirror of
https://github.com/kurbezz/discord-bot.git
synced 2026-03-03 15:00:46 +01:00
Use BaseSettings and remove Vault fetch logic
This commit is contained in:
@@ -1,15 +1,7 @@
|
|||||||
from httpx import Client
|
|
||||||
from pydantic import BaseModel
|
|
||||||
from pydantic_settings import BaseSettings
|
from pydantic_settings import BaseSettings
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Config(BaseSettings):
|
||||||
VAULT_HOST: str
|
|
||||||
VAULT_SECRET_PATH: str
|
|
||||||
VAULT_TOKEN: str
|
|
||||||
|
|
||||||
|
|
||||||
class Config(BaseModel):
|
|
||||||
DISCORD_BOT_TOKEN: str
|
DISCORD_BOT_TOKEN: str
|
||||||
DISCORD_BOT_ID: str
|
DISCORD_BOT_ID: str
|
||||||
DISCORD_BOT_ACTIVITY: str
|
DISCORD_BOT_ACTIVITY: str
|
||||||
@@ -37,21 +29,4 @@ class Config(BaseModel):
|
|||||||
TEMPOLAR_URL: str = "temporal:7233"
|
TEMPOLAR_URL: str = "temporal:7233"
|
||||||
|
|
||||||
|
|
||||||
def get_config() -> Config:
|
config = Config()
|
||||||
settings = Settings() # type: ignore
|
|
||||||
|
|
||||||
with Client() as client:
|
|
||||||
response = client.get(
|
|
||||||
f"https://{settings.VAULT_HOST}/v1/{settings.VAULT_SECRET_PATH}",
|
|
||||||
headers={
|
|
||||||
"X-Vault-Token": settings.VAULT_TOKEN,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
response.raise_for_status()
|
|
||||||
|
|
||||||
return Config(**response.json()["data"]["data"])
|
|
||||||
|
|
||||||
|
|
||||||
config = get_config()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user