Set the extra attribute in FrigateBaseModel.Config based on the value of the FRIGATE_EXTRA environment variable, allowing, ignoring or forbidding extra fields

This commit is contained in:
Sergey Krashevich 2023-06-19 13:23:35 +03:00
parent a29c4dccfb
commit 684a634345
No known key found for this signature in database
GPG Key ID: 625171324E7D3856

View File

@ -45,11 +45,13 @@ DEFAULT_DETECTORS = {"cpu": {"type": "cpu"}}
class FrigateBaseModel(BaseModel):
class Config:
extra = (
Extra.allow
if os.environ.get("FRIGATE_ALLOW_EXTRA") is not None
else Extra.forbid
)
frigate_env_extra_var = os.environ.get("FRIGATE_ALLOW_EXTRA", "forbid")
if frigate_env_extra_var.lower() == "allow":
extra = Extra.allow
elif frigate_env_extra_var.lower() == "ignore":
extra = Extra.ignore
else:
extra = Extra.forbid
class LiveModeEnum(str, Enum):