VOL-1900 lint warning fixes db
Change-Id: Iaa4e5c271c9e1d7c8ebce1e13c7e723ea4762304
diff --git a/db/model/root.go b/db/model/root.go
index bca2d4f..24cfe46 100644
--- a/db/model/root.go
+++ b/db/model/root.go
@@ -20,12 +20,13 @@
"context"
"encoding/hex"
"encoding/json"
+ "reflect"
+ "sync"
+
"github.com/golang/protobuf/proto"
"github.com/google/uuid"
"github.com/opencord/voltha-lib-go/v2/pkg/db"
"github.com/opencord/voltha-lib-go/v2/pkg/log"
- "reflect"
- "sync"
)
// Root is used to provide an abstraction to the base root structure
@@ -53,7 +54,7 @@
}
// NewRoot creates an new instance of a root object
-func NewRoot(initialData interface{}, kvStore *db.Backend) *root {
+func NewRoot(initialData interface{}, kvStore *db.Backend) Root {
root := &root{}
root.KvStore = kvStore
@@ -71,7 +72,7 @@
root.Callbacks = []CallbackTuple{}
root.NotificationCallbacks = []CallbackTuple{}
- root.node = NewNode(root, initialData, false, "")
+ root.node = newNode(root, initialData, false, "")
return root
}
@@ -104,7 +105,9 @@
// Merge operation fails
r.DeleteTxBranch(txid)
} else {
- r.node.MergeBranch(txid, false)
+ if _, err = r.node.MergeBranch(txid, false); err != nil {
+ log.Errorw("Unable to integrate the contents of a transaction branch within the latest branch of a given node", log.Fields{"error": err})
+ }
r.node.GetRoot().ExecuteCallbacks()
r.DeleteTxBranch(txid)
}
@@ -127,10 +130,6 @@
//}
}
-func (r *root) hasCallbacks() bool {
- return len(r.Callbacks) > 0
-}
-
// getCallbacks returns the available callbacks
func (r *root) GetCallbacks() []CallbackTuple {
r.mutex.Lock()
@@ -166,7 +165,7 @@
func (r *root) syncParent(childRev Revision, txid string) {
data := proto.Clone(r.GetProxy().ParentNode.Latest().GetData().(proto.Message))
- for fieldName, _ := range ChildrenFields(data) {
+ for fieldName := range ChildrenFields(data) {
childDataName, childDataHolder := GetAttributeValue(data, fieldName, 0)
if reflect.TypeOf(childRev.GetData()) == reflect.TypeOf(childDataHolder.Interface()) {
childDataHolder = reflect.ValueOf(childRev.GetData())
@@ -182,14 +181,6 @@
func (r *root) Update(ctx context.Context, path string, data interface{}, strict bool, txid string, makeBranch MakeBranchFunction) Revision {
var result Revision
- if makeBranch != nil {
- // TODO: raise error
- }
-
- if r.hasCallbacks() {
- // TODO: raise error
- }
-
if txid != "" {
trackDirty := func(node *node) *Branch {
r.DirtyNodes[txid] = append(r.DirtyNodes[txid], node)
@@ -217,14 +208,6 @@
func (r *root) Add(ctx context.Context, path string, data interface{}, txid string, makeBranch MakeBranchFunction) Revision {
var result Revision
- if makeBranch != nil {
- // TODO: raise error
- }
-
- if r.hasCallbacks() {
- // TODO: raise error
- }
-
if txid != "" {
trackDirty := func(node *node) *Branch {
r.DirtyNodes[txid] = append(r.DirtyNodes[txid], node)
@@ -246,14 +229,6 @@
func (r *root) Remove(ctx context.Context, path string, txid string, makeBranch MakeBranchFunction) Revision {
var result Revision
- if makeBranch != nil {
- // TODO: raise error
- }
-
- if r.hasCallbacks() {
- // TODO: raise error
- }
-
if txid != "" {
trackDirty := func(node *node) *Branch {
r.DirtyNodes[txid] = append(r.DirtyNodes[txid], node)