From fbc4eac84c182a90aec7712088dd1fe90107db3f Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Sun, 22 Oct 2023 13:06:02 +0900 Subject: [PATCH] Fix trying to list cluster-level resources when namespace specified close #984 --- pkg/kube/resources.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/kube/resources.go b/pkg/kube/resources.go index 585067612..e2d43954b 100644 --- a/pkg/kube/resources.go +++ b/pkg/kube/resources.go @@ -336,6 +336,10 @@ func CreateResourceProviderFromAPI(ctx context.Context, kube kubernetes.Interfac logrus.Warnf("Error retrieving mapping of Kind %s because of error: %v", kind, err) return nil, err } + if c.Namespace != "" && mapping.Scope.Name() != meta.RESTScopeNameNamespace { + logrus.Infof("Skipping %s because of auditing specific namespace", mapping.GroupVersionKind) + continue + } logrus.Info("Loading " + kind) objects, err := dynamic.Resource(mapping.Resource).Namespace(c.Namespace).List(ctx, metav1.ListOptions{})