Check client if nil before loading resource list
Unlike loading resource, current implementation doesn't check if
client is nil or not when loading resource list.
This commit checks if client is nil or not before loading resource
list.
@@ -162,6 +162,10 @@ func fetchAPIData(log logr.Logger, entry kyverno.ContextEntry, ctx *PolicyContex
}
func loadResourceList(ctx *PolicyContext, p *APIPath) ([]byte, error) {
+ if ctx.Client == nil {
+ return nil, fmt.Errorf("API client is not available")
+ }
+
l, err := ctx.Client.ListResource(p.Version, p.ResourceType, p.Namespace, nil)
if err != nil {
return nil, err
