1
0
Fork 0
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:
Mariam Fahmy 2023-08-23 18:22:37 +03:00 committed by GitHub
parent e1783e7375
commit 333845677a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -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),

View file

@ -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(