Alerting: replace usage of simplejson to json.RawMessage in NotificationChannelConfig (#60423)

* introduce alias for json.RawMessage with name RawMessage. This is needed to keep raw JSON and implement a marshaler for YAML, which does not seem to be used but there are tests that fail.
* replace usage of simplejson with RawMessage in NotificationChannelConfig
* remove usage of simplejson in tests
* change migration code to convert simplejson to raw message
This commit is contained in:
Yuri Tseretyan
2022-12-16 13:01:06 -05:00
committed by GitHub
parent 09bb4423d2
commit 9ad45aedcf
35 changed files with 257 additions and 161 deletions

View File

@@ -470,6 +470,10 @@ func (m *migration) validateAlertmanagerConfig(orgID int64, config *PostableUser
secureSettings[k] = d
}
data, err := gr.Settings.MarshalJSON()
if err != nil {
return err
}
var (
cfg = &channels.NotificationChannelConfig{
UID: gr.UID,
@@ -477,10 +481,9 @@ func (m *migration) validateAlertmanagerConfig(orgID int64, config *PostableUser
Name: gr.Name,
Type: gr.Type,
DisableResolveMessage: gr.DisableResolveMessage,
Settings: gr.Settings,
Settings: data,
SecureSettings: secureSettings,
}
err error
)
// decryptFunc represents the legacy way of decrypting data. Before the migration, we don't need any new way,