mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
removed print statements
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
This commit is contained in:
parent
98f756fcdd
commit
364174d372
1 changed files with 0 additions and 40 deletions
|
@ -391,10 +391,7 @@ func buildPolicyResults(resps []*response.EngineResponse, testResults []TestResu
|
|||
}
|
||||
}
|
||||
|
||||
// fmt.Println("3*****resultsKey: ", resultsKey)
|
||||
|
||||
patcheResourcePath = append(patcheResourcePath, test.PatchedResource)
|
||||
|
||||
if _, ok := results[resultsKey]; !ok {
|
||||
results[resultsKey] = result
|
||||
}
|
||||
|
@ -471,7 +468,6 @@ func GetAllPossibleResultsKey(policyNs, policy, rule, resourceNsnamespace, kind,
|
|||
resultKey3 := fmt.Sprintf("%s-%s-%s-%s-%s", policyNs, policy, rule, kind, resource)
|
||||
resultKey4 := fmt.Sprintf("%s-%s-%s-%s-%s-%s", policyNs, policy, rule, resourceNsnamespace, kind, resource)
|
||||
resultsKey = append(resultsKey, resultKey1, resultKey2, resultKey3, resultKey4)
|
||||
// fmt.Println("resultsKey: ", resultsKey)
|
||||
return resultsKey
|
||||
}
|
||||
|
||||
|
@ -650,17 +646,9 @@ func applyPoliciesFromPath(fs billy.Filesystem, policyBytes []byte, valuesFile s
|
|||
}
|
||||
engineResponses = append(engineResponses, ers...)
|
||||
pvInfos = append(pvInfos, info)
|
||||
// er, _ := json.Marshal(ers)
|
||||
// fmt.Println("\nEngineResponses: ", string(er))
|
||||
// pvI, _ := json.Marshal(pvInfos)
|
||||
// fmt.Println("\npvInfos: ", string(pvI))
|
||||
}
|
||||
}
|
||||
resultsMap, testResults := buildPolicyResults(engineResponses, values.Results, pvInfos, policyResourcePath, fs, isGit)
|
||||
// rm, _ := json.Marshal(resultsMap)
|
||||
// fmt.Println("\nresultsMap: ", string(rm))
|
||||
// tr, _ := json.Marshal(testResults)
|
||||
// fmt.Println("\testResults: ", string(tr))
|
||||
resultErr := printTestResult(resultsMap, testResults, rc)
|
||||
if resultErr != nil {
|
||||
return sanitizederror.NewWithError("failed to print test result:", resultErr)
|
||||
|
@ -687,82 +675,54 @@ func printTestResult(resps map[string]report.PolicyReportResult, testResults []T
|
|||
if v.Namespace != "" {
|
||||
namespace = v.Namespace
|
||||
}
|
||||
// fmt.Println("namespace: ", namespace)
|
||||
|
||||
res.Resource = boldFgCyan.Sprintf(namespace) + "/" + boldFgCyan.Sprintf(v.Kind) + "/" + boldFgCyan.Sprintf(v.Resource)
|
||||
// fmt.Println("res.Resource: ", res.Resource)
|
||||
var ruleNameInResultKey string
|
||||
|
||||
if v.AutoGeneratedRule != "" {
|
||||
ruleNameInResultKey = fmt.Sprintf("%s-%s", v.AutoGeneratedRule, v.Rule)
|
||||
// fmt.Println("v.AutoGeneratedRule....ruleNameInResultKey: ", ruleNameInResultKey)
|
||||
} else {
|
||||
ruleNameInResultKey = v.Rule
|
||||
// fmt.Println("else.....ruleNameInResultKey: ", ruleNameInResultKey)
|
||||
}
|
||||
|
||||
resultKey := fmt.Sprintf("%s-%s-%s-%s", v.Policy, ruleNameInResultKey, v.Kind, v.Resource)
|
||||
found, _ := isNamespacedPolicy(v.Policy)
|
||||
// fmt.Println("resultKey: ", resultKey)
|
||||
// fmt.Println("found; ", found)
|
||||
|
||||
var ns string
|
||||
// fmt.Println("\nv.policy: ", v.Policy)
|
||||
ns, v.Policy = getUserDefinedPolicyNameAndNamespace(v.Policy)
|
||||
// fmt.Println("nas: ", ns, "\nv.policy: ", v.Policy)
|
||||
|
||||
// fmt.Println("found: ", found, " v.Namespace: ", v.Namespace)
|
||||
// fmt.Println("1*******resultKey: ", resultKey)
|
||||
if found && v.Namespace != "" {
|
||||
resultKey = fmt.Sprintf("%s-%s-%s-%s-%s-%s", ns, v.Policy, ruleNameInResultKey, v.Namespace, v.Kind, v.Resource)
|
||||
// fmt.Println("1...\n resultKey: ", resultKey)
|
||||
} else if found {
|
||||
resultKey = fmt.Sprintf("%s-%s-%s-%s-%s", ns, v.Policy, ruleNameInResultKey, v.Kind, v.Resource)
|
||||
res.Policy = boldFgCyan.Sprintf(ns) + "/" + boldFgCyan.Sprintf(v.Policy)
|
||||
res.Resource = boldFgCyan.Sprintf(namespace) + "/" + boldFgCyan.Sprintf(v.Kind) + "/" + boldFgCyan.Sprintf(v.Resource)
|
||||
// fmt.Println("2...\n resultKey: ", resultKey)
|
||||
// fmt.Println("res.Policy: ", res.Policy)
|
||||
// fmt.Println("res.Resource: ", res.Resource)
|
||||
} else if v.Namespace != "" {
|
||||
res.Resource = boldFgCyan.Sprintf(namespace) + "/" + boldFgCyan.Sprintf(v.Kind) + "/" + boldFgCyan.Sprintf(v.Resource)
|
||||
resultKey = fmt.Sprintf("%s-%s-%s-%s-%s", v.Policy, ruleNameInResultKey, v.Namespace, v.Kind, v.Resource)
|
||||
// fmt.Println("3...\n resultKey: ", resultKey)
|
||||
// fmt.Println("res.Resource: ", res.Resource)
|
||||
}
|
||||
// fmt.Println("2*******resultKey: ", resultKey)
|
||||
|
||||
var testRes report.PolicyReportResult
|
||||
if val, ok := resps[resultKey]; ok {
|
||||
testRes = val
|
||||
// fmt.Println("1--- testRes: ", testRes)
|
||||
} else {
|
||||
res.Result = boldYellow.Sprintf("Not found")
|
||||
rc.Fail++
|
||||
table = append(table, res)
|
||||
// fmt.Println("2--- ")
|
||||
continue
|
||||
}
|
||||
|
||||
// fmt.Println("v.Result: ", v.Result, " v.Status: ", v.Status)
|
||||
if v.Result == "" && v.Status != "" {
|
||||
v.Result = v.Status
|
||||
// fmt.Println("......v.Result: ", v.Result)
|
||||
}
|
||||
|
||||
// fmt.Println("v.Result: ", v.Result, " testRes.Result: ", testRes.Result)
|
||||
if testRes.Result == v.Result {
|
||||
res.Result = boldGreen.Sprintf("Pass")
|
||||
if testRes.Result == report.StatusSkip {
|
||||
// fmt.Println("skip....")
|
||||
res.Result = boldGreen.Sprintf("Pass")
|
||||
rc.Skip++
|
||||
} else {
|
||||
// fmt.Println("pass....")
|
||||
res.Result = boldGreen.Sprintf("Pass")
|
||||
rc.Pass++
|
||||
}
|
||||
} else {
|
||||
// fmt.Println("fail....")
|
||||
res.Result = boldRed.Sprintf("Fail")
|
||||
rc.Fail++
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue