@@ -102,7 +107,7 @@ func (o *AuditOptions) Validate() []error {
...
@@ -102,7 +107,7 @@ func (o *AuditOptions) Validate() []error {
allErrors=append(allErrors,fmt.Errorf("feature '%s' must be enabled to set option --audit-webhook-config-file",features.AdvancedAuditing))
allErrors=append(allErrors,fmt.Errorf("feature '%s' must be enabled to set option --audit-webhook-config-file",features.AdvancedAuditing))
}
}
}else{
}else{
// check webhook mode
// Check webhook mode
validMode:=false
validMode:=false
for_,m:=rangepluginwebhook.AllowedModes{
for_,m:=rangepluginwebhook.AllowedModes{
ifm==o.WebhookOptions.Mode{
ifm==o.WebhookOptions.Mode{
...
@@ -114,7 +119,21 @@ func (o *AuditOptions) Validate() []error {
...
@@ -114,7 +119,21 @@ func (o *AuditOptions) Validate() []error {
allErrors=append(allErrors,fmt.Errorf("invalid audit webhook mode %s, allowed modes are %q",o.WebhookOptions.Mode,strings.Join(pluginwebhook.AllowedModes,",")))
allErrors=append(allErrors,fmt.Errorf("invalid audit webhook mode %s, allowed modes are %q",o.WebhookOptions.Mode,strings.Join(pluginwebhook.AllowedModes,",")))
}
}
// check log format
// Check webhook batch configuration
ifo.WebhookOptions.BatchConfig.BufferSize<=0{
allErrors=append(allErrors,fmt.Errorf("invalid audit batch webhook buffer size %v, must be a positive number",o.WebhookOptions.BatchConfig.BufferSize))
}
ifo.WebhookOptions.BatchConfig.MaxBatchSize<=0{
allErrors=append(allErrors,fmt.Errorf("invalid audit batch webhook max batch size %v, must be a positive number",o.WebhookOptions.BatchConfig.MaxBatchSize))
}
ifo.WebhookOptions.BatchConfig.ThrottleQPS<=0{
allErrors=append(allErrors,fmt.Errorf("invalid audit batch webhook throttle QPS %v, must be a positive number",o.WebhookOptions.BatchConfig.ThrottleQPS))
}
ifo.WebhookOptions.BatchConfig.ThrottleBurst<=0{
allErrors=append(allErrors,fmt.Errorf("invalid audit batch webhook throttle burst %v, must be a positive number",o.WebhookOptions.BatchConfig.ThrottleBurst))
}
// Check log format
validFormat:=false
validFormat:=false
for_,f:=rangepluginlog.AllowedFormats{
for_,f:=rangepluginlog.AllowedFormats{
iff==o.LogOptions.Format{
iff==o.LogOptions.Format{
...
@@ -249,6 +268,24 @@ func (o *AuditWebhookOptions) AddFlags(fs *pflag.FlagSet) {
...
@@ -249,6 +268,24 @@ func (o *AuditWebhookOptions) AddFlags(fs *pflag.FlagSet) {
"Strategy for sending audit events. Blocking indicates sending events should block"+
"Strategy for sending audit events. Blocking indicates sending events should block"+
" server responses. Batch causes the webhook to buffer and send events"+
" server responses. Batch causes the webhook to buffer and send events"+
" asynchronously. Known modes are "+strings.Join(pluginwebhook.AllowedModes,",")+".")
" asynchronously. Known modes are "+strings.Join(pluginwebhook.AllowedModes,",")+".")