1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-04-08 10:04:25 +00:00

fixed context variable

Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
This commit is contained in:
NoSkillGirl 2021-09-03 00:19:11 +05:30
parent 62d2df8b63
commit 2dc1f1dc3c

View file

@ -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)
}
}