File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
staging/src/k8s.io/apiserver/pkg/cel/common Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -318,6 +318,16 @@ func TestToValue(t *testing.T) {
318
318
"s2" : struct2 ,
319
319
},
320
320
},
321
+ {
322
+ name : "compare: identical complex structs" ,
323
+ expression : "c1 == c2" ,
324
+ activation : map [string ]typedValue {"c1" : complex1 , "c2" : complex1Again },
325
+ },
326
+ {
327
+ name : "compare: different complex structs" ,
328
+ expression : "c1 != c2" ,
329
+ activation : map [string ]typedValue {"c1" : complex1 , "c2" : complex2 },
330
+ },
321
331
{
322
332
name : "compare: struct and pointer to identical struct" ,
323
333
expression : "s1 == s1_ptr" ,
Original file line number Diff line number Diff line change @@ -598,13 +598,17 @@ func (t *unstructuredMap) Equal(other ref.Val) ref.Val {
598
598
if t .Size () != oMap .Size () {
599
599
return types .False
600
600
}
601
+
601
602
for key , value := range t .value {
602
- if propSchema , ok := t .propSchema (key ); ok {
603
- ov , found := oMap .Find (types .String (key ))
604
- if ! found {
603
+ if _ , ok := t .propSchema (key ); ok {
604
+ v , found := t .Find (types .String (key ))
605
+ ov , oFound := oMap .Find (types .String (key ))
606
+ if found != oFound {
605
607
return types .False
606
608
}
607
- v := UnstructuredToVal (value , propSchema )
609
+ if ! found {
610
+ continue
611
+ }
608
612
vEq := v .Equal (ov )
609
613
if vEq != types .True {
610
614
return vEq // either false or error
You can’t perform that action at this time.
0 commit comments