Alerting: Export of notification policies to HCL (#76411)

This commit is contained in:
Yuri Tseretyan
2023-10-12 12:10:08 -04:00
committed by GitHub
parent bdeb829cf6
commit c4ac4eb41b
5 changed files with 92 additions and 32 deletions
+8 -7
View File
@@ -557,13 +557,14 @@ func exportHcl(download bool, body definitions.AlertingFileExport) response.Resp
// Body: &cp,
// })
// }
// for idx, cp := range ex.Policies {
// resources = append(resources, resourceBlock{
// Type: "grafana_notification_policy",
// Name: fmt.Sprintf("notification_policy_%d", idx),
// Body: &cp,
// })
//
for idx, cp := range body.Policies {
policy := cp.Policy
resources = append(resources, hcl.Resource{
Type: "grafana_notification_policy",
Name: fmt.Sprintf("notification_policy_%d", idx+1),
Body: policy,
})
}
hclBody, err := hcl.Encode(resources...)
if err != nil {