mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Make some methods into non-methods
This commit is contained in:
parent
17312ea4a9
commit
c5f3e560e4
@ -96,7 +96,7 @@ func (strategy svcStrategy) PrepareForCreate(ctx context.Context, obj runtime.Ob
|
|||||||
service.Status = api.ServiceStatus{}
|
service.Status = api.ServiceStatus{}
|
||||||
|
|
||||||
normalizeClusterIPs(nil, service)
|
normalizeClusterIPs(nil, service)
|
||||||
strategy.dropServiceDisabledFields(service, nil)
|
dropServiceDisabledFields(service, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrepareForUpdate sets contextual defaults and clears fields that are not allowed to be set by end users on update.
|
// PrepareForUpdate sets contextual defaults and clears fields that are not allowed to be set by end users on update.
|
||||||
@ -106,7 +106,7 @@ func (strategy svcStrategy) PrepareForUpdate(ctx context.Context, obj, old runti
|
|||||||
newService.Status = oldService.Status
|
newService.Status = oldService.Status
|
||||||
|
|
||||||
normalizeClusterIPs(oldService, newService)
|
normalizeClusterIPs(oldService, newService)
|
||||||
strategy.dropServiceDisabledFields(newService, oldService)
|
dropServiceDisabledFields(newService, oldService)
|
||||||
// if service was converted from ClusterIP => ExternalName
|
// if service was converted from ClusterIP => ExternalName
|
||||||
// then clear ClusterIPs, IPFamilyPolicy and IPFamilies
|
// then clear ClusterIPs, IPFamilyPolicy and IPFamilies
|
||||||
clearClusterIPRelatedFields(newService, oldService)
|
clearClusterIPRelatedFields(newService, oldService)
|
||||||
@ -166,8 +166,8 @@ func (svcStrategy) Export(ctx context.Context, obj runtime.Object, exact bool) e
|
|||||||
// if !utilfeature.DefaultFeatureGate.Enabled(features.MyFeature) && !myFeatureInUse(oldSvc) {
|
// if !utilfeature.DefaultFeatureGate.Enabled(features.MyFeature) && !myFeatureInUse(oldSvc) {
|
||||||
// newSvc.Spec.MyFeature = nil
|
// newSvc.Spec.MyFeature = nil
|
||||||
// }
|
// }
|
||||||
func (strategy svcStrategy) dropServiceDisabledFields(newSvc *api.Service, oldSvc *api.Service) {
|
func dropServiceDisabledFields(newSvc *api.Service, oldSvc *api.Service) {
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.IPv6DualStack) && !strategy.serviceDualStackFieldsInUse(oldSvc) {
|
if !utilfeature.DefaultFeatureGate.Enabled(features.IPv6DualStack) && !serviceDualStackFieldsInUse(oldSvc) {
|
||||||
newSvc.Spec.IPFamilies = nil
|
newSvc.Spec.IPFamilies = nil
|
||||||
newSvc.Spec.IPFamilyPolicy = nil
|
newSvc.Spec.IPFamilyPolicy = nil
|
||||||
if len(newSvc.Spec.ClusterIPs) > 1 {
|
if len(newSvc.Spec.ClusterIPs) > 1 {
|
||||||
@ -182,7 +182,7 @@ func (strategy svcStrategy) dropServiceDisabledFields(newSvc *api.Service, oldSv
|
|||||||
}
|
}
|
||||||
|
|
||||||
// returns true if svc.Spec.ServiceIPFamily field is in use
|
// returns true if svc.Spec.ServiceIPFamily field is in use
|
||||||
func (strategy svcStrategy) serviceDualStackFieldsInUse(svc *api.Service) bool {
|
func serviceDualStackFieldsInUse(svc *api.Service) bool {
|
||||||
if svc == nil {
|
if svc == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user