Optimize some codes

Kubernetes-commit: 4a24a08f936a295bf332b9567bea182e2feff554
This commit is contained in:
xiongzhongliang 2021-02-28 01:00:09 +08:00 committed by Kubernetes Publisher
parent e61fc2bced
commit fbe8ccc9bd
1 changed files with 2 additions and 8 deletions

View File

@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
utilnet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/sets"
auditinternal "k8s.io/apiserver/pkg/apis/audit"
auditv1 "k8s.io/apiserver/pkg/apis/audit/v1"
auditv1alpha1 "k8s.io/apiserver/pkg/apis/audit/v1alpha1"
@ -478,14 +479,7 @@ func (o *AuditLogOptions) Validate() []error {
}
// Check log format
validFormat := false
for _, f := range pluginlog.AllowedFormats {
if f == o.Format {
validFormat = true
break
}
}
if !validFormat {
if !sets.NewString(pluginlog.AllowedFormats...).Has(o.Format) {
allErrors = append(allErrors, fmt.Errorf("invalid audit log format %s, allowed formats are %q", o.Format, strings.Join(pluginlog.AllowedFormats, ",")))
}