diff options
| author | Robusta Runner <aantny@gmail.com> | 2024-03-02 21:50:10 +0200 |
|---|---|---|
| committer | Robusta Runner <aantny@gmail.com> | 2024-03-02 21:50:10 +0200 |
| commit | 70263c4afdd525cf9f69025bada5fc468a4a67c4 (patch) | |
| tree | 08a048c12ec63f74ee51b35f332583ff54c7280e /robusta_krr | |
| parent | ae80181ccc5128caf93fe6acc4b47ca137263e25 (diff) | |
Warn the user if prometheus_url is in wrong format
Diffstat (limited to 'robusta_krr')
| -rw-r--r-- | robusta_krr/core/models/config.py | 10 |
1 files changed, 10 insertions, 0 deletions
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): |
