mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-04-12 00:00:26 +08:00
Merge pull request #57958 from nikhita/sample-controller-crd-validation
Automatic merge from submit-queue (batch tested with PRs 57902, 57958). 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>. Add CustomResourceValidation example in sample-controller Add `CustomResourceValidation` example in sample-controller. Addresses the following part of https://github.com/kubernetes/sample-controller/issues/2: > CRDs support json-schema schemas. These CRDs don't have them. It would be nice to show how to add them **Release note**: ```release-note NONE ``` /assign sttts munnerz Kubernetes-commit: 51acead08489644d30b3f1a978e0b36f228d12a7
This commit is contained in:
+12
-12
@@ -1322,23 +1322,23 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
|
||||
// If they're both maps or lists, recurse into the value.
|
||||
switch originalType.Kind() {
|
||||
case reflect.Map:
|
||||
subschema, patchMeta, err := schema.LookupPatchMetadataForStruct(k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
subschema, patchMeta, err2 := schema.LookupPatchMetadataForStruct(k)
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
_, patchStrategy, err := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
_, patchStrategy, err2 := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
original[k], err = mergeMapHandler(original[k], patchV, subschema, patchStrategy, mergeOptions)
|
||||
case reflect.Slice:
|
||||
subschema, patchMeta, err := schema.LookupPatchMetadataForSlice(k)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
subschema, patchMeta, err2 := schema.LookupPatchMetadataForSlice(k)
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
_, patchStrategy, err := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
_, patchStrategy, err2 := extractRetainKeysPatchStrategy(patchMeta.GetPatchStrategies())
|
||||
if err2 != nil {
|
||||
return nil, err2
|
||||
}
|
||||
original[k], err = mergeSliceHandler(original[k], patchV, subschema, patchStrategy, patchMeta.GetPatchMergeKey(), isDeleteList, mergeOptions)
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user