mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-15 20:20:22 +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()
|
rclient := registryclient.NewOrDie()
|
||||||
eng := engine.NewEngine(
|
eng := engine.NewEngine(
|
||||||
cfg,
|
cfg,
|
||||||
config.NewDefaultMetricsConfiguration(),
|
config.NewDefaultMetricsConfiguration(),
|
||||||
jmespath.New(cfg),
|
jmespath.New(cfg),
|
||||||
adapters.Client(c.Client),
|
client,
|
||||||
factories.DefaultRegistryClientFactory(adapters.RegistryClient(rclient), nil),
|
factories.DefaultRegistryClientFactory(adapters.RegistryClient(rclient), nil),
|
||||||
imageverifycache.DisabledImageVerifyCache(),
|
imageverifycache.DisabledImageVerifyCache(),
|
||||||
store.ContextLoaderFactory(nil),
|
store.ContextLoaderFactory(nil),
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (h validateCELHandler) Process(
|
||||||
auditExpressions := convertAuditAnnotations(auditAnnotations)
|
auditExpressions := convertAuditAnnotations(auditAnnotations)
|
||||||
|
|
||||||
// get the parameter resource if exists
|
// get the parameter resource if exists
|
||||||
if hasParam {
|
if hasParam && h.client != nil {
|
||||||
paramKind := rule.Validation.CEL.GetParamKind()
|
paramKind := rule.Validation.CEL.GetParamKind()
|
||||||
paramRef := rule.Validation.CEL.GetParamRef()
|
paramRef := rule.Validation.CEL.GetParamRef()
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ func (h validateCELHandler) Process(
|
||||||
if gvk.Kind == "Namespace" && gvk.Version == "v1" && gvk.Group == "" {
|
if gvk.Kind == "Namespace" && gvk.Version == "v1" && gvk.Group == "" {
|
||||||
namespaceName = ""
|
namespaceName = ""
|
||||||
}
|
}
|
||||||
if namespaceName != "" {
|
if namespaceName != "" && h.client != nil {
|
||||||
namespace, err = h.client.GetNamespace(ctx, namespaceName, metav1.GetOptions{})
|
namespace, err = h.client.GetNamespace(ctx, namespaceName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return resource, handlers.WithResponses(
|
return resource, handlers.WithResponses(
|
||||||
|
|
Loading…
Add table
Reference in a new issue