mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 03:19:30 +08:00
Store 'alertmanager_configuration' as JSON string instead of raw bytes (#42443)
This commit is contained in:

committed by
GitHub

parent
41917c1473
commit
5183cc4dc4
@ -123,7 +123,7 @@ type alertingSecret struct{}
|
||||
func (s alertingSecret) reencrypt(secretsSrv *manager.SecretsService, sess *xorm.Session) error {
|
||||
var results []struct {
|
||||
Id int
|
||||
AlertmanagerConfiguration []byte
|
||||
AlertmanagerConfiguration string
|
||||
}
|
||||
|
||||
selectSQL := "SELECT id, alertmanager_configuration FROM alert_configuration"
|
||||
@ -133,7 +133,7 @@ func (s alertingSecret) reencrypt(secretsSrv *manager.SecretsService, sess *xorm
|
||||
|
||||
for _, result := range results {
|
||||
result := result
|
||||
postableUserConfig, err := notifier.Load(result.AlertmanagerConfiguration)
|
||||
postableUserConfig, err := notifier.Load([]byte(result.AlertmanagerConfiguration))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -161,11 +161,12 @@ func (s alertingSecret) reencrypt(secretsSrv *manager.SecretsService, sess *xorm
|
||||
}
|
||||
}
|
||||
|
||||
result.AlertmanagerConfiguration, err = json.Marshal(postableUserConfig)
|
||||
marshalled, err := json.Marshal(postableUserConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result.AlertmanagerConfiguration = string(marshalled)
|
||||
if _, err := sess.Table("alert_configuration").Where("id = ?", result.Id).Update(&result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user