1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

refactor: move webhook events utils in utils package (#4545)

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>

Signed-off-by: Charles-Edouard Brétéché <charled.breteche@gmail.com>
This commit is contained in:
Charles-Edouard Brétéché 2022-09-08 18:10:27 +02:00 committed by GitHub
parent 3b556abe63
commit 16c2d880c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -278,7 +278,7 @@ func (h *handlers) handleMutation(logger logr.Logger, request *admissionv1.Admis
}
if !isResourceDeleted(policyContext) {
events := generateEvents(engineResponses, false, logger)
events := webhookutils.GenerateEvents(engineResponses, false, logger)
h.eventGen.Add(events...)
}
@ -351,7 +351,7 @@ func (h *handlers) handleVerifyImages(logger logr.Logger, request *admissionv1.A
failurePolicy := policyContext.Policy.GetSpec().GetFailurePolicy()
blocked := webhookutils.BlockRequest(engineResponses, failurePolicy, logger)
if !isResourceDeleted(policyContext) {
events := generateEvents(engineResponses, blocked, logger)
events := webhookutils.GenerateEvents(engineResponses, blocked, logger)
h.eventGen.Add(events...)
}

View file

@ -86,7 +86,7 @@ func (v *validationHandler) handleValidation(
blocked := webhookutils.BlockRequest(engineResponses, failurePolicy, logger)
if deletionTimeStamp == nil {
events := generateEvents(engineResponses, blocked, logger)
events := webhookutils.GenerateEvents(engineResponses, blocked, logger)
v.eventGen.Add(events...)
}

View file

@ -1,4 +1,4 @@
package resource
package utils
import (
"github.com/go-logr/logr"
@ -7,7 +7,7 @@ import (
)
// generateEvents generates event info for the engine responses
func generateEvents(engineResponses []*response.EngineResponse, blocked bool, log logr.Logger) []event.Info {
func GenerateEvents(engineResponses []*response.EngineResponse, blocked bool, log logr.Logger) []event.Info {
var events []event.Info
// - Some/All policies fail or error