mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Merge pull request #81826 from thockin/service-drop-disabled-fields
Add dropDisbledFields() to service
This commit is contained in:
commit
52a9f18b07
@ -47,6 +47,8 @@ func (svcStrategy) NamespaceScoped() bool {
|
||||
func (svcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
service := obj.(*api.Service)
|
||||
service.Status = api.ServiceStatus{}
|
||||
|
||||
dropServiceDisabledFields(service, nil)
|
||||
}
|
||||
|
||||
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
|
||||
@ -54,6 +56,8 @@ func (svcStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object
|
||||
newService := obj.(*api.Service)
|
||||
oldService := old.(*api.Service)
|
||||
newService.Status = oldService.Status
|
||||
|
||||
dropServiceDisabledFields(newService, oldService)
|
||||
}
|
||||
|
||||
// Validate validates a new service.
|
||||
@ -104,6 +108,14 @@ func (svcStrategy) Export(ctx context.Context, obj runtime.Object, exact bool) e
|
||||
return nil
|
||||
}
|
||||
|
||||
// dropServiceDisabledFields drops fields that are not used if their associated feature gates
|
||||
// are not enabled. The typical pattern is:
|
||||
// if !utilfeature.DefaultFeatureGate.Enabled(features.MyFeature) && !myFeatureInUse(oldSvc) {
|
||||
// newSvc.Spec.MyFeature = nil
|
||||
// }
|
||||
func dropServiceDisabledFields(newSvc *api.Service, oldSvc *api.Service) {
|
||||
}
|
||||
|
||||
type serviceStatusStrategy struct {
|
||||
svcStrategy
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user