Clear values for disabled alpha fields

This commit is contained in:
Jordan Liggitt
2017-08-18 16:18:53 -04:00
parent 44c5182187
commit 02281898f8
22 changed files with 107 additions and 3 deletions

View File

@@ -35,6 +35,7 @@ import (
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/api/pod"
"k8s.io/kubernetes/pkg/api/validation"
)
@@ -64,6 +65,10 @@ func (rcStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Ob
controller.Status = api.ReplicationControllerStatus{}
controller.Generation = 1
if controller.Spec.Template != nil {
pod.DropDisabledAlphaFields(&controller.Spec.Template.Spec)
}
}
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
@@ -73,6 +78,13 @@ func (rcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti
// update is not allowed to set status
newController.Status = oldController.Status
if oldController.Spec.Template != nil {
pod.DropDisabledAlphaFields(&oldController.Spec.Template.Spec)
}
if newController.Spec.Template != nil {
pod.DropDisabledAlphaFields(&newController.Spec.Template.Spec)
}
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object. We push
// the burden of managing the status onto the clients because we can't (in general)