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

delete if sync is true

This commit is contained in:
evalsocket 2020-07-10 17:06:16 -07:00
parent c319add062
commit 04ecfd3998

View file

@ -47,10 +47,15 @@ func (c *Controller) applyGenerate(resource unstructured.Unstructured, gr kyvern
policy, err := c.pLister.Get(gr.Spec.Policy)
if err != nil {
if apierrors.IsNotFound(err) {
if err := c.client.DeleteResource(gr.Spec.Resource.Kind, gr.Spec.Resource.Namespace, gr.Spec.Resource.Name, false); err != nil {
logger.V(4).Info("Generated resource is deleted")
return nil, err
for _, e := range policy.Spec.Rules {
if e.Generation.Synchronize {
if err := c.client.DeleteResource(e.Generation.Kind, e.Generation.Namespace, e.Generation.Name, false); err != nil {
logger.V(4).Info("Generated resource is deleted")
return nil, err
}
}
}
return nil, nil
}
logger.Error(err, "error in getting policy")