Skip to content

r/domain_zone_record: fix panic when del. outside tf #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ovh/resource_domain_zone_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ func resourceOvhDomainZoneRecordCreate(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error calling /domain/zone/%s. Zone may have been left with orphan records!:\n\t %q", zone, err)
}

if record == nil {
log.Printf("[DEBUG] record %v has been deleted.", record)
continue
}

log.Printf("[DEBUG] record found %v", record)
if record.Target == newRecord.Target &&
record.SubDomain == newRecord.SubDomain &&
Expand Down Expand Up @@ -163,6 +168,10 @@ func resourceOvhDomainZoneRecordRead(d *schema.ResourceData, meta interface{}) e
return err
}

if record == nil {
return fmt.Errorf("record %v has been deleted.", d.Id())
}

d.Set("zone", record.Zone)
d.Set("fieldtype", record.FieldType)
d.Set("subdomain", record.SubDomain)
Expand Down