Skip to content

Commit

Permalink
Warn the user if prometheus_url is in wrong format
Browse files Browse the repository at this point in the history
  • Loading branch information
aantn committed Mar 2, 2024
1 parent ae80181 commit 70263c4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions robusta_krr/core/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ def __init__(self, **kwargs: Any) -> None:
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):
Expand Down

0 comments on commit 70263c4

Please sign in to comment.