Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b8911b8d
Commit
b8911b8d
authored
Feb 04, 2019
by
Chao Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Importing latest json-patch.
parent
cdfb9126
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
84 additions
and
69 deletions
+84
-69
Godeps.json
Godeps/Godeps.json
+2
-2
Godeps.json
...ing/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/apimachinery/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/apiserver/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/cli-runtime/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/client-go/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/csi-api/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/metrics/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/node-api/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/sample-cli-plugin/Godeps/Godeps.json
+1
-1
Godeps.json
staging/src/k8s.io/sample-controller/Godeps/Godeps.json
+1
-1
BUILD
vendor/github.com/evanphx/json-patch/BUILD
+1
-0
README.md
vendor/github.com/evanphx/json-patch/README.md
+3
-7
errors.go
vendor/github.com/evanphx/json-patch/errors.go
+38
-0
patch.go
vendor/github.com/evanphx/json-patch/patch.go
+28
-48
No files found.
Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -1555,8 +1555,8 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Comment"
:
"v4.1.0-1
1-gd4020504c68b6b
"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Comment"
:
"v4.1.0-1
9-g5858425f75500d
"
,
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/exponent-io/jsonpath"
,
...
...
staging/src/k8s.io/apiextensions-apiserver/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -372,7 +372,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/ghodss/yaml"
,
...
...
staging/src/k8s.io/apimachinery/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -24,7 +24,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
staging/src/k8s.io/apiserver/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -372,7 +372,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/ghodss/yaml"
,
...
...
staging/src/k8s.io/cli-runtime/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -12,7 +12,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
staging/src/k8s.io/client-go/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -56,7 +56,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
staging/src/k8s.io/csi-api/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -12,7 +12,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
staging/src/k8s.io/kube-aggregator/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -96,7 +96,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
...
...
staging/src/k8s.io/metrics/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -12,7 +12,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
staging/src/k8s.io/node-api/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -12,7 +12,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
staging/src/k8s.io/sample-apiserver/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -88,7 +88,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/go-openapi/jsonpointer"
,
...
...
staging/src/k8s.io/sample-cli-plugin/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -12,7 +12,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
staging/src/k8s.io/sample-controller/Godeps/Godeps.json
View file @
b8911b8d
...
...
@@ -12,7 +12,7 @@
},
{
"ImportPath"
:
"github.com/evanphx/json-patch"
,
"Rev"
:
"
d4020504c68b6bfa818032bedfb48e33e9638506
"
"Rev"
:
"
5858425f75500d40c52783dce87d085a483ce135
"
},
{
"ImportPath"
:
"github.com/gogo/protobuf/proto"
,
...
...
vendor/github.com/evanphx/json-patch/BUILD
View file @
b8911b8d
...
...
@@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"errors.go",
"merge.go",
"patch.go",
],
...
...
vendor/github.com/evanphx/json-patch/README.md
View file @
b8911b8d
...
...
@@ -34,13 +34,9 @@ go get -u github.com/evanphx/json-patch
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.
*
There is a global configuration variable
`jsonpatch.AccumulatedCopySizeLimit`
,
which limits the total size increase in bytes caused by "copy" operations in a
patch. It defaults to 0, which means there is no limit.
## Create and apply a merge patch
Given both an original JSON document and a modified JSON document, you can create
...
...
vendor/github.com/evanphx/json-patch/errors.go
0 → 100644
View file @
b8911b8d
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
)
}
vendor/github.com/evanphx/json-patch/patch.go
View file @
b8911b8d
...
...
@@ -14,9 +14,15 @@ const (
eAry
)
var
SupportNegativeIndices
bool
=
true
var
ArraySizeLimit
int
=
0
var
ArraySizeAdditionLimit
int
=
0
var
(
// SupportNegativeIndices decides whether to support non-standard practice of
// 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
{
raw
*
json
.
RawMessage
...
...
@@ -65,17 +71,18 @@ func (n *lazyNode) UnmarshalJSON(data []byte) error {
return
nil
}
func
deepCopy
(
src
*
lazyNode
)
(
*
lazyNode
,
error
)
{
func
deepCopy
(
src
*
lazyNode
)
(
*
lazyNode
,
int
,
error
)
{
if
src
==
nil
{
return
nil
,
nil
return
nil
,
0
,
nil
}
a
,
err
:=
src
.
MarshalJSON
()
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
)
return
newLazyNode
(
&
ra
),
nil
return
newLazyNode
(
&
ra
),
sz
,
nil
}
func
(
n
*
lazyNode
)
intoDoc
()
(
*
partialDoc
,
error
)
{
...
...
@@ -359,44 +366,14 @@ func (d *partialDoc) remove(key string) error {
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
{
if
key
==
"-"
{
*
d
=
append
(
*
d
,
val
)
return
nil
}
idx
,
err
:=
strconv
.
Atoi
(
key
)
if
err
!=
nil
{
return
err
}
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
(
*
d
)[
idx
]
=
val
return
nil
}
...
...
@@ -412,9 +389,6 @@ func (d *partialArray) add(key string, val *lazyNode) error {
}
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
)
...
...
@@ -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
con
.
set
(
key
,
val
)
return
con
.
add
(
key
,
val
)
}
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
)
}
func
(
p
Patch
)
copy
(
doc
*
container
,
op
operation
)
error
{
func
(
p
Patch
)
copy
(
doc
*
container
,
op
operation
,
accumulatedCopySize
*
int64
)
error
{
from
:=
op
.
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
)
}
valCopy
,
err
:=
deepCopy
(
val
)
valCopy
,
sz
,
err
:=
deepCopy
(
val
)
if
err
!=
nil
{
return
err
}
(
*
accumulatedCopySize
)
+=
int64
(
sz
)
if
AccumulatedCopySizeLimit
>
0
&&
*
accumulatedCopySize
>
AccumulatedCopySizeLimit
{
return
NewAccumulatedCopySizeError
(
AccumulatedCopySizeLimit
,
*
accumulatedCopySize
)
}
return
con
.
add
(
key
,
valCopy
)
}
...
...
@@ -670,6 +648,8 @@ func (p Patch) ApplyIndent(doc []byte, indent string) ([]byte, error) {
err
=
nil
var
accumulatedCopySize
int64
for
_
,
op
:=
range
p
{
switch
op
.
kind
()
{
case
"add"
:
...
...
@@ -683,7 +663,7 @@ func (p Patch) ApplyIndent(doc []byte, indent string) ([]byte, error) {
case
"test"
:
err
=
p
.
test
(
&
pd
,
op
)
case
"copy"
:
err
=
p
.
copy
(
&
pd
,
op
)
err
=
p
.
copy
(
&
pd
,
op
,
&
accumulatedCopySize
)
default
:
err
=
fmt
.
Errorf
(
"Unexpected kind: %s"
,
op
.
kind
())
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment