Skip to content

Commit

Permalink
fixed skipping resources
Browse files Browse the repository at this point in the history
  • Loading branch information
NoSkillGirl committed Nov 18, 2020
1 parent d468368 commit 85d47e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/kyverno/apply/command.go
Expand Up @@ -141,7 +141,7 @@ func Command() *cobra.Command {
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)
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/kyverno/common/fetch.go
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -116,13 +116,14 @@ func getResourcesOfTypeFromCluster(resourceTypes []string, dClient *client.Clien
r := make(map[string]map[string]*unstructured.Unstructured)

var resources []*unstructured.Unstructured

for _, kind := range resourceTypes {
r[kind] = make(map[string]*unstructured.Unstructured)
resourceList, err := dClient.ListResource("", kind, namespace, nil)
if err != nil {
return nil, err
// return nil, err
continue
}

version := resourceList.GetAPIVersion()
for _, resource := range resourceList.Items {
r[kind][resource.GetName()] = resource.DeepCopy()
Expand Down

0 comments on commit 85d47e1

Please sign in to comment.