Alerting: Export of contact points to HCL (#75849)

* add compat layer to convert from Export model to "new" API models
This commit is contained in:
Yuri Tseretyan
2023-10-12 22:33:57 +01:00
committed by GitHub
parent 0a6d78f35e
commit 372082d254
6 changed files with 932 additions and 12 deletions
+11 -8
View File
@@ -548,15 +548,18 @@ func exportHcl(download bool, body definitions.AlertingFileExport) response.Resp
Body: &gr,
})
}
for idx, cp := range body.ContactPoints {
upd, err := ContactPointFromContactPointExport(cp)
if err != nil {
return response.Error(http.StatusInternalServerError, "failed to convert contact points to HCL", err)
}
resources = append(resources, hcl.Resource{
Type: "grafana_contact_point",
Name: fmt.Sprintf("contact_point_%d", idx),
Body: &upd,
})
}
// TODO implement support.
// for idx, cp := range ex.ContactPoints {
// resources = append(resources, resourceBlock{
// Type: "grafana_contact_point",
// Name: fmt.Sprintf("contact_point_%d", idx),
// Body: &cp,
// })
// }
for idx, cp := range body.Policies {
policy := cp.Policy
resources = append(resources, hcl.Resource{