fix import alerting rule data bug

This commit is contained in:
liugq 2023-08-08 22:45:42 +08:00
parent 3ad0abdd5f
commit 515fd8ad0c
1 changed files with 11 additions and 11 deletions

View File

@ -59,18 +59,18 @@ func (h *DataAPI) importData(w http.ResponseWriter, req *http.Request, ps httpro
func indexExportData(eds []ExportData) error {
for _, ed := range eds {
var obj interface{}
switch ed.Type {
case DataTypeAlertChannel:
obj = &alerting.Channel{}
case DataTypeAlertRule:
obj = &alerting.Rule{}
case DataTypeAlertEmailServer:
obj = &model.EmailServer{}
default:
return fmt.Errorf("unkonw data type: %s", ed.Type)
}
for _, row := range ed.Data {
var obj interface{}
switch ed.Type {
case DataTypeAlertChannel:
obj = &alerting.Channel{}
case DataTypeAlertRule:
obj = &alerting.Rule{}
case DataTypeAlertEmailServer:
obj = &model.EmailServer{}
default:
return fmt.Errorf("unkonw data type: %s", ed.Type)
}
buf := util.MustToJSONBytes(row)
err := util.FromJSONBytes(buf, obj)
if err != nil {