mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
fix: check if client is set in CEL validations (#8099)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
This commit is contained in:
parent
e1783e7375
commit
333845677a
2 changed files with 7 additions and 3 deletions
|
@ -113,12 +113,16 @@ OuterLoop:
|
|||
}
|
||||
}
|
||||
}
|
||||
var client engineapi.Client
|
||||
if c.Client != nil {
|
||||
client = adapters.Client(c.Client)
|
||||
}
|
||||
rclient := registryclient.NewOrDie()
|
||||
eng := engine.NewEngine(
|
||||
cfg,
|
||||
config.NewDefaultMetricsConfiguration(),
|
||||
jmespath.New(cfg),
|
||||
adapters.Client(c.Client),
|
||||
client,
|
||||
factories.DefaultRegistryClientFactory(adapters.RegistryClient(rclient), nil),
|
||||
imageverifycache.DisabledImageVerifyCache(),
|
||||
store.ContextLoaderFactory(nil),
|
||||
|
|
|
@ -77,7 +77,7 @@ func (h validateCELHandler) Process(
|
|||
auditExpressions := convertAuditAnnotations(auditAnnotations)
|
||||
|
||||
// get the parameter resource if exists
|
||||
if hasParam {
|
||||
if hasParam && h.client != nil {
|
||||
paramKind := rule.Validation.CEL.GetParamKind()
|
||||
paramRef := rule.Validation.CEL.GetParamRef()
|
||||
|
||||
|
@ -122,7 +122,7 @@ func (h validateCELHandler) Process(
|
|||
if gvk.Kind == "Namespace" && gvk.Version == "v1" && gvk.Group == "" {
|
||||
namespaceName = ""
|
||||
}
|
||||
if namespaceName != "" {
|
||||
if namespaceName != "" && h.client != nil {
|
||||
namespace, err = h.client.GetNamespace(ctx, namespaceName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return resource, handlers.WithResponses(
|
||||
|
|
Loading…
Reference in a new issue