k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cmd/kube-controller-manager/app/options/podgccontroller.go (about) 1 /* 2 Copyright 2018 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 options 18 19 import ( 20 "github.com/spf13/pflag" 21 22 podgcconfig "k8s.io/kubernetes/pkg/controller/podgc/config" 23 ) 24 25 // PodGCControllerOptions holds the PodGCController options. 26 type PodGCControllerOptions struct { 27 *podgcconfig.PodGCControllerConfiguration 28 } 29 30 // AddFlags adds flags related to PodGCController for controller manager to the specified FlagSet. 31 func (o *PodGCControllerOptions) AddFlags(fs *pflag.FlagSet) { 32 if o == nil { 33 return 34 } 35 36 fs.Int32Var(&o.TerminatedPodGCThreshold, "terminated-pod-gc-threshold", o.TerminatedPodGCThreshold, "Number of terminated pods that can exist before the terminated pod garbage collector starts deleting terminated pods. If <= 0, the terminated pod garbage collector is disabled.") 37 } 38 39 // ApplyTo fills up PodGCController config with options. 40 func (o *PodGCControllerOptions) ApplyTo(cfg *podgcconfig.PodGCControllerConfiguration) error { 41 if o == nil { 42 return nil 43 } 44 45 cfg.TerminatedPodGCThreshold = o.TerminatedPodGCThreshold 46 47 return nil 48 } 49 50 // Validate checks validation of PodGCControllerOptions. 51 func (o *PodGCControllerOptions) Validate() []error { 52 if o == nil { 53 return nil 54 } 55 56 errs := []error{} 57 return errs 58 }