Commit 9710eb62 authored by Cao Shufeng's avatar Cao Shufeng

validate oidc flags

This change validate oidc flags for kube-apiserver.
parent f0e5a999
...@@ -60,6 +60,9 @@ func (options *ServerRunOptions) Validate() []error { ...@@ -60,6 +60,9 @@ func (options *ServerRunOptions) Validate() []error {
if errs := options.SecureServing.Validate(); len(errs) > 0 { if errs := options.SecureServing.Validate(); len(errs) > 0 {
errors = append(errors, errs...) errors = append(errors, errs...)
} }
if errs := options.Authentication.Validate(); len(errs) > 0 {
errors = append(errors, errs...)
}
if errs := options.InsecureServing.Validate("insecure-port"); len(errs) > 0 { if errs := options.InsecureServing.Validate("insecure-port"); len(errs) > 0 {
errors = append(errors, errs...) errors = append(errors, errs...)
} }
......
...@@ -163,8 +163,14 @@ func (s *BuiltInAuthenticationOptions) WithWebHook() *BuiltInAuthenticationOptio ...@@ -163,8 +163,14 @@ func (s *BuiltInAuthenticationOptions) WithWebHook() *BuiltInAuthenticationOptio
return s return s
} }
// Validate checks invalid config combination
func (s *BuiltInAuthenticationOptions) Validate() []error { func (s *BuiltInAuthenticationOptions) Validate() []error {
allErrors := []error{} allErrors := []error{}
if s.OIDC != nil && (len(s.OIDC.IssuerURL) > 0) != (len(s.OIDC.ClientID) > 0) {
allErrors = append(allErrors, fmt.Errorf("oidc-issuer-url and oidc-client-id should be specified together"))
}
return allErrors return allErrors
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment