Alerting: Update grafana/alerting from de176b4a0309 to 83b6de6b0a35 (#105157)

* Update grafana alerting from de176b4a0309 to 83b6de6b0a35

Includes:
- https://github.com/grafana/alerting/pull/319
- https://github.com/grafana/alerting/pull/317

* Remove unused SendWebhook method from sender struct

grafana/alerting hasn't used the grafana webhook sender for a while now,
so this method is no longer used anywhere.

- Removed SendWebhook from the sender struct and rename it to emailSender
so that its use is clearer.
- Also, for similar reasons, the Webhook method on Grafana's
webhook sender `sendWebRequestSync` should not call grafana/alerting code for
NewTLSClient. The previous grafana/alerting function is vendored into grafana.

* Use BuildReceiverIntegrations new func signature
This commit is contained in:
Matthew Jacobson
2025-05-09 12:26:20 -04:00
committed by GitHub
parent 5e6c926b9c
commit 5795ba34f9
6 changed files with 33 additions and 58 deletions
+26 -3
View File
@@ -7,10 +7,10 @@ import (
"errors"
"fmt"
"io"
"net"
"net/http"
"net/url"
alertingHTTP "github.com/grafana/alerting/http"
"time"
"github.com/grafana/grafana/pkg/util"
)
@@ -71,7 +71,7 @@ func (ns *NotificationService) sendWebRequestSync(ctx context.Context, webhook *
request.Header.Set(k, v)
}
resp, err := alertingHTTP.NewTLSClient(webhook.TLSConfig).Do(request)
resp, err := NewTLSClient(webhook.TLSConfig).Do(request)
if err != nil {
return redactURL(err)
}
@@ -111,3 +111,26 @@ func redactURL(err error) error {
e.URL = "<redacted>"
return e
}
// NewTLSClient creates a new HTTP client with the provided TLS configuration or with default settings.
func NewTLSClient(tlsConfig *tls.Config) *http.Client {
nc := func(tlsConfig *tls.Config) *http.Client {
return &http.Client{
Timeout: time.Second * 30,
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 5 * time.Second,
},
}
}
if tlsConfig == nil {
return nc(&tls.Config{Renegotiation: tls.RenegotiateFreelyAsClient})
}
return nc(tlsConfig)
}