1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00

remove ownerReferences when cloning resources to other namespace.

Signed-off-by: Matthias Frey <matthias.frey@kit.edu>
This commit is contained in:
Matthias Frey 2021-08-24 16:02:12 +02:00
parent c522343c03
commit 605110d4ca

View file

@ -422,6 +422,10 @@ func manageClone(log logr.Logger, apiVersion, kind, namespace, name, policy stri
if err != nil {
return nil, Skip, fmt.Errorf("source resource %s %s/%s/%s not found. %v", apiVersion, kind, rNamespace, rName, err)
}
// remove ownerReferences when cloning resources to other namespace
if rNamespace != namespace && obj.GetOwnerReferences() != nil {
obj.SetOwnerReferences(nil)
}
// check if resource to be generated exists
newResource, err := client.GetResource(apiVersion, kind, namespace, name)