Upgrade k8s package verison (#5358)
* upgrade k8s package version Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> * Script upgrade and code formatting. Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
This commit is contained in:
8
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/OWNERS
generated
vendored
8
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/OWNERS
generated
vendored
@@ -1,8 +1,8 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
approvers:
|
||||
- pwittrock
|
||||
- mengqiy
|
||||
- pwittrock
|
||||
reviewers:
|
||||
- mengqiy
|
||||
- apelisse
|
||||
- apelisse
|
||||
emeritus_approvers:
|
||||
- mengqiy
|
||||
|
||||
12
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/meta.go
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/meta.go
generated
vendored
@@ -31,22 +31,22 @@ type PatchMeta struct {
|
||||
patchMergeKey string
|
||||
}
|
||||
|
||||
func (pm PatchMeta) GetPatchStrategies() []string {
|
||||
func (pm *PatchMeta) GetPatchStrategies() []string {
|
||||
if pm.patchStrategies == nil {
|
||||
return []string{}
|
||||
}
|
||||
return pm.patchStrategies
|
||||
}
|
||||
|
||||
func (pm PatchMeta) SetPatchStrategies(ps []string) {
|
||||
func (pm *PatchMeta) SetPatchStrategies(ps []string) {
|
||||
pm.patchStrategies = ps
|
||||
}
|
||||
|
||||
func (pm PatchMeta) GetPatchMergeKey() string {
|
||||
func (pm *PatchMeta) GetPatchMergeKey() string {
|
||||
return pm.patchMergeKey
|
||||
}
|
||||
|
||||
func (pm PatchMeta) SetPatchMergeKey(pmk string) {
|
||||
func (pm *PatchMeta) SetPatchMergeKey(pmk string) {
|
||||
pm.patchMergeKey = pmk
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func (s PatchMetaFromStruct) LookupPatchMetadataForSlice(key string) (LookupPatc
|
||||
// If the underlying element is neither an array nor a slice, the pointer is pointing to a slice,
|
||||
// e.g. https://github.com/kubernetes/kubernetes/blob/bc22e206c79282487ea0bf5696d5ccec7e839a76/staging/src/k8s.io/apimachinery/pkg/util/strategicpatch/patch_test.go#L2782-L2822
|
||||
// If the underlying element is either an array or a slice, return its element type.
|
||||
case reflect.Ptr:
|
||||
case reflect.Pointer:
|
||||
t = t.Elem()
|
||||
if t.Kind() == reflect.Array || t.Kind() == reflect.Slice {
|
||||
t = t.Elem()
|
||||
@@ -129,7 +129,7 @@ func getTagStructType(dataStruct interface{}) (reflect.Type, error) {
|
||||
|
||||
t := reflect.TypeOf(dataStruct)
|
||||
// Get the underlying type for pointers
|
||||
if t.Kind() == reflect.Ptr {
|
||||
if t.Kind() == reflect.Pointer {
|
||||
t = t.Elem()
|
||||
}
|
||||
|
||||
|
||||
40
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
generated
vendored
40
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
generated
vendored
@@ -987,10 +987,10 @@ func validatePatchWithSetOrderList(patchList, setOrderList interface{}, mergeKey
|
||||
return nil
|
||||
}
|
||||
|
||||
var nonDeleteList, toDeleteList []interface{}
|
||||
var nonDeleteList []interface{}
|
||||
var err error
|
||||
if len(mergeKey) > 0 {
|
||||
nonDeleteList, toDeleteList, err = extractToDeleteItems(typedPatchList)
|
||||
nonDeleteList, _, err = extractToDeleteItems(typedPatchList)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1018,7 +1018,6 @@ func validatePatchWithSetOrderList(patchList, setOrderList interface{}, mergeKey
|
||||
if patchIndex < len(nonDeleteList) && setOrderIndex >= len(typedSetOrderList) {
|
||||
return fmt.Errorf("The order in patch list:\n%v\n doesn't match %s list:\n%v\n", typedPatchList, setElementOrderDirectivePrefix, setOrderList)
|
||||
}
|
||||
typedPatchList = append(nonDeleteList, toDeleteList...)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -1329,15 +1328,25 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
|
||||
|
||||
_, ok := original[k]
|
||||
if !ok {
|
||||
// If it's not in the original document, just take the patch value.
|
||||
original[k] = patchV
|
||||
if !isDeleteList {
|
||||
// If it's not in the original document, just take the patch value.
|
||||
if mergeOptions.IgnoreUnmatchedNulls {
|
||||
discardNullValuesFromPatch(patchV)
|
||||
}
|
||||
original[k] = patchV
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
originalType := reflect.TypeOf(original[k])
|
||||
patchType := reflect.TypeOf(patchV)
|
||||
if originalType != patchType {
|
||||
original[k] = patchV
|
||||
if !isDeleteList {
|
||||
if mergeOptions.IgnoreUnmatchedNulls {
|
||||
discardNullValuesFromPatch(patchV)
|
||||
}
|
||||
original[k] = patchV
|
||||
}
|
||||
continue
|
||||
}
|
||||
// If they're both maps or lists, recurse into the value.
|
||||
@@ -1372,6 +1381,25 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
|
||||
return original, nil
|
||||
}
|
||||
|
||||
// discardNullValuesFromPatch discards all null property values from patch.
|
||||
// It traverses all slices and map types.
|
||||
func discardNullValuesFromPatch(patchV interface{}) {
|
||||
switch patchV := patchV.(type) {
|
||||
case map[string]interface{}:
|
||||
for k, v := range patchV {
|
||||
if v == nil {
|
||||
delete(patchV, k)
|
||||
} else {
|
||||
discardNullValuesFromPatch(v)
|
||||
}
|
||||
}
|
||||
case []interface{}:
|
||||
for _, v := range patchV {
|
||||
discardNullValuesFromPatch(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mergeMapHandler handles how to merge `patchV` whose key is `key` with `original` respecting
|
||||
// fieldPatchStrategy and mergeOptions.
|
||||
func mergeMapHandler(original, patch interface{}, schema LookupPatchMeta,
|
||||
|
||||
Reference in New Issue
Block a user