From 6bf8f6cddce929d9d4b5da03fbe7154629232230 Mon Sep 17 00:00:00 2001 From: lawik974 Date: Thu, 14 Mar 2024 23:31:32 +0100 Subject: [PATCH] Working on gotify message format --- kube_notify/app.py | 8 ++++---- kube_notify/notifications.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kube_notify/app.py b/kube_notify/app.py index 97f2211..2fba814 100644 --- a/kube_notify/app.py +++ b/kube_notify/app.py @@ -121,15 +121,15 @@ async def core_stream(kube_notify_config): involved_object_name = str(obj.involved_object.name) involved_object_namespace = str(obj.involved_object.namespace) - title = f"{resource_kind} {event_type}" + title = f"{event_type} {resource_kind}" description = f"{event_type} {resource_kind} : {involved_object_kind} {involved_object_name} {reason}." fields = { + "Message": message, "Reason": reason, "Type": event_type, - "Message": message, + "Object kind": involved_object_kind, + "Object name": involved_object_name, "Timestamp": last_timestamp.isoformat(), - "Involved Object kind": involved_object_kind, - "Involved Object name": involved_object_name, "Namespace": str(obj.metadata.namespace), } event_info = ( diff --git a/kube_notify/notifications.py b/kube_notify/notifications.py index b7cf3be..4387b99 100644 --- a/kube_notify/notifications.py +++ b/kube_notify/notifications.py @@ -98,10 +98,10 @@ def send_gotify_message(url, token, title, description, fields): url = f"{url}/message?token={token}&format=markdown" headers = {"Content-Type": "application/json"} message = f"**{description}**\n\n" - message += "| Clé | Valeur |\n" + message += "| | |\n" message += "| ---- | ---- |\n" for key, value in fields.items(): - message += f"| {key} | {value} |\n" + message += f"| {key} | **{value}** |\n" data = { "title": title, "message": message,