substitute variable values on a copy of policy rule
@@ -266,7 +266,10 @@ func handleData(ruleName string, generateRule kyverno.Generation, client *dclien
return nil, NewViolation(ruleName, fmt.Errorf("path not present in generate data: %s", invalidPaths))
}
- newData := variables.SubstituteVariables(ctx, generateRule.Data)
+ //work on copy
+ copyDataTemp := reflect.Indirect(reflect.ValueOf(generateRule.Data))
+ copyData := copyDataTemp.Interface()
+ newData := variables.SubstituteVariables(ctx, copyData)
// check if resource exists
obj, err := client.GetResource(generateRule.Kind, generateRule.Namespace, generateRule.Name)
