From b9d38d2fd32424ac856a188c953ada8267d9a44f Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Fri, 15 May 2020 18:51:45 -0700 Subject: [PATCH] fix error "failed to list resources" --- pkg/policy/existing.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/policy/existing.go b/pkg/policy/existing.go index 5f6fe09c67..44850b4df0 100644 --- a/pkg/policy/existing.go +++ b/pkg/policy/existing.go @@ -97,9 +97,14 @@ func getResourcesPerNamespace(kind string, client *client.Client, namespace stri // ls := mergeLabelSectors(rule.MatchResources.Selector, rule.ExcludeResources.Selector) // list resources log.V(4).Info("list resources to be processed") + + if kind == "Namespace" { + namespace = "" + } + list, err := client.ListResource(kind, namespace, ls) if err != nil { - log.Error(err, "failed to list resources", "kind", kind) + log.Error(err, "failed to list resources", "kind", kind, "namespace", namespace) return nil } // filter based on name