fixed context variable
@@ -779,7 +779,7 @@ func validateRuleContext(rule kyverno.Rule) error {
ruleBytes, _ := json.Marshal(rule)
ruleString := strings.ReplaceAll(string(ruleBytes), " ", "")
for _, contextName := range contextNames {
- if !strings.Contains(ruleString, fmt.Sprintf("{{"+contextName)) {
+ if !strings.Contains(ruleString, fmt.Sprintf("{{"+contextName)) && !strings.Contains(ruleString, fmt.Sprintf("{{\\\""+contextName)) {
return fmt.Errorf("context variable `%s` is not used in the policy", contextName)
}
}
