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

CR refactor

This commit is contained in:
shivkumar dudhani 2020-02-26 17:02:16 -08:00
parent 03ee46e1d9
commit 73c0aaca79

View file

@ -76,7 +76,6 @@ func subValR(ctx context.EvalInterface, valuePattern string, path string, errs *
if ok, retVal := processIfSingleVariable(ctx, valuePattern, path, errs); ok {
return retVal
}
regexVar := `\{\{([^{}]*)\}\}`
// var emptyInterface interface{}
var failedVars []string
// process type string
@ -87,7 +86,7 @@ func subValR(ctx context.EvalInterface, valuePattern string, path string, errs *
break
}
// get variables at this level
validRegex := regexp.MustCompile(regexVar)
validRegex := regexp.MustCompile(variableRegex)
groups := validRegex.FindAllStringSubmatch(valueStr, -1)
if len(groups) == 0 {
// there was no match
@ -157,7 +156,7 @@ func processIfSingleVariable(ctx context.EvalInterface, valuePattern interface{}
return false, nil
}
// as there will be exactly one variable based on the above regex
for _, group := range groups {
group := groups[0]
variable, err := ctx.Query(group[1])
if err != nil || variable == nil {
*errs = append(*errs, fmt.Errorf("failed to resolve %v at path %s", group[1], path))
@ -165,6 +164,4 @@ func processIfSingleVariable(ctx context.EvalInterface, valuePattern interface{}
return true, valuePattern
}
return true, variable
}
return false, nil
}