mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
fix: remove filtering for policy admission handlers (#5462)
* fix: remove filtering for policy admission handlers Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * move kyverno filtering Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> Co-authored-by: Prateek Pandey <prateek.pandey@nirmata.com>
This commit is contained in:
parent
42221a93e4
commit
67bd7b1edc
4 changed files with 5 additions and 9 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/go-logr/logr"
|
||||
"github.com/kyverno/kyverno/pkg/config"
|
||||
webhookutils "github.com/kyverno/kyverno/pkg/webhooks/utils"
|
||||
admissionv1 "k8s.io/api/admission/v1"
|
||||
)
|
||||
|
||||
|
@ -18,6 +19,9 @@ func (inner AdmissionHandler) withFilter(c config.Configuration) AdmissionHandle
|
|||
if c.ToFilter(request.Kind.Kind, request.Namespace, request.Name) {
|
||||
return nil
|
||||
}
|
||||
if webhookutils.ExcludeKyvernoResources(request.Kind.Kind) {
|
||||
return nil
|
||||
}
|
||||
return inner(ctx, logger, request, startTime)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,6 @@ func (h *handlers) Validate(ctx context.Context, logger logr.Logger, request *ad
|
|||
return admissionutils.Response(err, warnings...)
|
||||
}
|
||||
|
||||
func (h *handlers) Mutate(ctx context.Context, logger logr.Logger, request *admissionv1.AdmissionRequest, _ time.Time) *admissionv1.AdmissionResponse {
|
||||
func (h *handlers) Mutate(_ context.Context, _ logr.Logger, _ *admissionv1.AdmissionRequest, _ time.Time) *admissionv1.AdmissionResponse {
|
||||
return admissionutils.ResponseSuccess()
|
||||
}
|
||||
|
|
|
@ -95,9 +95,6 @@ func NewHandlers(
|
|||
}
|
||||
|
||||
func (h *handlers) Validate(ctx context.Context, logger logr.Logger, request *admissionv1.AdmissionRequest, failurePolicy string, startTime time.Time) *admissionv1.AdmissionResponse {
|
||||
if webhookutils.ExcludeKyvernoResources(request.Kind.Kind) {
|
||||
return admissionutils.ResponseSuccess()
|
||||
}
|
||||
kind := request.Kind.Kind
|
||||
logger = logger.WithValues("kind", kind)
|
||||
logger.V(4).Info("received an admission request in validating webhook")
|
||||
|
@ -145,9 +142,6 @@ func (h *handlers) Validate(ctx context.Context, logger logr.Logger, request *ad
|
|||
}
|
||||
|
||||
func (h *handlers) Mutate(ctx context.Context, logger logr.Logger, request *admissionv1.AdmissionRequest, failurePolicy string, startTime time.Time) *admissionv1.AdmissionResponse {
|
||||
if webhookutils.ExcludeKyvernoResources(request.Kind.Kind) {
|
||||
return admissionutils.ResponseSuccess()
|
||||
}
|
||||
if request.Operation == admissionv1.Delete {
|
||||
return admissionutils.ResponseSuccess()
|
||||
}
|
||||
|
|
|
@ -103,7 +103,6 @@ func NewServer(
|
|||
"POST",
|
||||
config.PolicyMutatingWebhookServicePath,
|
||||
handlers.FromAdmissionFunc("MUTATE", policyHandlers.Mutate).
|
||||
WithFilter(configuration).
|
||||
WithDump(debugModeOpts.DumpPayload).
|
||||
WithMetrics(metricsConfig).
|
||||
WithAdmission(policyLogger.WithName("mutate")).
|
||||
|
@ -113,7 +112,6 @@ func NewServer(
|
|||
"POST",
|
||||
config.PolicyValidatingWebhookServicePath,
|
||||
handlers.FromAdmissionFunc("VALIDATE", policyHandlers.Validate).
|
||||
WithFilter(configuration).
|
||||
WithDump(debugModeOpts.DumpPayload).
|
||||
WithMetrics(metricsConfig).
|
||||
WithAdmission(policyLogger.WithName("validate")).
|
||||
|
|
Loading…
Reference in a new issue