Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change return value and type for UpdateTXTRecord. Fixes #113 #114

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions object_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type IBObjectManager interface {
CreateNetworkView(name string) (*NetworkView, error)
CreatePTRRecord(netview string, dnsview string, recordname string, cidr string, ipAddr string, ea EA) (*RecordPTR, error)
DeleteARecord(ref string) (string, error)
DeleteZoneAuth(ref string) (string, error)
DeleteZoneAuth(ref string) (string, error)
DeleteCNAMERecord(ref string) (string, error)
DeleteFixedAddress(ref string) (string, error)
DeleteHostRecord(ref string) (string, error)
Expand Down Expand Up @@ -615,28 +615,28 @@ func (objMgr *ObjectManager) GetTXTRecord(name string) (*RecordTXT, error) {
return &res[0], nil
}

func (objMgr *ObjectManager) UpdateTXTRecord(recordname string, text string) (*RecordTXT, error) {
func (objMgr *ObjectManager) UpdateTXTRecord(recordname string, text string) (string, error) {
var res []RecordTXT

recordTXT := NewRecordTXT(RecordTXT{Name: recordname})

err := objMgr.connector.GetObject(recordTXT, "", &res)

if len(res) == 0 {
return nil, nil
return "", nil
}

res[0].Text = text

res[0].Zone = "" // set the Zone value to "" as its a non writable field

_, err = objMgr.connector.UpdateObject(&res[0], res[0].Ref)
ref, err := objMgr.connector.UpdateObject(&res[0], res[0].Ref)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference of the object can be updated after this line.
res[0].Ref=ref


if err != nil || res == nil || len(res) == 0 {
return nil, err
return "", err
}

return &res[0], nil
return ref, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest returning of pointer to the object by updating the reference of the object beforehand.

}

func (objMgr *ObjectManager) DeleteTXTRecord(ref string) (string, error) {
Expand Down Expand Up @@ -761,16 +761,15 @@ func (objMgr *ObjectManager) CreateZoneAuth(fqdn string, ea EA) (*ZoneAuth, erro
eas := objMgr.extendEA(ea)

zoneAuth := NewZoneAuth(ZoneAuth{
Fqdn: fqdn,
Ea: eas})

Fqdn: fqdn,
Ea: eas})

ref, err := objMgr.connector.CreateObject(zoneAuth)
zoneAuth.Ref = ref
return zoneAuth, err
}

// Retreive a authortative zone by ref
// Retreive a authortative zone by ref
func (objMgr *ObjectManager) GetZoneAuthByRef(ref string) (ZoneAuth, error) {
var res ZoneAuth

Expand Down