k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/cmd/kube-controller-manager/app/options/legacyserviceaccounttokencleaner.go (about) 1 /* 2 Copyright 2023 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 serviceaccountconfig "k8s.io/kubernetes/pkg/controller/serviceaccount/config" 23 ) 24 25 // LegacySATokenCleanerOptions holds the LegacySATokenCleaner options. 26 type LegacySATokenCleanerOptions struct { 27 *serviceaccountconfig.LegacySATokenCleanerConfiguration 28 } 29 30 // AddFlags adds flags related to LegacySATokenCleaner for controller manager to the specified FlagSet 31 func (o *LegacySATokenCleanerOptions) AddFlags(fs *pflag.FlagSet) { 32 if o == nil { 33 return 34 } 35 36 fs.DurationVar(&o.CleanUpPeriod.Duration, "legacy-service-account-token-clean-up-period", o.CleanUpPeriod.Duration, "The period of time since the last usage of an legacy service account token before it can be deleted.") 37 } 38 39 // ApplyTo fills up LegacySATokenCleaner config with options. 40 func (o *LegacySATokenCleanerOptions) ApplyTo(cfg *serviceaccountconfig.LegacySATokenCleanerConfiguration) error { 41 if o == nil { 42 return nil 43 } 44 45 cfg.CleanUpPeriod = o.CleanUpPeriod 46 47 return nil 48 } 49 50 // Validate checks validation of LegacySATokenCleanerOptions. 51 func (o *LegacySATokenCleanerOptions) Validate() []error { 52 if o == nil { 53 return nil 54 } 55 56 errs := []error{} 57 return errs 58 }