Check where nested structs could possibly be nil before trying to access their data
This commit is contained in:
parent
f140c15039
commit
c8dfecc65f
|
@ -212,11 +212,15 @@ func resourceVcdNetworkRead(d *schema.ResourceData, meta interface{}) error {
|
|||
|
||||
d.Set("name", network.OrgVDCNetwork.Name)
|
||||
d.Set("href", network.OrgVDCNetwork.HREF)
|
||||
d.Set("fence_mode", network.OrgVDCNetwork.Configuration.FenceMode)
|
||||
d.Set("gateway", network.OrgVDCNetwork.Configuration.IPScopes.IPScope.Gateway)
|
||||
d.Set("netmask", network.OrgVDCNetwork.Configuration.IPScopes.IPScope.Netmask)
|
||||
d.Set("dns1", network.OrgVDCNetwork.Configuration.IPScopes.IPScope.DNS1)
|
||||
d.Set("dns2", network.OrgVDCNetwork.Configuration.IPScopes.IPScope.DNS2)
|
||||
if c := network.OrgVDCNetwork.Configuration; c != nil {
|
||||
d.Set("fence_mode", c.FenceMode)
|
||||
if c.IPScopes != nil {
|
||||
d.Set("gateway", c.IPScopes.IPScope.Gateway)
|
||||
d.Set("netmask", c.IPScopes.IPScope.Netmask)
|
||||
d.Set("dns1", c.IPScopes.IPScope.DNS1)
|
||||
d.Set("dns2", c.IPScopes.IPScope.DNS2)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue