mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
update json-patch to pick up bug fixes
This commit is contained in:
parent
5468b8d5cb
commit
404c057b67
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
@ -1555,8 +1555,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Comment": "v4.0.0-3-g36442dbdb58521",
|
"Comment": "v4.1.0-11-gd4020504c68b6b",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/exponent-io/jsonpath",
|
"ImportPath": "github.com/exponent-io/jsonpath",
|
||||||
|
@ -372,7 +372,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/ghodss/yaml",
|
"ImportPath": "github.com/ghodss/yaml",
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
2
staging/src/k8s.io/apiserver/Godeps/Godeps.json
generated
2
staging/src/k8s.io/apiserver/Godeps/Godeps.json
generated
@ -372,7 +372,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/ghodss/yaml",
|
"ImportPath": "github.com/ghodss/yaml",
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
2
staging/src/k8s.io/client-go/Godeps/Godeps.json
generated
2
staging/src/k8s.io/client-go/Godeps/Godeps.json
generated
@ -56,7 +56,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
2
staging/src/k8s.io/csi-api/Godeps/Godeps.json
generated
2
staging/src/k8s.io/csi-api/Godeps/Godeps.json
generated
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/go-openapi/jsonpointer",
|
"ImportPath": "github.com/go-openapi/jsonpointer",
|
||||||
|
2
staging/src/k8s.io/metrics/Godeps/Godeps.json
generated
2
staging/src/k8s.io/metrics/Godeps/Godeps.json
generated
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
2
staging/src/k8s.io/node-api/Godeps/Godeps.json
generated
2
staging/src/k8s.io/node-api/Godeps/Godeps.json
generated
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/go-openapi/jsonpointer",
|
"ImportPath": "github.com/go-openapi/jsonpointer",
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "36442dbdb585210f8d5a1b45e67aa323c197d5c4"
|
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
|
17
vendor/github.com/evanphx/json-patch/README.md
generated
vendored
17
vendor/github.com/evanphx/json-patch/README.md
generated
vendored
@ -25,6 +25,23 @@ go get -u github.com/evanphx/json-patch
|
|||||||
* [Comparing JSON documents](#comparing-json-documents)
|
* [Comparing JSON documents](#comparing-json-documents)
|
||||||
* [Combine merge patches](#combine-merge-patches)
|
* [Combine merge patches](#combine-merge-patches)
|
||||||
|
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
* There is a global configuration variable `jsonpatch.SupportNegativeIndices`.
|
||||||
|
This defaults to `true` and enables the non-standard practice of allowing
|
||||||
|
negative indices to mean indices starting at the end of an array. This
|
||||||
|
functionality can be disabled by setting `jsonpatch.SupportNegativeIndices =
|
||||||
|
false`.
|
||||||
|
|
||||||
|
* There is a global configuration variable `jsonpatch.ArraySizeLimit`, which
|
||||||
|
limits the length of any array the patched object can have. It defaults to 0,
|
||||||
|
which means there is no limit.
|
||||||
|
|
||||||
|
* There is a global configuration variable `jsonpatch.ArraySizeAdditionLimit`,
|
||||||
|
which limits the increase of array length caused by each operation. It
|
||||||
|
defaults to 0, which means there is no limit.
|
||||||
|
|
||||||
## Create and apply a merge patch
|
## Create and apply a merge patch
|
||||||
Given both an original JSON document and a modified JSON document, you can create
|
Given both an original JSON document and a modified JSON document, you can create
|
||||||
a [Merge Patch](https://tools.ietf.org/html/rfc7396) document.
|
a [Merge Patch](https://tools.ietf.org/html/rfc7396) document.
|
||||||
|
60
vendor/github.com/evanphx/json-patch/patch.go
generated
vendored
60
vendor/github.com/evanphx/json-patch/patch.go
generated
vendored
@ -14,6 +14,10 @@ const (
|
|||||||
eAry
|
eAry
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var SupportNegativeIndices bool = true
|
||||||
|
var ArraySizeLimit int = 0
|
||||||
|
var ArraySizeAdditionLimit int = 0
|
||||||
|
|
||||||
type lazyNode struct {
|
type lazyNode struct {
|
||||||
raw *json.RawMessage
|
raw *json.RawMessage
|
||||||
doc partialDoc
|
doc partialDoc
|
||||||
@ -61,6 +65,19 @@ func (n *lazyNode) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deepCopy(src *lazyNode) (*lazyNode, error) {
|
||||||
|
if src == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
a, err := src.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
ra := make(json.RawMessage, len(a))
|
||||||
|
copy(ra, a)
|
||||||
|
return newLazyNode(&ra), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (n *lazyNode) intoDoc() (*partialDoc, error) {
|
func (n *lazyNode) intoDoc() (*partialDoc, error) {
|
||||||
if n.which == eDoc {
|
if n.which == eDoc {
|
||||||
return &n.doc, nil
|
return &n.doc, nil
|
||||||
@ -354,10 +371,19 @@ func (d *partialArray) set(key string, val *lazyNode) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sz := len(*d)
|
sz := len(*d)
|
||||||
|
|
||||||
|
if diff := idx + 1 - sz; ArraySizeAdditionLimit > 0 && diff > ArraySizeAdditionLimit {
|
||||||
|
return fmt.Errorf("Unable to increase the array size by %d, the limit is %d", diff, ArraySizeAdditionLimit)
|
||||||
|
}
|
||||||
|
|
||||||
if idx+1 > sz {
|
if idx+1 > sz {
|
||||||
sz = idx + 1
|
sz = idx + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ArraySizeLimit > 0 && sz > ArraySizeLimit {
|
||||||
|
return fmt.Errorf("Unable to create array of size %d, limit is %d", sz, ArraySizeLimit)
|
||||||
|
}
|
||||||
|
|
||||||
ary := make([]*lazyNode, sz)
|
ary := make([]*lazyNode, sz)
|
||||||
|
|
||||||
cur := *d
|
cur := *d
|
||||||
@ -385,17 +411,29 @@ func (d *partialArray) add(key string, val *lazyNode) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ary := make([]*lazyNode, len(*d)+1)
|
sz := len(*d) + 1
|
||||||
|
if ArraySizeLimit > 0 && sz > ArraySizeLimit {
|
||||||
|
return fmt.Errorf("Unable to create array of size %d, limit is %d", sz, ArraySizeLimit)
|
||||||
|
}
|
||||||
|
|
||||||
|
ary := make([]*lazyNode, sz)
|
||||||
|
|
||||||
cur := *d
|
cur := *d
|
||||||
|
|
||||||
if idx < -len(ary) || idx >= len(ary) {
|
if idx >= len(ary) {
|
||||||
|
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
||||||
|
}
|
||||||
|
|
||||||
|
if SupportNegativeIndices {
|
||||||
|
if idx < -len(ary) {
|
||||||
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if idx < 0 {
|
if idx < 0 {
|
||||||
idx += len(ary)
|
idx += len(ary)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
copy(ary[0:idx], cur[0:idx])
|
copy(ary[0:idx], cur[0:idx])
|
||||||
ary[idx] = val
|
ary[idx] = val
|
||||||
copy(ary[idx+1:], cur[idx:])
|
copy(ary[idx+1:], cur[idx:])
|
||||||
@ -426,12 +464,19 @@ func (d *partialArray) remove(key string) error {
|
|||||||
|
|
||||||
cur := *d
|
cur := *d
|
||||||
|
|
||||||
if idx < -len(cur) || idx >= len(cur) {
|
if idx >= len(cur) {
|
||||||
return fmt.Errorf("Unable to remove invalid index: %d", idx)
|
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 {
|
if idx < 0 {
|
||||||
idx += len(cur)
|
idx += len(cur)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ary := make([]*lazyNode, len(cur)-1)
|
ary := make([]*lazyNode, len(cur)-1)
|
||||||
|
|
||||||
@ -567,7 +612,12 @@ func (p Patch) copy(doc *container, op operation) error {
|
|||||||
return fmt.Errorf("jsonpatch copy operation does not apply: doc is missing destination path: %s", path)
|
return fmt.Errorf("jsonpatch copy operation does not apply: doc is missing destination path: %s", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return con.set(key, val)
|
valCopy, err := deepCopy(val)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return con.add(key, valCopy)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Equal indicates if 2 JSON documents have the same structural equality.
|
// Equal indicates if 2 JSON documents have the same structural equality.
|
||||||
|
Loading…
Reference in New Issue
Block a user