Fix loose config with environment variables
This commit is contained in:
parent
53f935b916
commit
d0c7e4614a
1 changed files with 19 additions and 17 deletions
|
@ -64,14 +64,8 @@ def get_cache_dir() -> Path:
|
||||||
return Path(conf.storage.root_cache_path)
|
return Path(conf.storage.root_cache_path)
|
||||||
|
|
||||||
|
|
||||||
class MyBaseSettings(BaseSettings):
|
class DB(BaseSettings):
|
||||||
model_config = SettingsConfigDict(
|
model_config = SettingsConfigDict(env_prefix="treetrail_db_")
|
||||||
env_prefix="treetrail_",
|
|
||||||
env_nested_delimiter="_",
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class DB(MyBaseSettings):
|
|
||||||
# uri: str
|
# uri: str
|
||||||
host: str = "treetrail-database"
|
host: str = "treetrail-database"
|
||||||
port: int = 5432
|
port: int = 5432
|
||||||
|
@ -91,16 +85,19 @@ class DB(MyBaseSettings):
|
||||||
return f"postgresql://{self.user}:{self.password}@{self.host}:{self.port}/{self.db}"
|
return f"postgresql://{self.user}:{self.password}@{self.host}:{self.port}/{self.db}"
|
||||||
|
|
||||||
|
|
||||||
class App(MyBaseSettings):
|
class App(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_app_")
|
||||||
title: str = "Tree Trail"
|
title: str = "Tree Trail"
|
||||||
|
|
||||||
|
|
||||||
class Storage(MyBaseSettings):
|
class Storage(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_storage_")
|
||||||
root_attachment_path: str = "/var/lib/treetrail/attachments"
|
root_attachment_path: str = "/var/lib/treetrail/attachments"
|
||||||
root_cache_path: str = "/var/lib/treetrail/cache"
|
root_cache_path: str = "/var/lib/treetrail/cache"
|
||||||
|
|
||||||
|
|
||||||
class Tiles(MyBaseSettings):
|
class Tiles(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_tiles_")
|
||||||
baseDir: str = "/var/lib/treetrail/mbtiles_files"
|
baseDir: str = "/var/lib/treetrail/mbtiles_files"
|
||||||
useRequestUrl: bool = True
|
useRequestUrl: bool = True
|
||||||
spriteBaseDir: str = "/var/lib/treetrail/mbtiles_sprites"
|
spriteBaseDir: str = "/var/lib/treetrail/mbtiles_sprites"
|
||||||
|
@ -109,7 +106,8 @@ class Tiles(MyBaseSettings):
|
||||||
osmBaseDir: str = "/var/lib/treetrail/osm"
|
osmBaseDir: str = "/var/lib/treetrail/osm"
|
||||||
|
|
||||||
|
|
||||||
class Map(MyBaseSettings):
|
class Map(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_map_")
|
||||||
zoom: float = 14.0
|
zoom: float = 14.0
|
||||||
pitch: float = 0.0
|
pitch: float = 0.0
|
||||||
lat: float = 45.8822
|
lat: float = 45.8822
|
||||||
|
@ -118,12 +116,14 @@ class Map(MyBaseSettings):
|
||||||
background: str = "OpenFreeMap"
|
background: str = "OpenFreeMap"
|
||||||
|
|
||||||
|
|
||||||
class Geo(MyBaseSettings):
|
class Geo(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_geo_")
|
||||||
simplify_geom_factor: int = 10000000
|
simplify_geom_factor: int = 10000000
|
||||||
simplify_preserve_topology: bool = False
|
simplify_preserve_topology: bool = False
|
||||||
|
|
||||||
|
|
||||||
class Security(MyBaseSettings):
|
class Security(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_security_")
|
||||||
"""
|
"""
|
||||||
JWT security configuration
|
JWT security configuration
|
||||||
"""
|
"""
|
||||||
|
@ -133,12 +133,14 @@ class Security(MyBaseSettings):
|
||||||
access_token_expire_minutes: float = 30
|
access_token_expire_minutes: float = 30
|
||||||
|
|
||||||
|
|
||||||
class ExternalMapStyle(MyBaseSettings):
|
class ExternalMapStyle(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_external_map_style_")
|
||||||
name: str
|
name: str
|
||||||
url: str
|
url: str
|
||||||
|
|
||||||
|
|
||||||
class Config(MyBaseSettings):
|
class Config(BaseSettings):
|
||||||
|
model_config = SettingsConfigDict(env_prefix="treetrail_")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def settings_customise_sources(
|
def settings_customise_sources(
|
||||||
|
@ -161,7 +163,7 @@ class Config(MyBaseSettings):
|
||||||
tiles: Tiles = Tiles()
|
tiles: Tiles = Tiles()
|
||||||
security: Security = Security()
|
security: Security = Security()
|
||||||
geo: Geo = Geo()
|
geo: Geo = Geo()
|
||||||
version: str = '-'
|
version: str = "-"
|
||||||
db: DB = DB()
|
db: DB = DB()
|
||||||
base_href: str = "/treetrail"
|
base_href: str = "/treetrail"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue