Skip to content

Commit

Permalink
Additional Point for existing Customer: If no Internal ID exist then …
Browse files Browse the repository at this point in the history
…don't go for EA Search and always search with Ref and get back second search only works if NotFound by ref and InternalID is present.
  • Loading branch information
sdas-infoblox committed Feb 23, 2024
1 parent 54960a0 commit 486fcb9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions object_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,22 +425,20 @@ func (objMgr *ObjectManager) DeleteZoneDelegated(ref string) (string, error) {
// Generic function to search object by alternate id
func (objMgr *ObjectManager) SearchDnsObjectByAltId(
objType string, ref string, internalId string, eaNameForInternalId string) (interface{}, error) {
var err error
if internalId == "" {
return nil, fmt.Errorf("internal ID must not be empty")
}
var (
err error
recordType IBObject
res interface{}
)

var recordType IBObject
if getRecordTypeMap[objType] != nil {
recordType = getRecordTypeMap[objType]()
} else {
return nil, fmt.Errorf("unknown record type")
}

var res interface{}
if ref != "" {
if err := objMgr.connector.GetObject(recordType, ref, NewQueryParams(false, nil), &res); err != nil {
fmt.Println("Error ", err.Error())
if _, ok := err.(*NotFoundError); !ok {
return nil, err
}
Expand All @@ -450,6 +448,10 @@ func (objMgr *ObjectManager) SearchDnsObjectByAltId(
}
}

if internalId == "" {
return nil, err
}

sf := map[string]string{
fmt.Sprintf("*%s", eaNameForInternalId): internalId,
}
Expand Down

0 comments on commit 486fcb9

Please sign in to comment.