1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

added crypto package

This commit is contained in:
NoSkillGirl 2021-01-04 19:10:36 +05:30
parent e67747260b
commit b4f473ec23

View file

@ -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())
}
}
}
}