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

small fixes

This commit is contained in:
NoSkillGirl 2020-06-26 12:33:49 +05:30
parent 356d749103
commit 8bbc722e7b
2 changed files with 3 additions and 11 deletions

View file

@ -17,7 +17,7 @@ func NewInHandler(log logr.Logger, ctx context.EvalInterface, subHandler Variabl
}
}
//InHandler provides implementation to handle NotIn oerator
//InHandler provides implementation to handle In Operator
type InHandler struct {
ctx context.EvalInterface
subHandler VariableSubstitutionHandler
@ -27,20 +27,16 @@ type InHandler struct {
//Evaluate evaluates expression with In Operator
func (in InHandler) Evaluate(key, value interface{}) bool {
var err error
//TODO: decouple variables from evaluation
// substitute the variables
if key, err = in.subHandler(in.log, in.ctx, key); err != nil {
// Failed to resolve the variable
in.log.Error(err, "Failed to resolve variable", "variable", key)
return false
}
if value, err = in.subHandler(in.log, in.ctx, value); err != nil {
// Failed to resolve the variable
in.log.Error(err, "Failed to resolve variable", "variable", value)
return false
}
// key should be avaliable in value
switch typedKey := key.(type) {
case string:
return in.validateValuewithStringPattern(typedKey, value)

View file

@ -26,19 +26,16 @@ type NotInHandler struct {
//Evaluate evaluates expression with NotIn Operator
func (nin NotInHandler) Evaluate(key, value interface{}) bool {
var err error
//TODO: decouple variables from evaluation
// substitute the variables
if key, err = nin.subHandler(nin.log, nin.ctx, key); err != nil {
// Failed to resolve the variable
nin.log.Error(err, "Failed to resolve variable", "variable", key)
return false
}
if value, err = nin.subHandler(nin.log, nin.ctx, value); err != nil {
// Failed to resolve the variable
nin.log.Error(err, "Failed to resolve variable", "variable", value)
return false
}
// key and value need to be of same type
switch typedKey := key.(type) {
case string:
return nin.validateValuewithStringPattern(typedKey, value)
@ -57,10 +54,9 @@ func (nin NotInHandler) validateValuewithStringPattern(key string, value interfa
}
if !keyExists {
fmt.Println(".....return true......")
return true
}
fmt.Println(".....return false......")
return false
}