validate oidc flags

This change validate oidc flags for kube-apiserver.
pull/6/head
Cao Shufeng 2017-05-22 18:03:28 +08:00
parent f0e5a999e9
commit 9710eb62ae
2 changed files with 9 additions and 0 deletions

View File

@ -60,6 +60,9 @@ func (options *ServerRunOptions) Validate() []error {
if errs := options.SecureServing.Validate(); len(errs) > 0 {
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 {
errors = append(errors, errs...)
}

View File

@ -163,8 +163,14 @@ func (s *BuiltInAuthenticationOptions) WithWebHook() *BuiltInAuthenticationOptio
return s
}
// Validate checks invalid config combination
func (s *BuiltInAuthenticationOptions) Validate() []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
}