Skip to content

Commit 65febc5

Browse files
authored
fixed dtc modules drift (#465)
1 parent 70cc3cd commit 65febc5

3 files changed

+21
-12
lines changed

infoblox/resource_infoblox_dtc_lbdn.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,12 @@ func resourceDtcLbdnGet(d *schema.ResourceData, m interface{}) error {
302302

303303
rec, err := searchObjectByRefOrInternalId("DtcLbdn", d, m)
304304
if err != nil {
305-
if _, ok := err.(*ibclient.NotFoundError); !ok {
306-
return ibclient.NewNotFoundError(fmt.Sprintf(
307-
"cannot find appropriate object on NIOS side for resource with ID '%s': %s;", d.Id(), err))
308-
} else {
305+
if _, ok := err.(*ibclient.NotFoundError); ok {
309306
d.SetId("")
310307
return nil
308+
} else {
309+
return ibclient.NewNotFoundError(fmt.Sprintf(
310+
"cannot find appropriate object on NIOS side for resource with ID '%s': %s;", d.Id(), err))
311311
}
312312
}
313313

@@ -429,6 +429,7 @@ func resourceDtcLbdnGet(d *schema.ResourceData, m interface{}) error {
429429
return err
430430
}
431431

432+
d.SetId(dtcLbdn.Ref)
432433
return nil
433434
}
434435

infoblox/resource_infoblox_dtc_pool.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,12 @@ func resourceDtcPoolGet(d *schema.ResourceData, m interface{}) error {
510510
connector := m.(ibclient.IBConnector)
511511
rec, err := searchObjectByRefOrInternalId("DtcPool", d, m)
512512
if err != nil {
513-
if _, ok := err.(*ibclient.NotFoundError); !ok {
514-
return ibclient.NewNotFoundError(fmt.Sprintf(
515-
"cannot find appropriate object on NIOS side for resource with ID '%s': %s;", d.Id(), err))
516-
} else {
513+
if _, ok := err.(*ibclient.NotFoundError); ok {
517514
d.SetId("")
518515
return nil
516+
} else {
517+
return ibclient.NewNotFoundError(fmt.Sprintf(
518+
"cannot find appropriate object on NIOS side for resource with ID '%s': %s;", d.Id(), err))
519519
}
520520
}
521521
var dtcPool *ibclient.DtcPool
@@ -643,6 +643,10 @@ func resourceDtcPoolGet(d *schema.ResourceData, m interface{}) error {
643643
}
644644
}
645645

646+
if err = d.Set("ref", dtcPool.Ref); err != nil {
647+
return err
648+
}
649+
d.SetId(dtcPool.Ref)
646650
return nil
647651
}
648652

infoblox/resource_infoblox_dtc_server.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ func resourceDtcServerGet(d *schema.ResourceData, m interface{}) error {
189189
connector := m.(ibclient.IBConnector)
190190
rec, err := searchObjectByRefOrInternalId("DtcServer", d, m)
191191
if err != nil {
192-
if _, ok := err.(*ibclient.NotFoundError); !ok {
193-
return ibclient.NewNotFoundError(fmt.Sprintf(
194-
"cannot find appropriate object on NIOS side for resource with ID '%s': %s;", d.Id(), err))
195-
} else {
192+
if _, ok := err.(*ibclient.NotFoundError); ok {
196193
d.SetId("")
197194
return nil
195+
} else {
196+
return ibclient.NewNotFoundError(fmt.Sprintf(
197+
"cannot find appropriate object on NIOS side for resource with ID '%s': %s;", d.Id(), err))
198198
}
199199
}
200200
var dtcServer *ibclient.DtcServer
@@ -244,6 +244,10 @@ func resourceDtcServerGet(d *schema.ResourceData, m interface{}) error {
244244
if err = d.Set("use_sni_hostname", dtcServer.UseSniHostname); err != nil {
245245
return err
246246
}
247+
if err = d.Set("ref", dtcServer.Ref); err != nil {
248+
return err
249+
}
250+
d.SetId(dtcServer.Ref)
247251
return nil
248252
}
249253

0 commit comments

Comments
 (0)