mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Clear values for disabled alpha fields
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user