-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #278 from idealista/develop
Release 3.2.3
- Loading branch information
Showing
6 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
apiVersion: v1 | ||
appVersion: "3.2.2" | ||
appVersion: "3.2.3" | ||
description: A Helm chart for Prom2Teams | ||
name: prom2teams | ||
version: 0.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
def remove_double_quotes_from_teams_alert(alert): | ||
"""Remove double quotes from all the fields""" | ||
for field in alert.__dict__: | ||
if field == "extra_annotations" or field == "extra_labels": | ||
new_inner_map = {} | ||
for inner_field in alert.__getattribute__(field): | ||
original_value = alert.__getattribute__(field)[inner_field] | ||
modified_value = original_value.replace('"', '') | ||
new_inner_map[inner_field] = modified_value | ||
alert.__setattr__(field, new_inner_map) | ||
else: | ||
original_value = alert.__getattribute__(field) | ||
modified_value = original_value.replace('"', '') | ||
alert.__setattr__(field, modified_value) | ||
return alert |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
import os | ||
|
||
from prom2teams.teams.teams_alert_validation import remove_double_quotes_from_teams_alert | ||
from prom2teams.teams.teams_alert_schema import TeamsAlert | ||
|
||
ALERT = { | ||
"name": "Watchdog", | ||
"status": "firing", | ||
"severity": 'non""""e', | ||
"summary": "unknown", | ||
"instance": "unknown", | ||
"description": "unknown", | ||
"fingerprint": '07109567b88e9"""""eb6c', | ||
"runbook_url": "", | ||
"extra_labels": {'prometheus': 'cattle-monitoring-s"""""ystem/rancher-monitoring-prometheus'}, | ||
"extra_annotations": {'message': 'This is an alert meant to ensure that the entire alerting pipeline is functional.\nThis alert is always firing, therefore it should always be firing in Alertmanager\nand always fire against a receiver. There are integrations with various notification\nmechanisms that send a notification when this alert is not firing. For example the\n"DeadMansSnitch" integration in PagerDuty.\n'}, | ||
} | ||
|
||
ALERT_WITHOUT_QUOTES = { | ||
"name": "Watchdog", | ||
"status": "firing", | ||
"severity": 'none', | ||
"summary": "unknown", | ||
"instance": "unknown", | ||
"description": "unknown", | ||
"fingerprint": '07109567b88e9eb6c', | ||
"runbook_url": "", | ||
"extra_labels": {'prometheus': 'cattle-monitoring-system/rancher-monitoring-prometheus'}, | ||
"extra_annotations": {'message': 'This is an alert meant to ensure that the entire alerting pipeline is functional.\nThis alert is always firing, therefore it should always be firing in Alertmanager\nand always fire against a receiver. There are integrations with various notification\nmechanisms that send a notification when this alert is not firing. For example the\nDeadMansSnitch integration in PagerDuty.\n'}, | ||
} | ||
|
||
TEAMS_ALERT = TeamsAlert(ALERT['name'], ALERT['status'].lower(), ALERT['severity'], | ||
ALERT['summary'], ALERT['instance'], ALERT['description'], | ||
ALERT['fingerprint'], ALERT['runbook_url'], ALERT['extra_labels'], | ||
ALERT['extra_annotations']) | ||
|
||
TEAMS_ALERT_WITHOUT_QUOTES = TeamsAlert(ALERT_WITHOUT_QUOTES['name'], ALERT_WITHOUT_QUOTES['status'].lower(), ALERT_WITHOUT_QUOTES['severity'], | ||
ALERT_WITHOUT_QUOTES['summary'], ALERT_WITHOUT_QUOTES['instance'], ALERT_WITHOUT_QUOTES['description'], | ||
ALERT_WITHOUT_QUOTES['fingerprint'], ALERT_WITHOUT_QUOTES['runbook_url'], ALERT_WITHOUT_QUOTES['extra_labels'], | ||
ALERT_WITHOUT_QUOTES['extra_annotations']) | ||
|
||
|
||
class TestServer(unittest.TestCase): | ||
def test_remove_double_quotes_from_teams_alert(self): | ||
alert = remove_double_quotes_from_teams_alert(TEAMS_ALERT) | ||
self.assertEqual(alert.extra_labels, TEAMS_ALERT_WITHOUT_QUOTES.extra_labels) | ||
self.assertEqual(alert.extra_annotations, TEAMS_ALERT_WITHOUT_QUOTES.extra_annotations) | ||
self.assertEqual(alert.severity, TEAMS_ALERT_WITHOUT_QUOTES.severity) | ||
self.assertEqual(alert.fingerprint, TEAMS_ALERT_WITHOUT_QUOTES.fingerprint) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |