K8s: add server run options (#87784)

This commit is contained in:
Stephanie Hingtgen 2024-05-13 23:11:11 -05:00 committed by GitHub
parent 56054e2e87
commit bbb4323f7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,6 +15,7 @@ type Options struct {
RecommendedOptions *genericoptions.RecommendedOptions
TracingOptions *TracingOptions
MetricsOptions *MetricsOptions
ServerRunOptions *genericoptions.ServerRunOptions
}
func New(logger log.Logger, codec runtime.Codec) *Options {
@ -24,6 +25,7 @@ func New(logger log.Logger, codec runtime.Codec) *Options {
RecommendedOptions: options.NewRecommendedOptions(codec),
TracingOptions: NewTracingOptions(logger),
MetricsOptions: NewMetrcicsOptions(logger),
ServerRunOptions: genericoptions.NewServerRunOptions(),
}
}
@ -33,6 +35,7 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
o.RecommendedOptions.AddFlags(fs)
o.TracingOptions.AddFlags(fs)
o.MetricsOptions.AddFlags(fs)
o.ServerRunOptions.AddUniversalFlags(fs)
}
func (o *Options) Validate() []error {
@ -52,6 +55,10 @@ func (o *Options) Validate() []error {
return errs
}
if errs := o.ServerRunOptions.Validate(); len(errs) != 0 {
return errs
}
// NOTE: we don't call validate on the top level recommended options as it doesn't like skipping etcd-servers
// the function is left here for troubleshooting any other config issues
// errors = append(errors, o.RecommendedOptions.Validate()...)
@ -117,6 +124,10 @@ func (o *Options) ModifiedApplyTo(config *genericapiserver.RecommendedConfig) er
return err
}
if err := o.ServerRunOptions.ApplyTo(&config.Config); err != nil {
return err
}
return nil
}
@ -155,5 +166,11 @@ func (o *Options) ApplyTo(serverConfig *genericapiserver.RecommendedConfig) erro
}
}
if o.ServerRunOptions != nil {
if err := o.ServerRunOptions.ApplyTo(&serverConfig.Config); err != nil {
return err
}
}
return nil
}