mirror of
https://github.com/grafana/grafana.git
synced 2024-11-22 00:47:38 -06:00
Alerting: Fix Test Receivers when settings are non-strings (#62156)
* Alerting: Fix Test Receivers when settings are non-strings As part of the Alerting extraction, we want to make sure we don't have circular depedencies. As such, I had to move `PostableGrafanaReceiver` to a new struct in `grafana/alerting` called `GrafanaReceiver`. `PostableGrafanaReceiver` has an attribute called `Settings` that uses a Grafana-propietary struct called `RawMessage`, this struct shadows `json.RawMessage`. When I created `GrafanaReceiver`, I turned settings into a `map[string]string` thinking all settings would end up as strings. This was a mistake, and this test proves that it doesn't work, and breaks the API.
This commit is contained in:
parent
e8dd01df35
commit
0bfe150928
2
go.mod
2
go.mod
@ -59,7 +59,7 @@ require (
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/google/wire v0.5.0
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
github.com/grafana/alerting v0.0.0-20230124145916-c6a7791d037e
|
||||
github.com/grafana/alerting v0.0.0-20230125210216-facc6b27b9e0
|
||||
github.com/grafana/cuetsy v0.1.5
|
||||
github.com/grafana/grafana-aws-sdk v0.12.0
|
||||
github.com/grafana/grafana-azure-sdk-go v1.5.1
|
||||
|
4
go.sum
4
go.sum
@ -1394,8 +1394,8 @@ github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
|
||||
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grafana/alerting v0.0.0-20230124145916-c6a7791d037e h1:YCxvmaPXHGiaQdWy6qeQExivxWzpwUyM0sh73vudWhw=
|
||||
github.com/grafana/alerting v0.0.0-20230124145916-c6a7791d037e/go.mod h1:NoSLbfmUwE+omWFReFrLtbtOItmvTbuQERJ6XFYp9ME=
|
||||
github.com/grafana/alerting v0.0.0-20230125210216-facc6b27b9e0 h1:BzkQNnj+eevX30EMqJiUS1w3CPoGc8kp7pDf/ari/4Y=
|
||||
github.com/grafana/alerting v0.0.0-20230125210216-facc6b27b9e0/go.mod h1:NoSLbfmUwE+omWFReFrLtbtOItmvTbuQERJ6XFYp9ME=
|
||||
github.com/grafana/codejen v0.0.3 h1:tAWxoTUuhgmEqxJPOLtJoxlPBbMULFwKFOcRsPRPXDw=
|
||||
github.com/grafana/codejen v0.0.3/go.mod h1:zmwwM/DRyQB7pfuBjTWII3CWtxcXh8LTwAYGfDfpR6s=
|
||||
github.com/grafana/cuetsy v0.1.5 h1:mnFwAXdbqCsyL8r7kkdUMJ4kOAR26cxIPmrZj7JzTeY=
|
||||
|
@ -60,7 +60,7 @@ func (am *Alertmanager) TestReceivers(ctx context.Context, c apimodels.TestRecei
|
||||
for _, r := range c.Receivers {
|
||||
greceivers := make([]*alerting.GrafanaReceiver, 0, len(r.GrafanaManagedReceivers))
|
||||
for _, gr := range r.PostableGrafanaReceivers.GrafanaManagedReceivers {
|
||||
var settings map[string]string
|
||||
var settings map[string]interface{}
|
||||
//TODO: We shouldn't need to do this marshalling.
|
||||
j, err := gr.Settings.MarshalJSON()
|
||||
if err != nil {
|
||||
|
@ -98,7 +98,8 @@ func TestIntegrationTestReceivers(t *testing.T) {
|
||||
"type": "email",
|
||||
"disableResolveMessage": false,
|
||||
"settings": {
|
||||
"addresses":"example@email.com"
|
||||
"addresses":"example@email.com",
|
||||
"singleEmail": true
|
||||
},
|
||||
"secureFields": {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user