in pkg/utils/patch/patch.go [30:47]
func CreateMergePatch(original, modified interface{}) ([]byte, bool, error) {
originalBytes, err := json.Marshal(original)
if err != nil {
return nil, false, fmt.Errorf("json.Marshal(): %w", err)
}
modifiedBytes, err := json.Marshal(modified)
if err != nil {
return nil, false, fmt.Errorf("json.Marshal(): %w", err)
}
if jsonpatch.Equal(originalBytes, modifiedBytes) {
return nil, false, nil
}
patchBytes, err := jsonpatch.CreateMergePatch(originalBytes, modifiedBytes)
if err != nil {
return nil, false, fmt.Errorf("jsonpatch.CreateMergePatch(): %w", err)
}
return patchBytes, true, nil
}