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

added pass resources in policy report

This commit is contained in:
NoSkillGirl 2020-11-13 00:48:40 +05:30
parent a7a5c07f84
commit aaa2b96b35
2 changed files with 8 additions and 1 deletions

View file

@ -17,6 +17,7 @@ import (
"github.com/kyverno/kyverno/pkg/engine/context"
"github.com/kyverno/kyverno/pkg/engine/response"
"github.com/kyverno/kyverno/pkg/kyverno/common"
pkgCommon "github.com/kyverno/kyverno/pkg/common"
"github.com/kyverno/kyverno/pkg/kyverno/sanitizedError"
"github.com/kyverno/kyverno/pkg/openapi"
policy2 "github.com/kyverno/kyverno/pkg/policy"
@ -299,6 +300,7 @@ func getResourceAccordingToResourcePath(resourcePaths []string, cluster bool, po
// printReportOrViolation - printing policy report/violations
func printReportOrViolation(policyReport bool, engineResponses []response.EngineResponse, rc *resultCounts, resourcePaths []string) {
if policyReport {
os.Setenv("POLICY-TYPE", pkgCommon.PolicyReport)
resps := buildPolicyReports(engineResponses)
if len(resps) > 0 {
fmt.Println("----------------------------------------------------------------------\nPOLICY REPORT:\n----------------------------------------------------------------------")

View file

@ -120,7 +120,12 @@ func mergeResults(report *unstructured.Unstructured, results *[]interface{}) {
func updateSummary(results []interface{}) map[string]interface{} {
summary := make(map[string]interface{})
status := []string{report.StatusPass, report.StatusFail, report.StatusError, report.StatusSkip, report.StatusWarn}
for i := 0; i < 5; i++ {
if _, ok := summary[status[i]].(int64); !ok {
summary[status[i]] = int64(0)
}
}
for _, result := range results {
typedResult, ok := result.(map[string]interface{})
if !ok {