|
1 | 1 | import os |
| 2 | +from pydantic import BaseModel |
2 | 3 |
|
3 | | -# from dotenv import load_dotenv |
4 | 4 |
|
5 | | -# load_dotenv() # Only needed locally if using a .env file |
| 5 | +class HostSettings(BaseModel): |
| 6 | + host: str = "localhost" |
| 7 | + port: int = 8000 |
| 8 | + etcd_host: str = "localhost" |
| 9 | + etcd_port: int = 2379 |
| 10 | + tool_support: bool = False |
| 11 | + gunicorn_workers: int = 10 |
| 12 | + attestation_host: str = "localhost" |
| 13 | + attestation_port: int = 8081 |
6 | 14 |
|
7 | | -SETTINGS = { |
8 | | - "host": os.getenv("SVC_HOST", "localhost"), |
9 | | - "port": os.getenv("SVC_PORT", 8000), |
10 | | - "etcd_host": os.getenv("ETCD_HOST", "localhost"), |
11 | | - "etcd_port": os.getenv("ETCD_PORT", 2379), |
12 | | - "tool_support": os.getenv("TOOL_SUPPORT", False), |
13 | | - "gunicorn_workers": os.getenv("NILAI_GUNICORN_WORKERS", 10), |
14 | | - "attestation_host": os.getenv("ATTESTATION_HOST", "localhost"), |
15 | | - "attestation_port": os.getenv("ATTESTATION_PORT", 8080), |
16 | | -} |
17 | | -# if environment == "docker": |
18 | | -# config = "docker_settings.py" |
19 | | -# else: |
20 | | -# config = "local_settings.py" |
21 | 15 |
|
22 | | -# # Import the appropriate config dynamically |
23 | | -# from importlib import import_module |
24 | | -# settings = import_module(config) |
| 16 | +SETTINGS: HostSettings = HostSettings( |
| 17 | + host=str(os.getenv("SVC_HOST", "localhost")), |
| 18 | + port=int(os.getenv("SVC_PORT", 8000)), |
| 19 | + etcd_host=str(os.getenv("ETCD_HOST", "localhost")), |
| 20 | + etcd_port=int(os.getenv("ETCD_PORT", 2379)), |
| 21 | + tool_support=bool(os.getenv("TOOL_SUPPORT", False)), |
| 22 | + gunicorn_workers=int(os.getenv("NILAI_GUNICORN_WORKERS", 10)), |
| 23 | + attestation_host=str(os.getenv("ATTESTATION_HOST", "localhost")), |
| 24 | + attestation_port=int(os.getenv("ATTESTATION_PORT", 8081)), |
| 25 | +) |
0 commit comments