mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-24 22:23:02 +00:00
Merge pull request #73713 from caesarxuchao/bump-json-patch-again
Importing the latest json patch and set the accumulated copy size limit Kubernetes-commit: b00b5d4ac00cab50b50554ce2a9212e1cd689496
This commit is contained in:
commit
5846423975
104
Godeps/Godeps.json
generated
104
Godeps/Godeps.json
generated
@ -56,7 +56,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "d4020504c68b6bfa818032bedfb48e33e9638506"
|
"Rev": "5858425f75500d40c52783dce87d085a483ce135"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/gogo/protobuf/proto",
|
"ImportPath": "github.com/gogo/protobuf/proto",
|
||||||
@ -404,207 +404,207 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/fuzzer",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/apitesting/roundtrip",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/equality",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/errors",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/meta",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
"ImportPath": "k8s.io/apimachinery/pkg/api/resource",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
|
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1beta1",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
"ImportPath": "k8s.io/apimachinery/pkg/conversion",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
"ImportPath": "k8s.io/apimachinery/pkg/fields",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
"ImportPath": "k8s.io/apimachinery/pkg/labels",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
"ImportPath": "k8s.io/apimachinery/pkg/selection",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
"ImportPath": "k8s.io/apimachinery/pkg/types",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/cache",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/clock",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/diff",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/errors",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/framer",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/json",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/naming",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/net",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/sets",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/validation",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/wait",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
"ImportPath": "k8s.io/apimachinery/pkg/version",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
"ImportPath": "k8s.io/apimachinery/pkg/watch",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
|
||||||
"Rev": "4b4ea28f279089e0cfafcc2d47479a5bd1a0964f"
|
"Rev": "095b9d2034671175d5f4d8c61040516f2ce9d05e"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/klog",
|
"ImportPath": "k8s.io/klog",
|
||||||
|
10
vendor/github.com/evanphx/json-patch/README.md
generated
vendored
10
vendor/github.com/evanphx/json-patch/README.md
generated
vendored
@ -34,13 +34,9 @@ go get -u github.com/evanphx/json-patch
|
|||||||
functionality can be disabled by setting `jsonpatch.SupportNegativeIndices =
|
functionality can be disabled by setting `jsonpatch.SupportNegativeIndices =
|
||||||
false`.
|
false`.
|
||||||
|
|
||||||
* There is a global configuration variable `jsonpatch.ArraySizeLimit`, which
|
* There is a global configuration variable `jsonpatch.AccumulatedCopySizeLimit`,
|
||||||
limits the length of any array the patched object can have. It defaults to 0,
|
which limits the total size increase in bytes caused by "copy" operations in a
|
||||||
which means there is no limit.
|
patch. 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
|
||||||
|
38
vendor/github.com/evanphx/json-patch/errors.go
generated
vendored
Normal file
38
vendor/github.com/evanphx/json-patch/errors.go
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package jsonpatch
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// AccumulatedCopySizeError is an error type returned when the accumulated size
|
||||||
|
// increase caused by copy operations in a patch operation has exceeded the
|
||||||
|
// limit.
|
||||||
|
type AccumulatedCopySizeError struct {
|
||||||
|
limit int64
|
||||||
|
accumulated int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAccumulatedCopySizeError returns an AccumulatedCopySizeError.
|
||||||
|
func NewAccumulatedCopySizeError(l, a int64) *AccumulatedCopySizeError {
|
||||||
|
return &AccumulatedCopySizeError{limit: l, accumulated: a}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
|
func (a *AccumulatedCopySizeError) Error() string {
|
||||||
|
return fmt.Sprintf("Unable to complete the copy, the accumulated size increase of copy is %d, exceeding the limit %d", a.accumulated, a.limit)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ArraySizeError is an error type returned when the array size has exceeded
|
||||||
|
// the limit.
|
||||||
|
type ArraySizeError struct {
|
||||||
|
limit int
|
||||||
|
size int
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewArraySizeError returns an ArraySizeError.
|
||||||
|
func NewArraySizeError(l, s int) *ArraySizeError {
|
||||||
|
return &ArraySizeError{limit: l, size: s}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error implements the error interface.
|
||||||
|
func (a *ArraySizeError) Error() string {
|
||||||
|
return fmt.Sprintf("Unable to create array of size %d, limit is %d", a.size, a.limit)
|
||||||
|
}
|
76
vendor/github.com/evanphx/json-patch/patch.go
generated
vendored
76
vendor/github.com/evanphx/json-patch/patch.go
generated
vendored
@ -14,9 +14,15 @@ const (
|
|||||||
eAry
|
eAry
|
||||||
)
|
)
|
||||||
|
|
||||||
var SupportNegativeIndices bool = true
|
var (
|
||||||
var ArraySizeLimit int = 0
|
// SupportNegativeIndices decides whether to support non-standard practice of
|
||||||
var ArraySizeAdditionLimit int = 0
|
// allowing negative indices to mean indices starting at the end of an array.
|
||||||
|
// Default to true.
|
||||||
|
SupportNegativeIndices bool = true
|
||||||
|
// AccumulatedCopySizeLimit limits the total size increase in bytes caused by
|
||||||
|
// "copy" operations in a patch.
|
||||||
|
AccumulatedCopySizeLimit int64 = 0
|
||||||
|
)
|
||||||
|
|
||||||
type lazyNode struct {
|
type lazyNode struct {
|
||||||
raw *json.RawMessage
|
raw *json.RawMessage
|
||||||
@ -65,17 +71,18 @@ func (n *lazyNode) UnmarshalJSON(data []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func deepCopy(src *lazyNode) (*lazyNode, error) {
|
func deepCopy(src *lazyNode) (*lazyNode, int, error) {
|
||||||
if src == nil {
|
if src == nil {
|
||||||
return nil, nil
|
return nil, 0, nil
|
||||||
}
|
}
|
||||||
a, err := src.MarshalJSON()
|
a, err := src.MarshalJSON()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
ra := make(json.RawMessage, len(a))
|
sz := len(a)
|
||||||
|
ra := make(json.RawMessage, sz)
|
||||||
copy(ra, a)
|
copy(ra, a)
|
||||||
return newLazyNode(&ra), nil
|
return newLazyNode(&ra), sz, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *lazyNode) intoDoc() (*partialDoc, error) {
|
func (n *lazyNode) intoDoc() (*partialDoc, error) {
|
||||||
@ -359,44 +366,14 @@ func (d *partialDoc) remove(key string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set should only be used to implement the "replace" operation, so "key" must
|
||||||
|
// be an already existing index in "d".
|
||||||
func (d *partialArray) set(key string, val *lazyNode) error {
|
func (d *partialArray) set(key string, val *lazyNode) error {
|
||||||
if key == "-" {
|
|
||||||
*d = append(*d, val)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
idx, err := strconv.Atoi(key)
|
idx, err := strconv.Atoi(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
(*d)[idx] = val
|
||||||
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 {
|
|
||||||
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)
|
|
||||||
|
|
||||||
cur := *d
|
|
||||||
|
|
||||||
copy(ary, cur)
|
|
||||||
|
|
||||||
if idx >= len(ary) {
|
|
||||||
return fmt.Errorf("Unable to access invalid index: %d", idx)
|
|
||||||
}
|
|
||||||
|
|
||||||
ary[idx] = val
|
|
||||||
|
|
||||||
*d = ary
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,9 +389,6 @@ func (d *partialArray) add(key string, val *lazyNode) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sz := 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)
|
ary := make([]*lazyNode, sz)
|
||||||
|
|
||||||
@ -556,7 +530,7 @@ func (p Patch) move(doc *container, op operation) error {
|
|||||||
return fmt.Errorf("jsonpatch move operation does not apply: doc is missing destination path: %s", path)
|
return fmt.Errorf("jsonpatch move operation does not apply: doc is missing destination path: %s", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return con.set(key, val)
|
return con.add(key, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Patch) test(doc *container, op operation) error {
|
func (p Patch) test(doc *container, op operation) error {
|
||||||
@ -590,7 +564,7 @@ func (p Patch) test(doc *container, op operation) error {
|
|||||||
return fmt.Errorf("Testing value %s failed", path)
|
return fmt.Errorf("Testing value %s failed", path)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Patch) copy(doc *container, op operation) error {
|
func (p Patch) copy(doc *container, op operation, accumulatedCopySize *int64) error {
|
||||||
from := op.from()
|
from := op.from()
|
||||||
|
|
||||||
con, key := findObject(doc, from)
|
con, key := findObject(doc, from)
|
||||||
@ -612,10 +586,14 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
valCopy, err := deepCopy(val)
|
valCopy, sz, err := deepCopy(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
(*accumulatedCopySize) += int64(sz)
|
||||||
|
if AccumulatedCopySizeLimit > 0 && *accumulatedCopySize > AccumulatedCopySizeLimit {
|
||||||
|
return NewAccumulatedCopySizeError(AccumulatedCopySizeLimit, *accumulatedCopySize)
|
||||||
|
}
|
||||||
|
|
||||||
return con.add(key, valCopy)
|
return con.add(key, valCopy)
|
||||||
}
|
}
|
||||||
@ -670,6 +648,8 @@ func (p Patch) ApplyIndent(doc []byte, indent string) ([]byte, error) {
|
|||||||
|
|
||||||
err = nil
|
err = nil
|
||||||
|
|
||||||
|
var accumulatedCopySize int64
|
||||||
|
|
||||||
for _, op := range p {
|
for _, op := range p {
|
||||||
switch op.kind() {
|
switch op.kind() {
|
||||||
case "add":
|
case "add":
|
||||||
@ -683,7 +663,7 @@ func (p Patch) ApplyIndent(doc []byte, indent string) ([]byte, error) {
|
|||||||
case "test":
|
case "test":
|
||||||
err = p.test(&pd, op)
|
err = p.test(&pd, op)
|
||||||
case "copy":
|
case "copy":
|
||||||
err = p.copy(&pd, op)
|
err = p.copy(&pd, op, &accumulatedCopySize)
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("Unexpected kind: %s", op.kind())
|
err = fmt.Errorf("Unexpected kind: %s", op.kind())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user