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
aa1d47a3
Commit
aa1d47a3
authored
Jul 29, 2017
by
Shimin Guo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix premature return
parent
e3c24829
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
1 deletion
+73
-1
patch.go
.../src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
+1
-1
patch_test.go
...k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go
+72
-0
No files found.
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
View file @
aa1d47a3
...
@@ -1138,7 +1138,7 @@ func mergePatchIntoOriginal(original, patch map[string]interface{}, t reflect.Ty
...
@@ -1138,7 +1138,7 @@ func mergePatchIntoOriginal(original, patch map[string]interface{}, t reflect.Ty
return
err
return
err
}
}
case
!
foundOriginal
&&
!
foundPatch
:
case
!
foundOriginal
&&
!
foundPatch
:
return
nil
continue
}
}
// Split all items into patch items and server-only items and then enforce the order.
// Split all items into patch items and server-only items and then enforce the order.
...
...
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go
View file @
aa1d47a3
...
@@ -5969,6 +5969,75 @@ retainKeysMergingList:
...
@@ -5969,6 +5969,75 @@ retainKeysMergingList:
`
),
`
),
},
},
},
},
{
Description
:
"delete and reorder in one list, reorder in another"
,
StrategicMergePatchRawTestCaseData
:
StrategicMergePatchRawTestCaseData
{
Original
:
[]
byte
(
`
mergingList:
- name: a
value: a
- name: b
value: b
mergeItemPtr:
- name: c
value: c
- name: d
value: d
`
),
Current
:
[]
byte
(
`
mergingList:
- name: a
value: a
- name: b
value: b
mergeItemPtr:
- name: c
value: c
- name: d
value: d
`
),
Modified
:
[]
byte
(
`
mergingList:
- name: b
value: b
mergeItemPtr:
- name: d
value: d
- name: c
value: c
`
),
TwoWay
:
[]
byte
(
`
$setElementOrder/mergingList:
- name: b
$setElementOrder/mergeItemPtr:
- name: d
- name: c
mergingList:
- $patch: delete
name: a
`
),
ThreeWay
:
[]
byte
(
`
$setElementOrder/mergingList:
- name: b
$setElementOrder/mergeItemPtr:
- name: d
- name: c
mergingList:
- $patch: delete
name: a
`
),
Result
:
[]
byte
(
`
mergingList:
- name: b
value: b
mergeItemPtr:
- name: d
value: d
- name: c
value: c
`
),
},
},
}
}
func
TestStrategicMergePatch
(
t
*
testing
.
T
)
{
func
TestStrategicMergePatch
(
t
*
testing
.
T
)
{
...
@@ -5993,10 +6062,13 @@ func TestStrategicMergePatch(t *testing.T) {
...
@@ -5993,10 +6062,13 @@ func TestStrategicMergePatch(t *testing.T) {
testThreeWayPatch
(
t
,
c
)
testThreeWayPatch
(
t
,
c
)
}
}
// run multiple times to exercise different map traversal orders
for
i
:=
0
;
i
<
10
;
i
++
{
for
_
,
c
:=
range
strategicMergePatchRawTestCases
{
for
_
,
c
:=
range
strategicMergePatchRawTestCases
{
testTwoWayPatchForRawTestCase
(
t
,
c
)
testTwoWayPatchForRawTestCase
(
t
,
c
)
testThreeWayPatchForRawTestCase
(
t
,
c
)
testThreeWayPatchForRawTestCase
(
t
,
c
)
}
}
}
}
}
func
testStrategicMergePatchWithCustomArguments
(
t
*
testing
.
T
,
description
,
original
,
patch
string
,
dataStruct
interface
{},
err
error
)
{
func
testStrategicMergePatchWithCustomArguments
(
t
*
testing
.
T
,
description
,
original
,
patch
string
,
dataStruct
interface
{},
err
error
)
{
...
...
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