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
51f033a4
Commit
51f033a4
authored
Jan 04, 2018
by
ymqytw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug of swallowing missing merge key error
parent
e991a94d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
12 deletions
+27
-12
patch.go
.../src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
+12
-12
patch_test.go
...k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go
+15
-0
No files found.
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
View file @
51f033a4
...
...
@@ -1322,23 +1322,23 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
// If they're both maps or lists, recurse into the value.
switch
originalType
.
Kind
()
{
case
reflect
.
Map
:
subschema
,
patchMeta
,
err
:=
schema
.
LookupPatchMetadataForStruct
(
k
)
if
err
!=
nil
{
return
nil
,
err
subschema
,
patchMeta
,
err
2
:=
schema
.
LookupPatchMetadataForStruct
(
k
)
if
err
2
!=
nil
{
return
nil
,
err
2
}
_
,
patchStrategy
,
err
:=
extractRetainKeysPatchStrategy
(
patchMeta
.
GetPatchStrategies
())
if
err
!=
nil
{
return
nil
,
err
_
,
patchStrategy
,
err
2
:=
extractRetainKeysPatchStrategy
(
patchMeta
.
GetPatchStrategies
())
if
err
2
!=
nil
{
return
nil
,
err
2
}
original
[
k
],
err
=
mergeMapHandler
(
original
[
k
],
patchV
,
subschema
,
patchStrategy
,
mergeOptions
)
case
reflect
.
Slice
:
subschema
,
patchMeta
,
err
:=
schema
.
LookupPatchMetadataForSlice
(
k
)
if
err
!=
nil
{
return
nil
,
err
subschema
,
patchMeta
,
err
2
:=
schema
.
LookupPatchMetadataForSlice
(
k
)
if
err
2
!=
nil
{
return
nil
,
err
2
}
_
,
patchStrategy
,
err
:=
extractRetainKeysPatchStrategy
(
patchMeta
.
GetPatchStrategies
())
if
err
!=
nil
{
return
nil
,
err
_
,
patchStrategy
,
err
2
:=
extractRetainKeysPatchStrategy
(
patchMeta
.
GetPatchStrategies
())
if
err
2
!=
nil
{
return
nil
,
err
2
}
original
[
k
],
err
=
mergeSliceHandler
(
original
[
k
],
patchV
,
subschema
,
patchStrategy
,
patchMeta
.
GetPatchMergeKey
(),
isDeleteList
,
mergeOptions
)
default
:
...
...
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go
View file @
51f033a4
...
...
@@ -654,6 +654,21 @@ mergingIntList:
ExpectedError
:
"doesn't match"
,
},
},
{
Description
:
"missing merge key should error out"
,
StrategicMergePatchRawTestCaseData
:
StrategicMergePatchRawTestCaseData
{
Original
:
[]
byte
(
`
mergingList:
- name: 1
value: a
`
),
TwoWay
:
[]
byte
(
`
mergingList:
- value: b
`
),
ExpectedError
:
"does not contain declared merge key"
,
},
},
}
func
TestCustomStrategicMergePatch
(
t
*
testing
.
T
)
{
...
...
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