mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-09 02:29:22 +00:00
removing print statements
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
This commit is contained in:
parent
c607408098
commit
6361aeae21
3 changed files with 20 additions and 33 deletions
|
@ -2,7 +2,6 @@ package common
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -30,8 +29,7 @@ func CallMetrics() (string, error) {
|
|||
return newStr, nil
|
||||
}
|
||||
|
||||
func ProcessMetrics(newStr, e2ePolicyName string, e2eTime time.Time) bool {
|
||||
fmt.Println("e2ePolicyName: ", e2ePolicyName, "e2eTime: ", e2eTime)
|
||||
func ProcessMetrics(newStr, e2ePolicyName string, e2eTime time.Time) (bool, error) {
|
||||
var action, policyName string
|
||||
var timeInTimeFormat time.Time
|
||||
var err error
|
||||
|
@ -53,29 +51,20 @@ func ProcessMetrics(newStr, e2ePolicyName string, e2eTime time.Time) bool {
|
|||
layout := "2006-01-02 15:04:05 -0700 MST"
|
||||
timeInTimeFormat, err = time.Parse(layout, splitByQuote[1])
|
||||
if err != nil {
|
||||
fmt.Println("error occurred: ", err)
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if policyName == e2ePolicyName {
|
||||
fmt.Println("--------------------------------------------------------")
|
||||
fmt.Println(lineSplitedByNewLine)
|
||||
fmt.Println("action: ", action)
|
||||
fmt.Println("policyName: ", policyName)
|
||||
fmt.Println("timeInTimeFormat: ", timeInTimeFormat)
|
||||
|
||||
diff := e2eTime.Sub(timeInTimeFormat)
|
||||
fmt.Println("diff: ", diff)
|
||||
if diff < time.Second {
|
||||
fmt.Println("****** condition ******")
|
||||
if action == "created" {
|
||||
fmt.Println("************policy created**************")
|
||||
return true
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
return false, nil
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ func Test_ClusterRole_ClusterRoleBinding_Sets(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
@ -238,10 +238,8 @@ func Test_Role_RoleBinding_Sets(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("##################################################")
|
||||
fmt.Println("metricsString: ", metricsString)
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
@ -379,8 +377,8 @@ func Test_Generate_NetworkPolicy(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, test.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, test.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
@ -484,8 +482,8 @@ func Test_Generate_Namespace_Label_Actions(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, test.GeneratePolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, test.GeneratePolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
@ -688,8 +686,8 @@ func Test_Generate_Synchronize_Flag(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, test.GeneratePolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, test.GeneratePolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
@ -891,8 +889,8 @@ func Test_Source_Resource_Update_Replication(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -92,8 +92,8 @@ func Test_Mutate_Sets(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, tests.PolicyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
@ -182,8 +182,8 @@ func Test_Mutate_Ingress(t *testing.T) {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policySyncBool = commonE2E.ProcessMetrics(metricsString, ingressTests.policyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false {
|
||||
policySyncBool, err = commonE2E.ProcessMetrics(metricsString, ingressTests.policyName, timeBeforePolicyCreation)
|
||||
if policySyncBool == false || err != nil {
|
||||
return errors.New("policy not created")
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Add table
Reference in a new issue