Skip to content

Commit

Permalink
reintroduce accidentally deleted code
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterp committed Feb 28, 2023
1 parent 3cf2d68 commit 0b42c3e
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion exoscale/resource_exoscale_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,34 @@ func resourceDomainImport(ctx context.Context, d *schema.ResourceData, meta inte
return nil, err
}

return []*schema.ResourceData{d}, nil
resources := make([]*schema.ResourceData, 0, 1)
resources = append(resources, d)

records, err := client.ListDNSDomainRecords(ctx, defaultZone, d.Id())
if err != nil {
return nil, err
}

for _, record := range records {
// Ignore the default NS and SOA entries
if *record.Type == "NS" || *record.Type == "SOA" {
continue
}
resource := resourceDomainRecord()
data := resource.Data(nil)
data.SetType("exoscale_domain_record")
if err := data.Set("domain", d.Id()); err != nil {
return nil, err
}

if err := resourceDomainRecordApply(data, *domain.UnicodeName, &record); err != nil {
continue
}

resources = append(resources, data)
}

return resources, nil
}

func resourceDomainApply(d *schema.ResourceData, domain *exo.DNSDomain) error {
Expand Down

0 comments on commit 0b42c3e

Please sign in to comment.