mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-04-12 00:00:26 +08:00
Merge pull request #54957 from apelisse/update-kube-openapi
Automatic merge from submit-queue (batch tested with PRs 55004, 54957). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Update kube-openapi to use validation **What this PR does / why we need it**: Moves openapi validation code to kube-openapi, so that we can move the rest of the code to apimachinery repository, so that later we can use it from both the client and the server. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #Nothing **Special notes for your reviewer**: **Release note**: ```release-note NONE ``` Kubernetes-commit: 55e216f56eac0082acc6be655d9ae09cf9ba38a8
This commit is contained in:
+6
-4
@@ -426,21 +426,23 @@ func (c *converterImpl) ToUnstructured(obj interface{}) (map[string]interface{},
|
||||
// DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains
|
||||
// types produced by json.Unmarshal().
|
||||
func DeepCopyJSON(x map[string]interface{}) map[string]interface{} {
|
||||
return deepCopyJSON(x).(map[string]interface{})
|
||||
return DeepCopyJSONValue(x).(map[string]interface{})
|
||||
}
|
||||
|
||||
func deepCopyJSON(x interface{}) interface{} {
|
||||
// DeepCopyJSONValue deep copies the passed value, assuming it is a valid JSON representation i.e. only contains
|
||||
// types produced by json.Unmarshal().
|
||||
func DeepCopyJSONValue(x interface{}) interface{} {
|
||||
switch x := x.(type) {
|
||||
case map[string]interface{}:
|
||||
clone := make(map[string]interface{}, len(x))
|
||||
for k, v := range x {
|
||||
clone[k] = deepCopyJSON(v)
|
||||
clone[k] = DeepCopyJSONValue(v)
|
||||
}
|
||||
return clone
|
||||
case []interface{}:
|
||||
clone := make([]interface{}, len(x))
|
||||
for i, v := range x {
|
||||
clone[i] = deepCopyJSON(v)
|
||||
clone[i] = DeepCopyJSONValue(v)
|
||||
}
|
||||
return clone
|
||||
case string, int64, bool, float64, nil, encodingjson.Number:
|
||||
|
||||
Reference in New Issue
Block a user