mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-09 09:26:54 +00:00
28 lines
874 B
Go
28 lines
874 B
Go
|
package mutation
|
||
|
|
||
|
import (
|
||
|
admissionutils "github.com/kyverno/kyverno/pkg/utils/admission"
|
||
|
reportutils "github.com/kyverno/kyverno/pkg/utils/report"
|
||
|
"github.com/kyverno/kyverno/pkg/webhooks/handlers"
|
||
|
admissionv1 "k8s.io/api/admission/v1"
|
||
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||
|
)
|
||
|
|
||
|
func (v *mutationHandler) needsReports(request handlers.AdmissionRequest, resource unstructured.Unstructured, admissionReport bool) bool {
|
||
|
createReport := admissionReport
|
||
|
if admissionutils.IsDryRun(request.AdmissionRequest) {
|
||
|
createReport = false
|
||
|
}
|
||
|
// we don't need reports for deletions
|
||
|
if request.Operation == admissionv1.Delete {
|
||
|
createReport = false
|
||
|
}
|
||
|
// check if the resource supports reporting
|
||
|
if !reportutils.IsGvkSupported(schema.GroupVersionKind(request.Kind)) {
|
||
|
createReport = false
|
||
|
}
|
||
|
|
||
|
return createReport
|
||
|
}
|