Migrate unsupported integrations to webhook (#1737)
## Which issue(s) this PR fixes https://github.com/grafana/oncall/issues/1718
This commit is contained in:
parent
6f11d73f3d
commit
6ccde4a5e2
3 changed files with 21 additions and 2 deletions
|
|
@ -50,3 +50,9 @@ EXPERIMENTAL_MIGRATE_EVENT_RULES = (
|
|||
EXPERIMENTAL_MIGRATE_EVENT_RULES_LONG_NAMES = (
|
||||
os.getenv("EXPERIMENTAL_MIGRATE_EVENT_RULES_LONG_NAMES", "false").lower() == "true"
|
||||
)
|
||||
|
||||
# Set to true to migrate unsupported integrations to OnCall webhook integration
|
||||
# https://grafana.com/docs/oncall/latest/integrations/available-integrations/configure-webhook/
|
||||
UNSUPPORTED_INTEGRATION_TO_WEBHOOKS = (
|
||||
os.getenv("UNSUPPORTED_INTEGRATION_TO_WEBHOOKS", "false").lower() == "true"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
TAB = " " * 4
|
||||
SUCCESS_SIGN = "✅"
|
||||
ERROR_SIGN = "❌"
|
||||
WARNING_SIGN = "⚠️" # TODO: warning sign does not renders properly
|
||||
|
||||
|
||||
def format_user(user: dict) -> str:
|
||||
|
|
@ -73,7 +74,13 @@ def format_integration(integration: dict) -> str:
|
|||
ERROR_SIGN, result, policy_name
|
||||
)
|
||||
else:
|
||||
result = "{} {}".format(SUCCESS_SIGN, result)
|
||||
# check if integration not supported, but UNSUPPORTED_INTEGRATION_TO_WEBHOOKS set
|
||||
if integration.get("converted_to_webhook", False):
|
||||
result = "{} {} – Webhook integration will be created, Grafana OnCall not support this type directly ".format(
|
||||
WARNING_SIGN, result
|
||||
)
|
||||
else:
|
||||
result = "{} {}".format(SUCCESS_SIGN, result)
|
||||
|
||||
return result
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
from migrator import oncall_api_client
|
||||
from migrator.config import PAGERDUTY_TO_ONCALL_VENDOR_MAP
|
||||
from migrator.config import (
|
||||
PAGERDUTY_TO_ONCALL_VENDOR_MAP,
|
||||
UNSUPPORTED_INTEGRATION_TO_WEBHOOKS,
|
||||
)
|
||||
from migrator.utils import find_by_id
|
||||
|
||||
|
||||
|
|
@ -36,6 +39,9 @@ def match_integration_type(integration: dict, vendors: list[dict]) -> None:
|
|||
|
||||
integration["vendor_name"] = vendor_name
|
||||
integration["oncall_type"] = PAGERDUTY_TO_ONCALL_VENDOR_MAP.get(vendor_name)
|
||||
if UNSUPPORTED_INTEGRATION_TO_WEBHOOKS and integration["oncall_type"] is None:
|
||||
integration["oncall_type"] = "webhook"
|
||||
integration["converted_to_webhook"] = True
|
||||
|
||||
|
||||
def migrate_integration(integration: dict, escalation_policies: list[dict]) -> None:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue