1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/pkg/background/mutate.go
Charles-Edouard Brétéché b36a2ecdcc
feat: bump update request api version (#10508)
* feat: bump update request api version

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* use v2

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* codegen

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* codegen

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix linter

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* fix linter

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2024-06-20 09:44:43 +00:00

21 lines
649 B
Go

package background
import (
"context"
kyvernov2 "github.com/kyverno/kyverno/api/kyverno/v2"
common "github.com/kyverno/kyverno/pkg/background/common"
"github.com/kyverno/kyverno/pkg/config"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func (c *controller) handleMutatePolicyAbsence(ur *kyvernov2.UpdateRequest) error {
selector := &metav1.LabelSelector{
MatchLabels: common.MutateLabelsSet(ur.Spec.Policy, nil),
}
return c.kyvernoClient.KyvernoV2().UpdateRequests(config.KyvernoNamespace()).DeleteCollection(
context.TODO(),
metav1.DeleteOptions{},
metav1.ListOptions{LabelSelector: metav1.FormatLabelSelector(selector)},
)
}