Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: jira provider _host attribute #2751

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions keep/providers/jira_provider/jira_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class JiraProviderAuthConfig:
"sensitive": False,
"documentation_url": "https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/#Create-an-API-token",
"hint": "https://keephq.atlassian.net",
"validation": "https_url"
"validation": "https_url",
}
)

Expand Down Expand Up @@ -101,6 +101,7 @@ def __init__(
self, context_manager: ContextManager, provider_id: str, config: ProviderConfig
):
super().__init__(context_manager, provider_id, config)
self._host = None

def validate_scopes(self):
"""
Expand Down Expand Up @@ -161,10 +162,16 @@ def validate_config(self):
)

@property
def jira_host(self):
if self._host:
def jira_host(self) -> str:
if self._host is not None:
return self._host
self._host = str(self.authentication_config.host)
host = (
self.authentication_config.host
if self.authentication_config.host.startswith("https://")
or self.authentication_config.host.startswith("http://")
else f"https://{self.authentication_config.host}"
)
self._host = host
return self._host

def dispose(self):
Expand Down Expand Up @@ -483,9 +490,7 @@ def _query(self, ticket_id="", board_id="", **kwargs: dict):
kwargs (dict): The providers with context
"""
if not ticket_id:
request_url = (
f"{self.jira_host}/rest/agile/1.0/board/{board_id}/issue"
)
request_url = f"{self.jira_host}/rest/agile/1.0/board/{board_id}/issue"
response = requests.get(request_url, auth=self.__get_auth(), verify=False)
if not response.ok:
raise ProviderException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def _format_alert(
message=annotations.get("summary"),
status=VictoriametricsProvider.STATUS_MAP[alert["status"]],
severity=VictoriametricsProvider.SEVERITIES_MAP[
alert.get("labels", {}).get("severity", "info")
labels.get("severity", "low")
],
startedAt=alert.get("startsAt"),
url=alert.get("generatorURL"),
Expand Down
Loading