Merge pull request #45471 from CaoShuFeng/useless_validate

Automatic merge from submit-queue (batch tested with PRs 46164, 45471, 46037)

validate oidc flags

This change validate oidc flags for kube-apiserver.



**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```NONE
```
pull/6/head
Kubernetes Submit Queue 2017-05-22 09:08:54 -07:00 committed by GitHub
commit 451d47889c
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
}