mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
generate refactorings
This commit is contained in:
parent
72d35572d4
commit
e67747260b
4 changed files with 4 additions and 10 deletions
|
@ -28,7 +28,7 @@ func AddLabels(client *kyvernoclient.Clientset, grInformer kyvernoinformer.Gener
|
|||
for _, gr := range grList {
|
||||
|
||||
grLabels := gr.Labels
|
||||
if grLabels == nil || len(grLabels) == 0 {
|
||||
if len(grLabels) == 0 {
|
||||
grLabels = make(map[string]string)
|
||||
}
|
||||
grLabels["generate.kyverno.io/policy-name"] = gr.Spec.Policy
|
||||
|
@ -53,7 +53,6 @@ func AddLabels(client *kyvernoclient.Clientset, grInformer kyvernoinformer.Gener
|
|||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func addLabelForGR(name string, namespace string, client *kyvernoclient.Clientset, grInformer kyvernoinformer.GenerateRequestInformer) error {
|
||||
|
@ -64,7 +63,7 @@ func addLabelForGR(name string, namespace string, client *kyvernoclient.Clientse
|
|||
}
|
||||
|
||||
grLabels := gr.Labels
|
||||
if grLabels == nil || len(grLabels) == 0 {
|
||||
if len(grLabels) == 0 {
|
||||
grLabels = make(map[string]string)
|
||||
}
|
||||
grLabels["generate.kyverno.io/policy-name"] = gr.Spec.Policy
|
||||
|
|
|
@ -440,13 +440,10 @@ func updateGR(kyvernoClient *kyvernoclient.Clientset, policyKey string, grList [
|
|||
for _, gr := range grList {
|
||||
if policyKey == gr.Spec.Policy {
|
||||
grLabels := gr.Labels
|
||||
if grLabels == nil || len(grLabels) == 0 {
|
||||
if len(grLabels) == 0 {
|
||||
grLabels = make(map[string]string)
|
||||
}
|
||||
grLabels["policy-update"] = fmt.Sprintf("revision-count-%d", rand.Intn(100000))
|
||||
// gr.SetLabels(map[string]string{
|
||||
// "policy-update": fmt.Sprintf("revision-count-%d", rand.Intn(100000)),
|
||||
// })
|
||||
gr.SetLabels(grLabels)
|
||||
_, err := kyvernoClient.KyvernoV1().GenerateRequests(config.KyvernoNamespace).Update(context.TODO(), gr, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
|
|
|
@ -155,7 +155,7 @@ func retryApplyResource(client *kyvernoclient.Clientset, grSpec kyverno.Generate
|
|||
for _, v := range grList {
|
||||
|
||||
grLabels := gr.Labels
|
||||
if grLabels == nil || len(grLabels) == 0 {
|
||||
if len(grLabels) == 0 {
|
||||
grLabels = make(map[string]string)
|
||||
}
|
||||
grLabels["resources-update"] = "true"
|
||||
|
|
|
@ -86,8 +86,6 @@ func (ws *WebhookServer) HandleGenerate(request *v1beta1.AdmissionRequest, polic
|
|||
if request.Operation == v1beta1.Update {
|
||||
ws.handleUpdate(request)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//HandleUpdate handles admission-requests for update
|
||||
|
|
Loading…
Add table
Reference in a new issue