From b4f473ec239ab0c2ba5dd593b69b9666a382481e Mon Sep 17 00:00:00 2001 From: NoSkillGirl Date: Mon, 4 Jan 2021 19:10:36 +0530 Subject: [PATCH] added crypto package --- pkg/policy/validate_controller.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/policy/validate_controller.go b/pkg/policy/validate_controller.go index 9268d43760..98a3988ce6 100644 --- a/pkg/policy/validate_controller.go +++ b/pkg/policy/validate_controller.go @@ -2,8 +2,9 @@ package policy import ( "context" + "crypto/rand" "fmt" - "math/rand" + "math/big" "reflect" "time" @@ -443,13 +444,18 @@ func updateGR(kyvernoClient *kyvernoclient.Clientset, policyKey string, grList [ if len(grLabels) == 0 { grLabels = make(map[string]string) } - grLabels["policy-update"] = fmt.Sprintf("revision-count-%d", rand.Intn(100000)) + + nBig, err := rand.Int(rand.Reader, big.NewInt(100000)) + if err != nil { + logger.Error(err, "failed to generate random interger") + } + grLabels["policy-update"] = fmt.Sprintf("revision-count-%d", nBig.Int64()) gr.SetLabels(grLabels) - _, err := kyvernoClient.KyvernoV1().GenerateRequests(config.KyvernoNamespace).Update(context.TODO(), gr, metav1.UpdateOptions{}) + + _, err = kyvernoClient.KyvernoV1().GenerateRequests(config.KyvernoNamespace).Update(context.TODO(), gr, metav1.UpdateOptions{}) if err != nil { logger.Error(err, "failed to update gr", "name", gr.GetName()) } } } - }