diff --git a/pkg/kyverno/apply/command.go b/pkg/kyverno/apply/command.go index 4e60bb4ffe..d4337d0f65 100644 --- a/pkg/kyverno/apply/command.go +++ b/pkg/kyverno/apply/command.go @@ -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----------------------------------------------------------------------") diff --git a/pkg/kyverno/apply/generate.go b/pkg/kyverno/apply/generate.go index 361932c37e..3153b2965e 100644 --- a/pkg/kyverno/apply/generate.go +++ b/pkg/kyverno/apply/generate.go @@ -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 {