mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
support merging multiple SMP into one patch
This commit is contained in:
parent
2bf111a619
commit
48b6786632
@ -880,6 +880,29 @@ func StrategicMergeMapPatchUsingLookupPatchMeta(original, patch JSONMap, schema
|
||||
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.
|
||||
func handleDirectiveInMergeMap(directive interface{}, patch map[string]interface{}) (map[string]interface{}, error) {
|
||||
if directive == replaceDirective {
|
||||
|
Loading…
Reference in New Issue
Block a user