Revert to json-patch 4.12.0

This commit is contained in:
Jordan Liggitt
2023-08-31 19:01:37 -04:00
parent 8b132ea40a
commit 741f146157
49 changed files with 110 additions and 68 deletions

View File

@@ -568,6 +568,29 @@ func (p Patch) replace(doc *container, op Operation) error {
return errors.Wrapf(err, "replace operation failed to decode path")
}
if path == "" {
val := op.value()
if val.which == eRaw {
if !val.tryDoc() {
if !val.tryAry() {
return errors.Wrapf(err, "replace operation value must be object or array")
}
}
}
switch val.which {
case eAry:
*doc = &val.ary
case eDoc:
*doc = &val.doc
case eRaw:
return errors.Wrapf(err, "replace operation hit impossible case")
}
return nil
}
con, key := findObject(doc, path)
if con == nil {
@@ -634,6 +657,25 @@ func (p Patch) test(doc *container, op Operation) error {
return errors.Wrapf(err, "test operation failed to decode path")
}
if path == "" {
var self lazyNode
switch sv := (*doc).(type) {
case *partialDoc:
self.doc = *sv
self.which = eDoc
case *partialArray:
self.ary = *sv
self.which = eAry
}
if self.equal(op.value()) {
return nil
}
return errors.Wrapf(ErrTestFailed, "testing value %s failed", path)
}
con, key := findObject(doc, path)
if con == nil {

2
vendor/modules.txt vendored
View File

@@ -202,7 +202,7 @@ github.com/emicklei/go-restful/v3/log
# github.com/euank/go-kmsg-parser v2.0.0+incompatible
## explicit
github.com/euank/go-kmsg-parser/kmsgparser
# github.com/evanphx/json-patch v5.6.0+incompatible
# github.com/evanphx/json-patch v4.12.0+incompatible
## explicit
github.com/evanphx/json-patch
# github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d