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
325f506c
Commit
325f506c
authored
Mar 30, 2017
by
ymqytw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor Strategic Merge Patch
parent
176eb0e5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
5 deletions
+19
-5
errors.go
...ing/src/k8s.io/apimachinery/pkg/util/mergepatch/errors.go
+17
-3
patch.go
.../src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
+0
-0
patch_test.go
...k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go
+2
-2
No files found.
staging/src/k8s.io/apimachinery/pkg/util/mergepatch/errors.go
View file @
325f506c
...
...
@@ -21,9 +21,23 @@ import (
"fmt"
)
var
ErrBadJSONDoc
=
errors
.
New
(
"Invalid JSON document"
)
var
ErrNoListOfLists
=
errors
.
New
(
"Lists of lists are not supported"
)
var
ErrBadPatchFormatForPrimitiveList
=
errors
.
New
(
"Invalid patch format of primitive list"
)
var
(
ErrBadJSONDoc
=
errors
.
New
(
"Invalid JSON document"
)
ErrNoListOfLists
=
errors
.
New
(
"Lists of lists are not supported"
)
ErrBadPatchFormatForPrimitiveList
=
errors
.
New
(
"Invalid patch format of primitive list"
)
)
func
ErrNoMergeKey
(
m
map
[
string
]
interface
{},
k
string
)
error
{
return
fmt
.
Errorf
(
"map: %v does not contain declared merge key: %s"
,
m
,
k
)
}
func
ErrBadArgType
(
expected
,
actual
string
)
error
{
return
fmt
.
Errorf
(
"expected a %s, but received a %s"
,
expected
,
actual
)
}
func
ErrBadPatchType
(
t
interface
{},
m
map
[
string
]
interface
{})
error
{
return
fmt
.
Errorf
(
"unknown patch type: %s in map: %v"
,
t
,
m
)
}
// IsPreconditionFailed returns true if the provided error indicates
// a precondition failed.
...
...
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
View file @
325f506c
This diff is collapsed.
Click to expand it.
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go
View file @
325f506c
...
...
@@ -1998,9 +1998,9 @@ func TestStrategicMergePatch(t *testing.T) {
testStrategicMergePatchWithCustomArguments
(
t
,
"bad patch"
,
"{}"
,
"<THIS IS NOT JSON>"
,
mergeItem
,
mergepatch
.
ErrBadJSONDoc
)
testStrategicMergePatchWithCustomArguments
(
t
,
"bad struct"
,
"{}"
,
"{}"
,
[]
byte
(
"<THIS IS NOT A STRUCT>"
),
fmt
.
Errorf
(
errBadArgTypeFmt
,
"struct"
,
"slice"
))
"{}"
,
"{}"
,
[]
byte
(
"<THIS IS NOT A STRUCT>"
),
mergepatch
.
ErrBadArgType
(
"struct"
,
"slice"
))
testStrategicMergePatchWithCustomArguments
(
t
,
"nil struct"
,
"{}"
,
"{}"
,
nil
,
fmt
.
Errorf
(
errBadArgTypeFmt
,
"struct"
,
"nil"
))
"{}"
,
"{}"
,
nil
,
mergepatch
.
ErrBadArgType
(
"struct"
,
"nil"
))
tc
:=
StrategicMergePatchTestCases
{}
err
:=
yaml
.
Unmarshal
(
createStrategicMergePatchTestCaseData
,
&
tc
)
...
...
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