Update go dependencies
This commit is contained in:
parent
14a9e9f3fa
commit
14f4a7b8e8
1349 changed files with 128369 additions and 32627 deletions
43
vendor/github.com/evanphx/json-patch/patch.go
generated
vendored
43
vendor/github.com/evanphx/json-patch/patch.go
generated
vendored
|
|
@ -14,8 +14,6 @@ const (
|
|||
eAry
|
||||
)
|
||||
|
||||
var SupportNegativeIndices bool = true
|
||||
|
||||
type lazyNode struct {
|
||||
raw *json.RawMessage
|
||||
doc partialDoc
|
||||
|
|
@ -206,7 +204,7 @@ func (n *lazyNode) equal(o *lazyNode) bool {
|
|||
}
|
||||
|
||||
func (o operation) kind() string {
|
||||
if obj, ok := o["op"]; ok && obj != nil {
|
||||
if obj, ok := o["op"]; ok {
|
||||
var op string
|
||||
|
||||
err := json.Unmarshal(*obj, &op)
|
||||
|
|
@ -222,7 +220,7 @@ func (o operation) kind() string {
|
|||
}
|
||||
|
||||
func (o operation) path() string {
|
||||
if obj, ok := o["path"]; ok && obj != nil {
|
||||
if obj, ok := o["path"]; ok {
|
||||
var op string
|
||||
|
||||
err := json.Unmarshal(*obj, &op)
|
||||
|
|
@ -238,7 +236,7 @@ func (o operation) path() string {
|
|||
}
|
||||
|
||||
func (o operation) from() string {
|
||||
if obj, ok := o["from"]; ok && obj != nil {
|
||||
if obj, ok := o["from"]; ok {
|
||||
var op string
|
||||
|
||||
err := json.Unmarshal(*obj, &op)
|
||||
|
|
@ -391,18 +389,13 @@ func (d *partialArray) add(key string, val *lazyNode) error {
|
|||
|
||||
cur := *d
|
||||
|
||||
if idx >= len(ary) {
|
||||
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
||||
}
|
||||
if idx < 0 {
|
||||
idx *= -1
|
||||
|
||||
if SupportNegativeIndices {
|
||||
if idx < -len(ary) {
|
||||
if idx > len(ary) {
|
||||
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
||||
}
|
||||
|
||||
if idx < 0 {
|
||||
idx += len(ary)
|
||||
}
|
||||
idx = len(ary) - idx
|
||||
}
|
||||
|
||||
copy(ary[0:idx], cur[0:idx])
|
||||
|
|
@ -436,17 +429,7 @@ func (d *partialArray) remove(key string) error {
|
|||
cur := *d
|
||||
|
||||
if idx >= len(cur) {
|
||||
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
||||
}
|
||||
|
||||
if SupportNegativeIndices {
|
||||
if idx < -len(cur) {
|
||||
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
||||
}
|
||||
|
||||
if idx < 0 {
|
||||
idx += len(cur)
|
||||
}
|
||||
return fmt.Errorf("Unable to remove invalid index: %d", idx)
|
||||
}
|
||||
|
||||
ary := make([]*lazyNode, len(cur)-1)
|
||||
|
|
@ -465,7 +448,7 @@ func (p Patch) add(doc *container, op operation) error {
|
|||
con, key := findObject(doc, path)
|
||||
|
||||
if con == nil {
|
||||
return fmt.Errorf("jsonpatch add operation does not apply: doc is missing path: \"%s\"", path)
|
||||
return fmt.Errorf("jsonpatch add operation does not apply: doc is missing path: %s", path)
|
||||
}
|
||||
|
||||
return con.add(key, op.value())
|
||||
|
|
@ -477,7 +460,7 @@ func (p Patch) remove(doc *container, op operation) error {
|
|||
con, key := findObject(doc, path)
|
||||
|
||||
if con == nil {
|
||||
return fmt.Errorf("jsonpatch remove operation does not apply: doc is missing path: \"%s\"", path)
|
||||
return fmt.Errorf("jsonpatch remove operation does not apply: doc is missing path: %s", path)
|
||||
}
|
||||
|
||||
return con.remove(key)
|
||||
|
|
@ -492,8 +475,8 @@ func (p Patch) replace(doc *container, op operation) error {
|
|||
return fmt.Errorf("jsonpatch replace operation does not apply: doc is missing path: %s", path)
|
||||
}
|
||||
|
||||
_, ok := con.get(key)
|
||||
if ok != nil {
|
||||
val, ok := con.get(key)
|
||||
if val == nil || ok != nil {
|
||||
return fmt.Errorf("jsonpatch replace operation does not apply: doc is missing key: %s", path)
|
||||
}
|
||||
|
||||
|
|
@ -550,8 +533,6 @@ func (p Patch) test(doc *container, op operation) error {
|
|||
return nil
|
||||
}
|
||||
return fmt.Errorf("Testing value %s failed", path)
|
||||
} else if op.value() == nil {
|
||||
return fmt.Errorf("Testing value %s failed", path)
|
||||
}
|
||||
|
||||
if val.equal(op.value()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue