Cleaned up what-changed race condition issues #165

A few small async issues needed attention.

Signed-off-by: Quobix <dave@quobix.com>
This commit is contained in:
Quobix
2023-08-28 12:20:36 -04:00
committed by quobix
parent 92a820b5c4
commit 4879ccc489

View File

@@ -19,6 +19,8 @@ const (
EMPTY_STR = ""
)
var changeMutex sync.Mutex
// CreateChange is a generic function that will create a Change of type T, populate all properties if set, and then
// add a pointer to Change[T] in the slice of Change pointers provided
func CreateChange(changes *[]*Change, changeType int, property string, leftValueNode, rightValueNode *yaml.Node,
@@ -45,7 +47,9 @@ func CreateChange(changes *[]*Change, changeType int, property string, leftValue
c.NewObject = newObject
// add the change to supplied changes slice
changeMutex.Lock()
*changes = append(*changes, c)
changeMutex.Unlock()
return changes
}