in pkg/cloud/filter/filter.go [233:279]
func (fp *filterPredicate) match(o interface{}) bool {
v, err := extractValue(fp.fieldName, o)
klog.V(6).Infof("extractValue(%q, %#v) = %v, %v", fp.fieldName, o, v, err)
if err != nil {
return false
}
var match bool
switch x := v.(type) {
case string:
if fp.s == nil {
return false
}
re, err := regexp.Compile(*fp.s)
if err != nil {
klog.Errorf("Match regexp %q is invalid: %v", *fp.s, err)
return false
}
match = x == *fp.s
if fp.op < regexpNotEquals {
match = re.Match([]byte(x))
}
case int:
if fp.i == nil {
return false
}
match = x == *fp.i
case bool:
if fp.b == nil {
return false
}
match = x == *fp.b
}
switch fp.op {
case regexpEquals:
return match
case regexpNotEquals:
return !match
case equals:
return match
case notEquals:
return !match
}
return false
}