mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-08 10:04:25 +00:00
Tidy up some of the apply command output code (#2633)
Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
parent
adf39ed6fb
commit
9932525c3c
1 changed files with 15 additions and 8 deletions
|
@ -336,30 +336,37 @@ func checkMutateLogPath(mutateLogPath string) (mutateLogPathIsDir bool, err erro
|
|||
|
||||
// printReportOrViolation - printing policy report/violations
|
||||
func printReportOrViolation(policyReport bool, rc *common.ResultCounts, resourcePaths []string, resourcesLen int, skipInvalidPolicies SkippedInvalidPolicies, stdin bool, pvInfos []policyreport.Info) {
|
||||
divider := "----------------------------------------------------------------------"
|
||||
|
||||
if len(skipInvalidPolicies.skipped) > 0 {
|
||||
fmt.Println("----------------------------------------------------------------------\nPolicies Skipped(as required variables are not provided by the users):")
|
||||
fmt.Println(divider)
|
||||
fmt.Println("Policies Skipped (as required variables are not provided by the user):")
|
||||
for i, policyName := range skipInvalidPolicies.skipped {
|
||||
fmt.Println(i+1, ". ", policyName)
|
||||
fmt.Printf("%d. %s\n", i+1, policyName)
|
||||
}
|
||||
fmt.Println("----------------------------------------------------------------------")
|
||||
fmt.Println(divider)
|
||||
}
|
||||
if len(skipInvalidPolicies.invalid) > 0 {
|
||||
fmt.Println("----------------------------------------------------------------------\nInvalid Policies:")
|
||||
fmt.Println(divider)
|
||||
fmt.Println("Invalid Policies:")
|
||||
for i, policyName := range skipInvalidPolicies.invalid {
|
||||
fmt.Println(i+1, ". ", policyName)
|
||||
fmt.Printf("%d. %s\n", i+1, policyName)
|
||||
}
|
||||
fmt.Println("----------------------------------------------------------------------")
|
||||
fmt.Println(divider)
|
||||
}
|
||||
|
||||
if policyReport {
|
||||
resps := buildPolicyReports(pvInfos)
|
||||
if len(resps) > 0 || resourcesLen == 0 {
|
||||
fmt.Println("\n----------------------------------------------------------------------\nPOLICY REPORT:\n----------------------------------------------------------------------")
|
||||
fmt.Println(divider)
|
||||
fmt.Println("POLICY REPORT:")
|
||||
fmt.Println(divider)
|
||||
report, _ := generateCLIRaw(resps)
|
||||
yamlReport, _ := yaml1.Marshal(report)
|
||||
fmt.Println(string(yamlReport))
|
||||
} else {
|
||||
fmt.Println("----------------------------------------------------------------------\nPOLICY REPORT: skip generating policy report (no validate policy found/resource skipped)")
|
||||
fmt.Println(divider)
|
||||
fmt.Println("POLICY REPORT: skip generating policy report (no validate policy found/resource skipped)")
|
||||
}
|
||||
} else {
|
||||
if !stdin {
|
||||
|
|
Loading…
Add table
Reference in a new issue