From 720cbc0df67ed7296bdbc5b8fae057fb332bf2c5 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 4665213c6..6d70eb777 100644 --- a/pkg/kube/resources.go +++ b/pkg/kube/resources.go @@ -343,6 +343,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{})