From abe4e0076791982933113aa120a7ae9178af46c5 Mon Sep 17 00:00:00 2001 From: Jonathan Buch Date: Wed, 8 Nov 2023 09:39:41 +0100 Subject: [PATCH] Fix alertmanager runbook url * fixes #144 --- pkg/connectors/alertmanager/connector.go | 3 +-- pkg/connectors/alertmanager/connector_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/connectors/alertmanager/connector.go b/pkg/connectors/alertmanager/connector.go index da709a3..441d2d8 100644 --- a/pkg/connectors/alertmanager/connector.go +++ b/pkg/connectors/alertmanager/connector.go @@ -97,8 +97,7 @@ func (c *Connector) Collect(ctx context.Context) ([]connectors.Alert, error) { } var links []html.HTML - if rb, ok := sourceAlert.Annotations["runbook"]; ok { - link := url.QueryEscape(rb) + if link, ok := sourceAlert.Annotations["runbook"]; ok { links = append(links, html.HTML("📖")) } diff --git a/pkg/connectors/alertmanager/connector_test.go b/pkg/connectors/alertmanager/connector_test.go index 627d5a4..f6cfa88 100644 --- a/pkg/connectors/alertmanager/connector_test.go +++ b/pkg/connectors/alertmanager/connector_test.go @@ -6,6 +6,7 @@ import ( "net/http" "net/http/httptest" "regexp" + "strings" "testing" "github.com/synyx/tuwat/pkg/connectors" @@ -35,6 +36,13 @@ func TestConnector(t *testing.T) { if alerts == nil || len(alerts) != 3 { t.Error("There should be alerts") } + + alert := alerts[0] + for _, link := range alert.Links { + if !strings.Contains(string(link), "://") { + t.Error("There should be a non encoded url") + } + } } func TestDecode(t *testing.T) {