From 70263c4afdd525cf9f69025bada5fc468a4a67c4 Mon Sep 17 00:00:00 2001 From: Robusta Runner Date: Sat, 2 Mar 2024 21:50:10 +0200 Subject: Warn the user if prometheus_url is in wrong format --- robusta_krr/core/models/config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'robusta_krr') diff --git a/robusta_krr/core/models/config.py b/robusta_krr/core/models/config.py index 54a9ed3..0f22854 100644 --- a/robusta_krr/core/models/config.py +++ b/robusta_krr/core/models/config.py @@ -74,6 +74,16 @@ class Config(pd.BaseSettings): def Formatter(self) -> formatters.FormatterFunc: return formatters.find(self.format) + @pd.validator("prometheus_url") + def validate_prometheus_url(cls, v: Optional[str]): + if v is None: + return None + + if not v.startswith("https://") and not v.startswith("http://"): + raise Exception("--prometheus-url must start with https:// or http://") + + return v + @pd.validator("prometheus_other_headers", pre=True) def validate_prometheus_other_headers(cls, headers: Union[list[str], dict[str, str]]) -> dict[str, str]: if isinstance(headers, dict): -- cgit v1.2.3