Handle missing floating IPs (#55)
This commit is contained in:
parent
5dd3a6781c
commit
1c0e1d5b0f
|
@ -117,7 +117,8 @@ func resourceDigitalOceanFloatingIpRead(d *schema.ResourceData, meta interface{}
|
|||
client := meta.(*godo.Client)
|
||||
|
||||
log.Printf("[INFO] Reading the details of the FloatingIP %s", d.Id())
|
||||
floatingIp, _, err := client.FloatingIPs.Get(context.Background(), d.Id())
|
||||
floatingIp, resp, err := client.FloatingIPs.Get(context.Background(), d.Id())
|
||||
if resp.StatusCode != 404 {
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error retrieving FloatingIP: %s", err)
|
||||
}
|
||||
|
@ -132,6 +133,9 @@ func resourceDigitalOceanFloatingIpRead(d *schema.ResourceData, meta interface{}
|
|||
}
|
||||
|
||||
d.Set("ip_address", floatingIp.IP)
|
||||
} else {
|
||||
d.SetId("")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue