1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00

fixed skipping resources

This commit is contained in:
NoSkillGirl 2020-11-18 11:08:24 +05:30
parent d468368ec2
commit 85d47e16e7
2 changed files with 5 additions and 4 deletions

View file

@ -141,7 +141,7 @@ func Command() *cobra.Command {
return sanitizedError.NewWithError("failed to load resources", err) return sanitizedError.NewWithError("failed to load resources", err)
} }
} }
if len(resources) == 0 { if len(resources) == 0 && !cluster {
return sanitizedError.NewWithError("valid resource(s) not provided", err) return sanitizedError.NewWithError("valid resource(s) not provided", err)
} }

View file

@ -61,7 +61,7 @@ func GetResources(policies []*v1.ClusterPolicy, resourcePaths []string, dClient
} }
} }
} }
if lenOfResource >= len(resources){ if lenOfResource >= len(resources) {
fmt.Printf("\n----------------------------------------------------------------------\n%s not found in cluster\n----------------------------------------------------------------------\n", resourcePath) fmt.Printf("\n----------------------------------------------------------------------\n%s not found in cluster\n----------------------------------------------------------------------\n", resourcePath)
} }
} }
@ -116,13 +116,14 @@ func getResourcesOfTypeFromCluster(resourceTypes []string, dClient *client.Clien
r := make(map[string]map[string]*unstructured.Unstructured) r := make(map[string]map[string]*unstructured.Unstructured)
var resources []*unstructured.Unstructured var resources []*unstructured.Unstructured
for _, kind := range resourceTypes { for _, kind := range resourceTypes {
r[kind] = make(map[string]*unstructured.Unstructured) r[kind] = make(map[string]*unstructured.Unstructured)
resourceList, err := dClient.ListResource("", kind, namespace, nil) resourceList, err := dClient.ListResource("", kind, namespace, nil)
if err != nil { if err != nil {
return nil, err // return nil, err
continue
} }
version := resourceList.GetAPIVersion() version := resourceList.GetAPIVersion()
for _, resource := range resourceList.Items { for _, resource := range resourceList.Items {
r[kind][resource.GetName()] = resource.DeepCopy() r[kind][resource.GetName()] = resource.DeepCopy()