Skip to content

Commit

Permalink
Fix alertmanager runbook url
Browse files Browse the repository at this point in the history
* fixes #144
  • Loading branch information
BuJo committed Nov 8, 2023
1 parent 18a2be1 commit abe4e00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/connectors/alertmanager/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("<a href=\""+link+"\" target=\"_blank\" alt=\"Runbook\">📖</a>"))
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/connectors/alertmanager/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httptest"
"regexp"
"strings"
"testing"

"github.com/synyx/tuwat/pkg/connectors"
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit abe4e00

Please sign in to comment.