MCPcopy
hub / github.com/1Panel-dev/KubePi / MatchField

Method MatchField

pkg/storm/matcher.go:37–58  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

35}
36
37func (a *arrayValueLike) MatchField(v interface{}) (bool, error) {
38 refV := reflect.ValueOf(v)
39 if refV.Kind() != reflect.Slice {
40 return false, nil
41 }
42 vs := strings.Split(a.val, ",")
43 for i := range vs {
44 var flag = false
45 for j := 0; j < refV.Len(); j++ {
46 v, ok := refV.Index(j).Interface().(string)
47 if ok {
48 if v == vs[i] {
49 flag = true
50 }
51 }
52 }
53 if !flag {
54 return false, nil
55 }
56 }
57 return true, nil
58}
59
60func ArrayValueLike(fieldName, val string) q.Matcher {
61 return q.NewFieldMatcher(fieldName, &arrayValueLike{val: val})

Callers

nothing calls this directly

Calls 1

LenMethod · 0.80

Tested by

no test coverage detected