Alerting: Fix terraform export of notification policy
When exporting a notification policy with no `group_by` the hcl exported is not valid as it is missing the required field. This fixes the issue by initializing the `group_by` field with an empty list if it is nil.
This commit is contained in:
committed by
Moustafa Baiou
parent
a110917577
commit
8ab12aede4
@@ -614,6 +614,10 @@ func exportHcl(download bool, body definitions.AlertingFileExport) response.Resp
|
||||
|
||||
for idx, cp := range body.Policies {
|
||||
policy := cp.RouteExport
|
||||
if policy.GroupByStr == nil {
|
||||
// required field, must be set to empty array
|
||||
policy.GroupByStr = &[]string{}
|
||||
}
|
||||
resources = append(resources, hcl.Resource{
|
||||
Type: "grafana_notification_policy",
|
||||
Name: fmt.Sprintf("notification_policy_%d", idx+1),
|
||||
|
||||
Reference in New Issue
Block a user