ttlafterfinishedcontroller.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. ttlafterfinishedconfig "k8s.io/kubernetes/pkg/controller/ttlafterfinished/config"
  17. )
  18. // TTLAfterFinishedControllerOptions holds the TTLAfterFinishedController options.
  19. type TTLAfterFinishedControllerOptions struct {
  20. *ttlafterfinishedconfig.TTLAfterFinishedControllerConfiguration
  21. }
  22. // AddFlags adds flags related to TTLAfterFinishedController for controller manager to the specified FlagSet.
  23. func (o *TTLAfterFinishedControllerOptions) AddFlags(fs *pflag.FlagSet) {
  24. if o == nil {
  25. return
  26. }
  27. fs.Int32Var(&o.ConcurrentTTLSyncs, "concurrent-ttl-after-finished-syncs", o.ConcurrentTTLSyncs, "The number of TTL-after-finished controller workers that are allowed to sync concurrently.")
  28. }
  29. // ApplyTo fills up TTLAfterFinishedController config with options.
  30. func (o *TTLAfterFinishedControllerOptions) ApplyTo(cfg *ttlafterfinishedconfig.TTLAfterFinishedControllerConfiguration) error {
  31. if o == nil {
  32. return nil
  33. }
  34. cfg.ConcurrentTTLSyncs = o.ConcurrentTTLSyncs
  35. return nil
  36. }
  37. // Validate checks validation of TTLAfterFinishedControllerOptions.
  38. func (o *TTLAfterFinishedControllerOptions) Validate() []error {
  39. if o == nil {
  40. return nil
  41. }
  42. errs := []error{}
  43. return errs
  44. }