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
48b67866
Commit
48b67866
authored
Apr 04, 2018
by
Mengqi Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support merging multiple SMP into one patch
parent
2bf111a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
patch.go
.../src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
+23
-0
No files found.
staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
View file @
48b67866
...
@@ -880,6 +880,29 @@ func StrategicMergeMapPatchUsingLookupPatchMeta(original, patch JSONMap, schema
...
@@ -880,6 +880,29 @@ func StrategicMergeMapPatchUsingLookupPatchMeta(original, patch JSONMap, schema
return
mergeMap
(
original
,
patch
,
schema
,
mergeOptions
)
return
mergeMap
(
original
,
patch
,
schema
,
mergeOptions
)
}
}
// MergeStrategicMergeMapPatchUsingLookupPatchMeta merges strategic merge
// patches retaining `null` fields and parallel lists. If 2 patches change the
// same fields and the latter one will override the former one. If you don't
// want that happen, you need to run func MergingMapsHaveConflicts before
// merging these patches. Applying the resulting merged merge patch to a JSONMap
// yields the same as merging each strategic merge patch to the JSONMap in
// succession.
func
MergeStrategicMergeMapPatchUsingLookupPatchMeta
(
schema
LookupPatchMeta
,
patches
...
JSONMap
)
(
JSONMap
,
error
)
{
mergeOptions
:=
MergeOptions
{
MergeParallelList
:
false
,
IgnoreUnmatchedNulls
:
false
,
}
merged
:=
JSONMap
{}
var
err
error
for
_
,
patch
:=
range
patches
{
merged
,
err
=
mergeMap
(
merged
,
patch
,
schema
,
mergeOptions
)
if
err
!=
nil
{
return
nil
,
err
}
}
return
merged
,
nil
}
// handleDirectiveInMergeMap handles the patch directive when merging 2 maps.
// handleDirectiveInMergeMap handles the patch directive when merging 2 maps.
func
handleDirectiveInMergeMap
(
directive
interface
{},
patch
map
[
string
]
interface
{})
(
map
[
string
]
interface
{},
error
)
{
func
handleDirectiveInMergeMap
(
directive
interface
{},
patch
map
[
string
]
interface
{})
(
map
[
string
]
interface
{},
error
)
{
if
directive
==
replaceDirective
{
if
directive
==
replaceDirective
{
...
...
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