garbagecollectorcontroller.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. Copyright 2018 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 options
  14. import (
  15. "github.com/spf13/pflag"
  16. garbagecollectorconfig "k8s.io/kubernetes/pkg/controller/garbagecollector/config"
  17. )
  18. // GarbageCollectorControllerOptions holds the GarbageCollectorController options.
  19. type GarbageCollectorControllerOptions struct {
  20. *garbagecollectorconfig.GarbageCollectorControllerConfiguration
  21. }
  22. // AddFlags adds flags related to GarbageCollectorController for controller manager to the specified FlagSet.
  23. func (o *GarbageCollectorControllerOptions) AddFlags(fs *pflag.FlagSet) {
  24. if o == nil {
  25. return
  26. }
  27. fs.Int32Var(&o.ConcurrentGCSyncs, "concurrent-gc-syncs", o.ConcurrentGCSyncs, "The number of garbage collector workers that are allowed to sync concurrently.")
  28. fs.BoolVar(&o.EnableGarbageCollector, "enable-garbage-collector", o.EnableGarbageCollector, "Enables the generic garbage collector. MUST be synced with the corresponding flag of the kube-apiserver.")
  29. }
  30. // ApplyTo fills up GarbageCollectorController config with options.
  31. func (o *GarbageCollectorControllerOptions) ApplyTo(cfg *garbagecollectorconfig.GarbageCollectorControllerConfiguration) error {
  32. if o == nil {
  33. return nil
  34. }
  35. cfg.ConcurrentGCSyncs = o.ConcurrentGCSyncs
  36. cfg.GCIgnoredResources = o.GCIgnoredResources
  37. cfg.EnableGarbageCollector = o.EnableGarbageCollector
  38. return nil
  39. }
  40. // Validate checks validation of GarbageCollectorController.
  41. func (o *GarbageCollectorControllerOptions) Validate() []error {
  42. if o == nil {
  43. return nil
  44. }
  45. errs := []error{}
  46. return errs
  47. }