1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-16 12:40:43 +00:00

fix: Check for the client being nil before applying a mutation (#10726)

Signed-off-by: aerosouund <aerosound161@gmail.com>
Co-authored-by: shuting <shuting@nirmata.com>
This commit is contained in:
Ammar Yasser 2024-07-26 13:49:51 +03:00 committed by GitHub
parent 8109f2194e
commit f618717f75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ package engine
import (
"context"
"fmt"
"time"
"github.com/go-logr/logr"
@ -36,6 +37,9 @@ func (e *engine) mutate(
return nil, nil
}
if !policyContext.AdmissionOperation() && rule.HasMutateExisting() {
if e.client == nil {
return nil, fmt.Errorf("Handler factory requires a client but a nil client was passed, likely due to a bug or unsupported operation.")
}
return mutation.NewMutateExistingHandler(e.client)
}
return mutation.NewMutateResourceHandler()