mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
add lables update fix
This commit is contained in:
parent
9913af0253
commit
dfaeaa7f8e
2 changed files with 12 additions and 7 deletions
|
@ -15,7 +15,7 @@ import (
|
|||
dclient "github.com/kyverno/kyverno/pkg/dclient"
|
||||
event "github.com/kyverno/kyverno/pkg/event"
|
||||
"github.com/kyverno/kyverno/pkg/generate"
|
||||
backwardcompatibility "github.com/kyverno/kyverno/pkg/generate/backwardCompatibility"
|
||||
backwardcompatibility "github.com/kyverno/kyverno/pkg/generate/backward_compatibility"
|
||||
generatecleanup "github.com/kyverno/kyverno/pkg/generate/cleanup"
|
||||
"github.com/kyverno/kyverno/pkg/openapi"
|
||||
"github.com/kyverno/kyverno/pkg/policy"
|
||||
|
|
|
@ -23,12 +23,17 @@ func AddLabels(client *kyvernoclient.Clientset, grInformer kyvernoinformer.Gener
|
|||
}
|
||||
|
||||
for _, gr := range grList {
|
||||
gr.SetLabels(map[string]string{
|
||||
"generate.kyverno.io/policy-name": gr.Spec.Policy,
|
||||
"generate.kyverno.io/resource-name": gr.Spec.Resource.Name,
|
||||
"generate.kyverno.io/resource-kind": gr.Spec.Resource.Kind,
|
||||
"generate.kyverno.io/resource-namespace": gr.Spec.Resource.Namespace,
|
||||
})
|
||||
|
||||
grLabels := gr.Labels
|
||||
if grLabels == nil || len(grLabels) == 0 {
|
||||
grLabels = make(map[string]string)
|
||||
}
|
||||
grLabels["generate.kyverno.io/policy-name"] = gr.Spec.Policy
|
||||
grLabels["generate.kyverno.io/resource-name"] = gr.Spec.Resource.Name
|
||||
grLabels["generate.kyverno.io/resource-kind"] = gr.Spec.Resource.Kind
|
||||
grLabels["generate.kyverno.io/resource-namespace"] = gr.Spec.Resource.Namespace
|
||||
|
||||
gr.SetLabels(grLabels)
|
||||
|
||||
_, err = client.KyvernoV1().GenerateRequests(config.KyvernoNamespace).Update(context.TODO(), gr, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue