mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-05 15:37:19 +00:00
Merge pull request #2222 from NoSkillGirl/2180_backwards_compatibility
Added backward compatibility | Resolving variables from the resource passed | CLI
This commit is contained in:
commit
3dd53c6ad2
1 changed files with 14 additions and 2 deletions
|
@ -387,6 +387,7 @@ func GetVariable(variablesString, valuesFile string, fs billy.Filesystem, isGit
|
|||
valuesMapRule := make(map[string]map[string]Rule)
|
||||
namespaceSelectorMap := make(map[string]map[string]string)
|
||||
variables := make(map[string]string)
|
||||
reqObjVars := ""
|
||||
|
||||
var yamlFile []byte
|
||||
var err error
|
||||
|
@ -395,7 +396,10 @@ func GetVariable(variablesString, valuesFile string, fs billy.Filesystem, isGit
|
|||
for _, kvpair := range kvpairs {
|
||||
kvs := strings.Split(strings.Trim(kvpair, " "), "=")
|
||||
if strings.Contains(kvs[0], "request.object") {
|
||||
return variables, valuesMapResource, namespaceSelectorMap, sanitizederror.NewWithError("variable request.object.* is handled by kyverno. please do not pass value for request.object variables ", err)
|
||||
if !strings.Contains(reqObjVars, kvs[0]) {
|
||||
reqObjVars = reqObjVars + "," + kvs[0]
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
variables[strings.Trim(kvs[0], " ")] = strings.Trim(kvs[1], " ")
|
||||
|
@ -432,7 +436,11 @@ func GetVariable(variablesString, valuesFile string, fs billy.Filesystem, isGit
|
|||
for _, r := range p.Resources {
|
||||
for variableInFile := range r.Values {
|
||||
if strings.Contains(variableInFile, "request.object") {
|
||||
return variables, valuesMapResource, namespaceSelectorMap, sanitizederror.NewWithError("variable request.object.* is handled by kyverno. please do not pass value for request.object variables ", err)
|
||||
if !strings.Contains(reqObjVars, variableInFile) {
|
||||
reqObjVars = reqObjVars + "," + variableInFile
|
||||
}
|
||||
delete(r.Values, variableInFile)
|
||||
continue
|
||||
}
|
||||
}
|
||||
resourceMap[r.Name] = r
|
||||
|
@ -453,6 +461,10 @@ func GetVariable(variablesString, valuesFile string, fs billy.Filesystem, isGit
|
|||
}
|
||||
}
|
||||
|
||||
if reqObjVars != "" {
|
||||
fmt.Printf(("\nvariable request.object.* is handled by kyverno. ignoring value of variables: `%v` passed by the user.\n"), reqObjVars)
|
||||
}
|
||||
|
||||
storePolices := make([]store.Policy, 0)
|
||||
for policyName, ruleMap := range valuesMapRule {
|
||||
storeRules := make([]store.Rule, 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue