From 56c5a5a4bcff85dcfa6369e5b33655270a91e2f1 Mon Sep 17 00:00:00 2001 From: Valentin Flaux <38909103+vflaux@users.noreply.github.com> Date: Mon, 13 Jan 2025 16:16:21 +0100 Subject: [PATCH] msteams notifier: adaptive cards full width Configure the adaptive card to expand and make full use of extra canvas space in teams. Signed-off-by: Valentin Flaux <38909103+vflaux@users.noreply.github.com> --- internal/notifier/teams.go | 8 ++++++++ internal/notifier/teams_test.go | 3 +++ 2 files changed, 11 insertions(+) diff --git a/internal/notifier/teams.go b/internal/notifier/teams.go index abe559eaa..4295dd1bf 100644 --- a/internal/notifier/teams.go +++ b/internal/notifier/teams.go @@ -84,6 +84,7 @@ type msAdaptiveCardContent struct { Type string `json:"type"` Version string `json:"version"` Body []msAdaptiveCardBodyElement `json:"body"` + MSTeams msAdaptiveCardMSTeams `json:"msteams"` } type msAdaptiveCardBodyElement struct { @@ -98,6 +99,10 @@ type msAdaptiveCardContainer struct { Items []msAdaptiveCardBodyElement `json:"items,omitempty"` } +type msAdaptiveCardMSTeams struct { + Width string `json:"width,omitempty"` +} + type msAdaptiveCardTextBlock struct { Text string `json:"text,omitempty"` Size string `json:"size,omitempty"` @@ -237,6 +242,9 @@ func buildMSTeamsAdaptiveCardPayload(event *eventv1.Event, objName string) *msAd Schema: "http://adaptivecards.io/schemas/adaptive-card.json", Type: "AdaptiveCard", Version: msAdaptiveCardVersion, + MSTeams: msAdaptiveCardMSTeams{ + Width: "Full", + }, Body: []msAdaptiveCardBodyElement{ { Type: "Container", diff --git a/internal/notifier/teams_test.go b/internal/notifier/teams_test.go index e280df295..67cbb26bb 100644 --- a/internal/notifier/teams_test.go +++ b/internal/notifier/teams_test.go @@ -100,6 +100,9 @@ func TestMSTeams_Post(t *testing.T) { "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", "version": "1.4", + "msteams": map[string]any{ + "width": "Full", + }, "body": []any{ map[string]any{ "type": "Container",