mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: update kubernetes to 1.28.0 in main
updating kubernetes to 1.28.0 in the main repo. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
b2fdc269c3
commit
ff3e84ad67
63
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
generated
vendored
63
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
generated
vendored
@ -1182,7 +1182,13 @@ func mergePatchIntoOriginal(original, patch map[string]interface{}, schema Looku
|
||||
merged = originalFieldValue
|
||||
case !foundOriginal && foundPatch:
|
||||
// list was added
|
||||
merged = patchFieldValue
|
||||
v, keep := removeDirectives(patchFieldValue)
|
||||
if !keep {
|
||||
// Shouldn't be possible since patchFieldValue is a slice
|
||||
continue
|
||||
}
|
||||
|
||||
merged = v.([]interface{})
|
||||
case foundOriginal && foundPatch:
|
||||
merged, err = mergeSliceHandler(originalList, patchList, subschema,
|
||||
patchStrategy, patchMeta.GetPatchMergeKey(), false, mergeOptions)
|
||||
@ -1270,6 +1276,42 @@ func partitionMapsByPresentInList(original, partitionBy []interface{}, mergeKey
|
||||
return patch, serverOnly, nil
|
||||
}
|
||||
|
||||
// Removes directives from an object and returns value to use instead and whether
|
||||
// or not the field/index should even be kept
|
||||
// May modify input
|
||||
func removeDirectives(obj interface{}) (interface{}, bool) {
|
||||
if obj == nil {
|
||||
return obj, true
|
||||
} else if typedV, ok := obj.(map[string]interface{}); ok {
|
||||
if _, hasDirective := typedV[directiveMarker]; hasDirective {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
for k, v := range typedV {
|
||||
var keep bool
|
||||
typedV[k], keep = removeDirectives(v)
|
||||
if !keep {
|
||||
delete(typedV, k)
|
||||
}
|
||||
}
|
||||
return typedV, true
|
||||
} else if typedV, ok := obj.([]interface{}); ok {
|
||||
var res []interface{}
|
||||
if typedV != nil {
|
||||
// Make sure res is non-nil if patch is non-nil
|
||||
res = []interface{}{}
|
||||
}
|
||||
for _, v := range typedV {
|
||||
if newV, keep := removeDirectives(v); keep {
|
||||
res = append(res, newV)
|
||||
}
|
||||
}
|
||||
return res, true
|
||||
} else {
|
||||
return obj, true
|
||||
}
|
||||
}
|
||||
|
||||
// Merge fields from a patch map into the original map. Note: This may modify
|
||||
// both the original map and the patch because getting a deep copy of a map in
|
||||
// golang is highly non-trivial.
|
||||
@ -1333,7 +1375,10 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
|
||||
if mergeOptions.IgnoreUnmatchedNulls {
|
||||
discardNullValuesFromPatch(patchV)
|
||||
}
|
||||
original[k] = patchV
|
||||
original[k], ok = removeDirectives(patchV)
|
||||
if !ok {
|
||||
delete(original, k)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -1345,7 +1390,10 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
|
||||
if mergeOptions.IgnoreUnmatchedNulls {
|
||||
discardNullValuesFromPatch(patchV)
|
||||
}
|
||||
original[k] = patchV
|
||||
original[k], ok = removeDirectives(patchV)
|
||||
if !ok {
|
||||
delete(original, k)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
@ -1372,7 +1420,11 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
|
||||
}
|
||||
original[k], err = mergeSliceHandler(original[k], patchV, subschema, patchStrategy, patchMeta.GetPatchMergeKey(), isDeleteList, mergeOptions)
|
||||
default:
|
||||
original[k] = patchV
|
||||
original[k], ok = removeDirectives(patchV)
|
||||
if !ok {
|
||||
// if patchV itself is a directive, then don't keep it
|
||||
delete(original, k)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1425,7 +1477,8 @@ func mergeSliceHandler(original, patch interface{}, schema LookupPatchMeta,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if fieldPatchStrategy == mergeDirective {
|
||||
// Delete lists are handled the same way regardless of what the field's patch strategy is
|
||||
if fieldPatchStrategy == mergeDirective || isDeleteList {
|
||||
return mergeSlice(typedOriginal, typedPatch, schema, fieldPatchMergeKey, mergeOptions, isDeleteList)
|
||||
} else {
|
||||
return typedPatch, nil
|
||||
|
Reference in New Issue
Block a user