Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup: wrap the apiserver identity validation #99573

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions cmd/kube-apiserver/app/options/validation.go
Expand Up @@ -150,6 +150,17 @@ func validateAPIPriorityAndFairness(options *ServerRunOptions) []error {
return nil
}

func validateAPIServerIdentity(options *ServerRunOptions) []error {
var errs []error
if options.IdentityLeaseDurationSeconds <= 0 {
errs = append(errs, fmt.Errorf("--identity-lease-duration-seconds should be a positive number, but value '%d' provided", options.IdentityLeaseDurationSeconds))
}
if options.IdentityLeaseRenewIntervalSeconds <= 0 {
errs = append(errs, fmt.Errorf("--identity-lease-renew-interval-seconds should be a positive number, but value '%d' provided", options.IdentityLeaseRenewIntervalSeconds))
}
return errs
}

// Validate checks ServerRunOptions and return a slice of found errs.
func (s *ServerRunOptions) Validate() []error {
var errs []error
Expand All @@ -169,12 +180,7 @@ func (s *ServerRunOptions) Validate() []error {
errs = append(errs, validateTokenRequest(s)...)
errs = append(errs, s.Metrics.Validate()...)
errs = append(errs, s.Logs.Validate()...)
if s.IdentityLeaseDurationSeconds <= 0 {
errs = append(errs, fmt.Errorf("--identity-lease-duration-seconds should be a positive number, but value '%d' provided", s.IdentityLeaseDurationSeconds))
}
if s.IdentityLeaseRenewIntervalSeconds <= 0 {
errs = append(errs, fmt.Errorf("--identity-lease-renew-interval-seconds should be a positive number, but value '%d' provided", s.IdentityLeaseRenewIntervalSeconds))
}
errs = append(errs, validateAPIServerIdentity(s)...)

return errs
}