diff --git a/infoblox/datasource_infoblox_zone_delegated.go b/infoblox/datasource_infoblox_zone_delegated.go index 6a047127a..f6d6772c4 100644 --- a/infoblox/datasource_infoblox_zone_delegated.go +++ b/infoblox/datasource_infoblox_zone_delegated.go @@ -184,7 +184,7 @@ func flattenZoneDelegated(zoneDelegated ibclient.ZoneDelegated) (map[string]inte res["delegated_ttl"] = *zoneDelegated.DelegatedTtl } if zoneDelegated.DelegateTo.IsNull == false { - nsInterface := convertForwardToInterface(zoneDelegated.DelegateTo) + nsInterface := convertNullableNameServersToInterface(zoneDelegated.DelegateTo) res["delegate_to"] = nsInterface } diff --git a/infoblox/datasource_infoblox_zone_forward.go b/infoblox/datasource_infoblox_zone_forward.go index 09b13df20..cb0f59624 100644 --- a/infoblox/datasource_infoblox_zone_forward.go +++ b/infoblox/datasource_infoblox_zone_forward.go @@ -229,7 +229,7 @@ func flattenZoneForward(zf ibclient.ZoneForward) (map[string]interface{}, error) } if zf.ForwardTo.IsNull == false { - nsInterface := convertForwardToInterface(zf.ForwardTo) + nsInterface := convertNullableNameServersToInterface(zf.ForwardTo) res["forward_to"] = nsInterface } @@ -251,16 +251,17 @@ func convertForwardingServersToInterface(zf []*ibclient.Forwardingmemberserver) sMap["forwarders_only"] = fs.ForwardersOnly sMap["use_override_forwarders"] = fs.UseOverrideForwarders if fs.ForwardTo.IsNull == false { - nsInterface := convertForwardToInterface(fs.ForwardTo) + nsInterface := convertNullableNameServersToInterface(fs.ForwardTo) sMap["forward_to"] = nsInterface } fwServers = append(fwServers, sMap) } return fwServers, nil } -func convertForwardToInterface(nameServers ibclient.NullForwardTo) []map[string]interface{} { - nsInterface := make([]map[string]interface{}, 0, len(nameServers.ForwardTo)) - for _, ns := range nameServers.ForwardTo { + +func convertNullableNameServersToInterface(nameServers ibclient.NullableNameServers) []map[string]interface{} { + nsInterface := make([]map[string]interface{}, 0, len(nameServers.NameServers)) + for _, ns := range nameServers.NameServers { nsMap := make(map[string]interface{}) nsMap["address"] = ns.Address nsMap["name"] = ns.Name diff --git a/infoblox/resource_infoblox_zone_delegated.go b/infoblox/resource_infoblox_zone_delegated.go index a971c70f1..c6314fc79 100644 --- a/infoblox/resource_infoblox_zone_delegated.go +++ b/infoblox/resource_infoblox_zone_delegated.go @@ -115,7 +115,7 @@ func resourceZoneDelegatedCreate(d *schema.ResourceData, m interface{}) error { dtInterface, delegateToOk := d.GetOk("delegate_to") var delegateTo []ibclient.NameServer - var nullDT ibclient.NullForwardTo + var nullDT ibclient.NullableNameServers if !nsGroupOk && !delegateToOk { return fmt.Errorf("either 'ns_group' or 'delegate_to' must be set") } @@ -126,7 +126,7 @@ func resourceZoneDelegatedCreate(d *schema.ResourceData, m interface{}) error { if err != nil { return err } - nullDT = ibclient.NullForwardTo{IsNull: false, ForwardTo: delegateTo} + nullDT = ibclient.NullableNameServers{IsNull: false, NameServers: delegateTo} } comment := d.Get("comment").(string) @@ -269,8 +269,8 @@ func resourceZoneDelegatedRead(d *schema.ResourceData, m interface{}) error { } } - if zoneDelegated.DelegateTo.ForwardTo != nil { - nsInterface := convertForwardToInterface(zoneDelegated.DelegateTo) + if zoneDelegated.DelegateTo.NameServers != nil { + nsInterface := convertNullableNameServersToInterface(zoneDelegated.DelegateTo) if err = d.Set("delegate_to", nsInterface); err != nil { return err } @@ -331,11 +331,11 @@ func resourceZoneDelegatedUpdate(d *schema.ResourceData, m interface{}) error { } var delegateTo []ibclient.NameServer - var nullDT ibclient.NullForwardTo + var nullDT ibclient.NullableNameServers if !nsGroupOk && !delegateToOk { return fmt.Errorf("either ns_group or delegate_to must be set") } else if !delegateToOk { - nullDT = ibclient.NullForwardTo{IsNull: false, ForwardTo: []ibclient.NameServer{}} + nullDT = ibclient.NullableNameServers{IsNull: false, NameServers: []ibclient.NameServer{}} } else { dtSlice := dtInterface.(*schema.Set).List() var err error @@ -343,7 +343,7 @@ func resourceZoneDelegatedUpdate(d *schema.ResourceData, m interface{}) error { if err != nil { return err } - nullDT = ibclient.NullForwardTo{IsNull: false, ForwardTo: delegateTo} + nullDT = ibclient.NullableNameServers{IsNull: false, NameServers: delegateTo} } oldExtAttrsJSON, newExtAttrsJSON := d.GetChange("ext_attrs") @@ -552,8 +552,8 @@ func resourceZoneDelegatedImport(d *schema.ResourceData, m interface{}) ([]*sche } } - if zoneDelegated.DelegateTo.ForwardTo != nil { - nsInterface := convertForwardToInterface(zoneDelegated.DelegateTo) + if zoneDelegated.DelegateTo.NameServers != nil { + nsInterface := convertNullableNameServersToInterface(zoneDelegated.DelegateTo) if err = d.Set("delegate_to", nsInterface); err != nil { return nil, err } diff --git a/infoblox/resource_infoblox_zone_delegated_test.go b/infoblox/resource_infoblox_zone_delegated_test.go index 2ed177ae1..fc10d55f5 100644 --- a/infoblox/resource_infoblox_zone_delegated_test.go +++ b/infoblox/resource_infoblox_zone_delegated_test.go @@ -157,7 +157,7 @@ func testAccZoneDelegatedCompare(t *testing.T, resPath string, expectedRec *ibcl *rec.NsGroup, *expectedRec.NsGroup) } } - if rec.DelegateTo.ForwardTo != nil && expectedRec.DelegateTo.ForwardTo != nil { + if rec.DelegateTo.NameServers != nil && expectedRec.DelegateTo.NameServers != nil { if !reflect.DeepEqual(rec.DelegateTo, expectedRec.DelegateTo) { return fmt.Errorf( "the value of 'delegate_to' field is '%v', but expected '%v'", @@ -181,9 +181,9 @@ func TestAccResourceZoneDelegated(t *testing.T) { Config: testResourceZoneDelegatedRecord, Check: testAccZoneDelegatedCompare(t, "infoblox_zone_delegated.testzd1", &ibclient.ZoneDelegated{ Fqdn: "test_zd.test3.com", - DelegateTo: ibclient.NullForwardTo{ + DelegateTo: ibclient.NullableNameServers{ IsNull: false, - ForwardTo: []ibclient.NameServer{ + NameServers: []ibclient.NameServer{ {Name: "ns2.infoblox.com", Address: "10.0.0.1"}, }}, ZoneFormat: "FORWARD", diff --git a/infoblox/resource_infoblox_zone_forward.go b/infoblox/resource_infoblox_zone_forward.go index 8e38ed3a2..362c4bf61 100644 --- a/infoblox/resource_infoblox_zone_forward.go +++ b/infoblox/resource_infoblox_zone_forward.go @@ -169,11 +169,11 @@ func resourceZoneForwardCreate(d *schema.ResourceData, m interface{}) error { ftInterface, forwardToOk := d.GetOk("forward_to") var forwardTo []ibclient.NameServer - var nullFWT ibclient.NullForwardTo + var nullFWT ibclient.NullableNameServers if !externalNsGroupOk && !forwardToOk { return fmt.Errorf("either external_ns_group or forward_to must be set") } else if !forwardToOk { - nullFWT = ibclient.NullForwardTo{IsNull: false, ForwardTo: []ibclient.NameServer{}} + nullFWT = ibclient.NullableNameServers{IsNull: false, NameServers: []ibclient.NameServer{}} } else { ftSlice, ok := ftInterface.([]interface{}) if !ok { @@ -184,7 +184,7 @@ func resourceZoneForwardCreate(d *schema.ResourceData, m interface{}) error { if err != nil { return err } - nullFWT = ibclient.NullForwardTo{IsNull: false, ForwardTo: forwardTo} + nullFWT = ibclient.NullableNameServers{IsNull: false, NameServers: forwardTo} } fqdn := d.Get("fqdn").(string) @@ -357,8 +357,8 @@ func resourceZoneForwardRead(d *schema.ResourceData, m interface{}) error { } } - if zoneForward.ForwardTo.ForwardTo != nil { - nsInterface := convertForwardToInterface(zoneForward.ForwardTo) + if zoneForward.ForwardTo.NameServers != nil { + nsInterface := convertNullableNameServersToInterface(zoneForward.ForwardTo) if err = d.Set("forward_to", nsInterface); err != nil { return err } @@ -427,11 +427,11 @@ func resourceZoneForwardUpdate(d *schema.ResourceData, m interface{}) error { } var forwardTo []ibclient.NameServer - var nullFWT ibclient.NullForwardTo + var nullFWT ibclient.NullableNameServers if !externalNsGroupOk && !forwardToOk { return fmt.Errorf("either external_ns_group or forward_to must be set") } else if !forwardToOk { - nullFWT = ibclient.NullForwardTo{IsNull: false, ForwardTo: []ibclient.NameServer{}} + nullFWT = ibclient.NullableNameServers{IsNull: false, NameServers: []ibclient.NameServer{}} } else { ftSlice, ok := ftInterface.([]interface{}) if !ok { @@ -442,7 +442,7 @@ func resourceZoneForwardUpdate(d *schema.ResourceData, m interface{}) error { if err != nil { return err } - nullFWT = ibclient.NullForwardTo{IsNull: false, ForwardTo: forwardTo} + nullFWT = ibclient.NullableNameServers{IsNull: false, NameServers: forwardTo} } oldExtAttrsJSON, newExtAttrsJSON := d.GetChange("ext_attrs") @@ -661,8 +661,8 @@ func resourceZoneForwardImport(d *schema.ResourceData, m interface{}) ([]*schema } } - if zf.ForwardTo.ForwardTo != nil { - nsInterface := convertForwardToInterface(zf.ForwardTo) + if zf.ForwardTo.NameServers != nil { + nsInterface := convertNullableNameServersToInterface(zf.ForwardTo) if err = d.Set("forward_to", nsInterface); err != nil { return nil, err } diff --git a/infoblox/resource_infoblox_zone_forward_test.go b/infoblox/resource_infoblox_zone_forward_test.go index 847705764..4b1576a5d 100644 --- a/infoblox/resource_infoblox_zone_forward_test.go +++ b/infoblox/resource_infoblox_zone_forward_test.go @@ -140,7 +140,7 @@ func testForwardZoneCompare(t *testing.T, resourceName string, expectedZF *ibcli *rec.NsGroup, *expectedZF.NsGroup) } } - if rec.ForwardTo.ForwardTo != nil && expectedZF.ForwardTo.ForwardTo != nil { + if rec.ForwardTo.NameServers != nil && expectedZF.ForwardTo.NameServers != nil { if !reflect.DeepEqual(rec.ForwardTo, expectedZF.ForwardTo) { return fmt.Errorf( "the value of 'forward_to' field is '%v', but expected '%v'", @@ -171,9 +171,9 @@ func TestAccResourceZoneForward(t *testing.T) { View: utils.StringPtr("default"), ZoneFormat: "FORWARD", Comment: utils.StringPtr("test sample forward zone"), - ForwardTo: ibclient.NullForwardTo{ + ForwardTo: ibclient.NullableNameServers{ IsNull: false, - ForwardTo: []ibclient.NameServer{ + NameServers: []ibclient.NameServer{ {Name: "test123.dz.ex.com", Address: "10.0.0.1"}, {Name: "test245.dz.ex.com", Address: "10.0.0.2"}, }},