1
0
Fork 0
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:
Marcus Vaal 2023-08-08 02:03:59 -05:00 committed by GitHub
parent 0b5f9a0f25
commit bf21fbf673
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {