mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-15 17:51:20 +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:
parent
8109f2194e
commit
f618717f75
1 changed files with 4 additions and 0 deletions
|
@ -2,6 +2,7 @@ package engine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-logr/logr"
|
"github.com/go-logr/logr"
|
||||||
|
@ -36,6 +37,9 @@ func (e *engine) mutate(
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
if !policyContext.AdmissionOperation() && rule.HasMutateExisting() {
|
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.NewMutateExistingHandler(e.client)
|
||||||
}
|
}
|
||||||
return mutation.NewMutateResourceHandler()
|
return mutation.NewMutateResourceHandler()
|
||||||
|
|
Loading…
Reference in a new issue