Skip to content

Commit

Permalink
changing name of NullForwardTo struct to NullableServers for zone-for…
Browse files Browse the repository at this point in the history
…ward and zone-delegated objects.
  • Loading branch information
Aish-sp committed Aug 28, 2024
1 parent f5f6195 commit 36d74a1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion infoblox/datasource_infoblox_zone_delegated.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func flattenZoneDelegated(zoneDelegated ibclient.ZoneDelegated) (map[string]inte
res["delegated_ttl"] = *zoneDelegated.DelegatedTtl
}
if zoneDelegated.DelegateTo.IsNull == false {

Check failure on line 186 in infoblox/datasource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

zoneDelegated.DelegateTo.IsNull undefined (type []ibclient.NameServer has no field or method IsNull)

Check failure on line 186 in infoblox/datasource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

zoneDelegated.DelegateTo.IsNull undefined (type []ibclient.NameServer has no field or method IsNull)
nsInterface := convertForwardToInterface(zoneDelegated.DelegateTo)
nsInterface := convertNullableNameServersToInterface(zoneDelegated.DelegateTo)
res["delegate_to"] = nsInterface
}

Expand Down
11 changes: 6 additions & 5 deletions infoblox/datasource_infoblox_zone_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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{} {

Check failure on line 262 in infoblox/datasource_infoblox_zone_forward.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

undefined: ibclient.NullableNameServers

Check failure on line 262 in infoblox/datasource_infoblox_zone_forward.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

undefined: ibclient.NullableNameServers
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
Expand Down
18 changes: 9 additions & 9 deletions infoblox/resource_infoblox_zone_delegated.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check failure on line 118 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

undefined: ibclient.NullableNameServers

Check failure on line 118 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

undefined: ibclient.NullableNameServers
if !nsGroupOk && !delegateToOk {
return fmt.Errorf("either 'ns_group' or 'delegate_to' must be set")
}
Expand All @@ -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}

Check failure on line 129 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

undefined: ibclient.NullableNameServers

Check failure on line 129 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

undefined: ibclient.NullableNameServers
}

comment := d.Get("comment").(string)
Expand Down Expand Up @@ -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 {

Check failure on line 272 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

zoneDelegated.DelegateTo.NameServers undefined (type []ibclient.NameServer has no field or method NameServers)

Check failure on line 272 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

zoneDelegated.DelegateTo.NameServers undefined (type []ibclient.NameServer has no field or method NameServers)
nsInterface := convertNullableNameServersToInterface(zoneDelegated.DelegateTo)
if err = d.Set("delegate_to", nsInterface); err != nil {
return err
}
Expand Down Expand Up @@ -331,19 +331,19 @@ func resourceZoneDelegatedUpdate(d *schema.ResourceData, m interface{}) error {
}

var delegateTo []ibclient.NameServer
var nullDT ibclient.NullForwardTo
var nullDT ibclient.NullableNameServers

Check failure on line 334 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

undefined: ibclient.NullableNameServers

Check failure on line 334 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

undefined: 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{}}

Check failure on line 338 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

undefined: ibclient.NullableNameServers

Check failure on line 338 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

undefined: ibclient.NullableNameServers
} else {
dtSlice := dtInterface.(*schema.Set).List()
var err error
delegateTo, err = validateForwardTo(dtSlice)
if err != nil {
return err
}
nullDT = ibclient.NullForwardTo{IsNull: false, ForwardTo: delegateTo}
nullDT = ibclient.NullableNameServers{IsNull: false, NameServers: delegateTo}

Check failure on line 346 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest, 1.21)

undefined: ibclient.NullableNameServers

Check failure on line 346 in infoblox/resource_infoblox_zone_delegated.go

View workflow job for this annotation

GitHub Actions / Test (macOS-latest, 1.21)

undefined: ibclient.NullableNameServers
}

oldExtAttrsJSON, newExtAttrsJSON := d.GetChange("ext_attrs")
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions infoblox/resource_infoblox_zone_delegated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand All @@ -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",
Expand Down
20 changes: 10 additions & 10 deletions infoblox/resource_infoblox_zone_forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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")
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions infoblox/resource_infoblox_zone_forward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down Expand Up @@ -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"},
}},
Expand Down

0 comments on commit 36d74a1

Please sign in to comment.