k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/pkg/controller/endpointslicemirroring/config/v1alpha1/defaults.go (about)

     1  /*
     2  Copyright 2020 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1alpha1
    18  
    19  import (
    20  	kubectrlmgrconfigv1alpha1 "k8s.io/kube-controller-manager/config/v1alpha1"
    21  )
    22  
    23  // RecommendedDefaultEndpointSliceMirroringControllerConfiguration defaults a
    24  // pointer to a EndpointSliceMirroringControllerConfiguration struct. This will
    25  // set the recommended default values, but they may be subject to change between
    26  // API versions. This function is intentionally not registered in the scheme as
    27  // a "normal" `SetDefaults_Foo` function to allow consumers of this type to set
    28  // whatever defaults for their embedded configs. Forcing consumers to use these
    29  // defaults would be problematic as defaulting in the scheme is done as part of
    30  // the conversion, and there would be no easy way to opt-out. Instead, if you
    31  // want to use this defaulting method run it in your wrapper struct of this type
    32  // in its `SetDefaults_` method.
    33  func RecommendedDefaultEndpointSliceMirroringControllerConfiguration(obj *kubectrlmgrconfigv1alpha1.EndpointSliceMirroringControllerConfiguration) {
    34  	if obj.MirroringConcurrentServiceEndpointSyncs == 0 {
    35  		obj.MirroringConcurrentServiceEndpointSyncs = 5
    36  	}
    37  
    38  	if obj.MirroringMaxEndpointsPerSubset == 0 {
    39  		obj.MirroringMaxEndpointsPerSubset = 1000
    40  	}
    41  }