mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
fix: Fixed issue with AddVariable that prevented certain variables (#7981)
When using a label or annotation with quoted dots, AddVariable was splitting inside the quote causing it to be improperly parsed and replaced Signed-off-by: mvaal <mvaal@expediagroup.com>
This commit is contained in:
parent
0b5f9a0f25
commit
bf21fbf673
1 changed files with 8 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package context
|
||||
|
||||
import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
@ -146,7 +147,13 @@ func (ctx *context) AddRequest(request admissionv1.AdmissionRequest) error {
|
|||
}
|
||||
|
||||
func (ctx *context) AddVariable(key string, value interface{}) error {
|
||||
return addToContext(ctx, value, strings.Split(key, ".")...)
|
||||
reader := csv.NewReader(strings.NewReader(key))
|
||||
reader.Comma = '.'
|
||||
if fields, err := reader.Read(); err != nil {
|
||||
return err
|
||||
} else {
|
||||
return addToContext(ctx, value, fields...)
|
||||
}
|
||||
}
|
||||
|
||||
func (ctx *context) AddContextEntry(name string, dataRaw []byte) error {
|
||||
|
|
Loading…
Reference in a new issue