File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,20 @@ const (
2929 LabelOpLTENumeric
3030)
3131
32+ func (l LabelOp ) isComparison () bool {
33+ //nolint:exhaustive
34+ switch l {
35+ case LabelOpLT :
36+ case LabelOpLTE :
37+ case LabelOpLTNumeric :
38+ case LabelOpLTENumeric :
39+ default :
40+ return false
41+ }
42+
43+ return true
44+ }
45+
3246// LabelTerm describes a filter on metadata labels.
3347type LabelTerm struct {
3448 Key string
Original file line number Diff line number Diff line change @@ -54,6 +54,10 @@ func (labels Labels) matches(term LabelTerm) *bool {
5454 value , ok := labels .Get (term .Key )
5555
5656 if ! ok {
57+ if term .Op .isComparison () {
58+ return nil
59+ }
60+
5761 return pointer .To (false )
5862 }
5963
Original file line number Diff line number Diff line change @@ -100,6 +100,13 @@ func TestLabels(t *testing.T) {
100100 Value : []string {"NaN" },
101101 Invert : true ,
102102 }))
103+
104+ assert .False (t , termTests .Matches (resource.LabelTerm {
105+ Key : "nm" ,
106+ Op : resource .LabelOpLTENumeric ,
107+ Value : []string {"NaN" },
108+ Invert : true ,
109+ }))
103110}
104111
105112func TestLabelsDo (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments