Skip to content

Commit

Permalink
Explicitly set labels to nil for Alert Policy
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
chrisst committed Jan 9, 2020
1 parent 644697d commit a1503a8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions google/resource_monitoring_alert_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,18 @@ func resourceMonitoringAlertPolicyRead(d *schema.ResourceData, meta interface{})
return handleNotFoundError(err, d, fmt.Sprintf("MonitoringAlertPolicy %q", d.Id()))
}

res, err = resourceMonitoringAlertPolicyDecoder(d, meta, res)
if err != nil {
return err
}

if res == nil {
// Decoding the object has resulted in it being gone. It may be marked deleted
log.Printf("[DEBUG] Removing MonitoringAlertPolicy because it no longer exists.")
d.SetId("")
return nil
}

if err := d.Set("project", project); err != nil {
return fmt.Errorf("Error reading AlertPolicy: %s", err)
}
Expand Down Expand Up @@ -1849,3 +1861,10 @@ func expandMonitoringAlertPolicyDocumentationContent(v interface{}, d TerraformR
func expandMonitoringAlertPolicyDocumentationMimeType(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func resourceMonitoringAlertPolicyDecoder(d *schema.ResourceData, meta interface{}, res map[string]interface{}) (map[string]interface{}, error) {
if err := d.Set("labels", nil); err != nil {
return res, fmt.Errorf("Error ignoring Removed fields for AlertPolicy: %s", err)
}
return res, nil
}

0 comments on commit a1503a8

Please sign in to comment.