defaults.go 1.7 KB

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