mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-16 10:37:09 +00:00
notify/webhook: trim space from url_file content
Signed-off-by: Davide Bizzarri <davide.bizzarri@neoom.com>
This commit is contained in:
parent
80cbee0f58
commit
6b3dbc1e38
@ -21,6 +21,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/go-kit/log"
|
||||
"github.com/go-kit/log/level"
|
||||
@ -110,7 +111,7 @@ func (n *Notifier) Notify(ctx context.Context, alerts ...*types.Alert) (bool, er
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("read url_file: %w", err)
|
||||
}
|
||||
url = string(content)
|
||||
url = strings.TrimSpace(string(content))
|
||||
}
|
||||
|
||||
resp, err := notify.PostJSON(ctx, n.client, url, &buf)
|
||||
|
@ -124,7 +124,7 @@ func TestWebhookReadingURLFromFile(t *testing.T) {
|
||||
|
||||
f, err := os.CreateTemp("", "webhook_url")
|
||||
require.NoError(t, err, "creating temp file failed")
|
||||
_, err = f.WriteString(u.String())
|
||||
_, err = f.WriteString(u.String() + "\n")
|
||||
require.NoError(t, err, "writing to temp file failed")
|
||||
|
||||
notifier, err := New(
|
||||
|
Loading…
Reference in New Issue
Block a user