Skip to content

Commit

Permalink
Trim issue title
Browse files Browse the repository at this point in the history
Prevent trailing newline characters in the title due to template
formatting.
Newlines in titles prevent Github->Slack webhooks working with issues as
of 2022-05-06.

Closes
#21
  • Loading branch information
Limess committed Jun 6, 2022
1 parent 073d471 commit 100689b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/notifier/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"crypto/sha256"
"fmt"
"net/url"
"sort"
"strings"

"github.com/google/go-github/v43/github"
"github.com/pfnet-research/alertmanager-to-github/pkg/template"
"github.com/pfnet-research/alertmanager-to-github/pkg/types"
"github.com/rs/zerolog/log"
"net/url"
"sort"
"strings"
)

type GitHubNotifier struct {
Expand Down Expand Up @@ -74,6 +75,9 @@ func (n *GitHubNotifier) Notify(ctx context.Context, payload *types.WebhookPaylo
if err != nil {
return err
}
// prevent trailing newline characters in the title due to template formatting
// newlines in titles prevent Github->Slack webhooks working with issues as of 2022-05-06
title = strings.TrimSpace(title)

req := &github.IssueRequest{
Title: &title,
Expand Down

0 comments on commit 100689b

Please sign in to comment.