-
Notifications
You must be signed in to change notification settings - Fork 1
/
attestation_domain.pb.filter.go
1219 lines (1054 loc) · 35.1 KB
/
attestation_domain.pb.filter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by protoc-gen-goten-resource
// Resource: AttestationDomain
// DO NOT EDIT!!!
package attestation_domain
import (
"fmt"
"math"
"reflect"
"strings"
"github.com/google/cel-go/common/types"
"github.com/google/cel-go/common/types/ref"
"github.com/google/cel-go/common/types/traits"
firestorepb "google.golang.org/genproto/googleapis/firestore/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
gotenresource "github.com/cloudwan/goten-sdk/runtime/resource"
filterParser "github.com/cloudwan/goten-sdk/runtime/resource/filter"
utils "github.com/cloudwan/goten-sdk/runtime/utils"
)
// proto imports
import (
ntt_meta "github.com/cloudwan/edgelq-sdk/common/types/meta"
iam_common "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/common"
project "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/project"
)
var (
_ = new(fmt.Stringer)
_ = strings.Builder{}
_ = math.IsNaN
_ = types.Bool(true)
_ = new(ref.Type)
_ = new(traits.Receiver)
_ = firestorepb.Value{}
_ = new(proto.Message)
_ = new(gotenobject.FieldPath)
_ = gotenresource.WildcardId
)
// make sure we're using proto imports
var (
_ = &ntt_meta.Meta{}
_ = &iam_common.PCR{}
_ = &project.Project{}
)
type FilterCondition interface {
gotenresource.FilterCondition
_IsFilterCondition()
_IsAttestationDomainFilterBuilderOrCondition()
And(...FilterCondition) FilterCondition
Evaluate(res *AttestationDomain) bool
// Whether this condition is at least as specific as other.
// When true, any AttestationDomain that passes this condition will also pass other condition.
Satisfies(other FilterCondition) bool
// Checks whether condition specifies given field path
// Useful for blacklisting protected paths in iam policy conditions
SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool
}
func AndFilterConditions(conds ...FilterCondition) FilterCondition {
result := &FilterConditionComposite{
Operator: filterParser.AND,
}
for _, condi := range conds {
switch cond := condi.(type) {
case *FilterConditionComposite:
if cond.Operator == filterParser.AND {
result.Conditions = append(result.Conditions, cond.Conditions...)
continue
}
default:
}
result.Conditions = append(result.Conditions, condi)
}
return result
}
type FilterConditionComposite struct {
Operator filterParser.CompositeOperator
Conditions []FilterCondition
}
func (cond *FilterConditionComposite) String() string {
substrs := make([]string, 0, len(cond.Conditions))
for _, subcond := range cond.Conditions {
substrs = append(substrs, subcond.String())
}
sep := fmt.Sprintf(" %s ", cond.Operator)
return "(" + strings.Join(substrs, sep) + ")"
}
func (cond *FilterConditionComposite) _IsFilterCondition() {}
func (cond *FilterConditionComposite) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionComposite) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionComposite) Evaluate(res *AttestationDomain) bool {
switch cond.Operator {
case filterParser.OR:
for _, subCond := range cond.Conditions {
if subCond.Evaluate(res) {
return true
}
}
return false
case filterParser.AND:
for _, subCond := range cond.Conditions {
if !subCond.Evaluate(res) {
return false
}
}
return true
default:
panic(fmt.Sprintf("Unsupported composite condition operator: %s", cond.Operator))
}
}
func (cond *FilterConditionComposite) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionComposite) flattenConditions() (results []FilterCondition) {
for _, subcnd := range cond.Conditions {
switch tsubcnd := subcnd.(type) {
case *FilterConditionComposite:
if tsubcnd.Operator == cond.Operator {
results = append(results, tsubcnd.flattenConditions()...)
} else {
results = append(results, subcnd) // take it as it is
}
default:
results = append(results, subcnd)
}
}
return
}
func (cond *FilterConditionComposite) Satisfies(other FilterCondition) bool {
flattened := cond.flattenConditions()
switch cond.Operator {
case filterParser.AND:
switch tother := other.(type) {
case *FilterConditionComposite:
switch tother.Operator {
case filterParser.AND:
otherFlattened := tother.flattenConditions()
OtherSubcnds:
for _, otherSubcnd := range otherFlattened {
for _, subcnd := range flattened {
if subcnd.Satisfies(otherSubcnd) {
continue OtherSubcnds
}
}
return false
}
return true
case filterParser.OR:
otherFlattened := tother.flattenConditions()
for _, otherSubcnd := range otherFlattened {
if cond.Satisfies(otherSubcnd) {
return true
}
}
return false
default:
return false
}
default:
for _, subcnd := range flattened {
if subcnd.Satisfies(other) {
return true
}
}
return false
}
default:
panic(fmt.Errorf("unsupported condition type %s", cond.Operator))
}
return false
}
func (cond *FilterConditionComposite) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionComposite) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
for _, subcnd := range cond.Conditions {
if subcnd.SpecifiesFieldPath(fp) {
return true
}
}
return false
}
func (cond *FilterConditionComposite) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionComposite) GetOperator() filterParser.CompositeOperator {
return cond.Operator
}
func (cond *FilterConditionComposite) GetSubConditions() []gotenresource.FilterCondition {
subConds := make([]gotenresource.FilterCondition, len(cond.Conditions))
for idx, subCond := range cond.Conditions {
subConds[idx] = subCond
}
return subConds
}
func (cond *FilterConditionComposite) ConditionComposite() {}
type FilterConditionNot struct {
FilterCondition
}
func (cond *FilterConditionNot) String() string {
return "NOT " + cond.FilterCondition.String()
}
func (cond *FilterConditionNot) _IsFilterCondition() {}
func (cond *FilterConditionNot) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionNot) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionNot) Evaluate(res *AttestationDomain) bool {
return !cond.FilterCondition.Evaluate(res)
}
func (cond *FilterConditionNot) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionNot) Satisfies(other FilterCondition) bool {
switch tother := other.(type) {
case *FilterConditionNot:
return cond.FilterCondition.Satisfies(tother.FilterCondition)
default:
return !cond.FilterCondition.Satisfies(other)
}
}
func (cond *FilterConditionNot) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionNot) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
return cond.FilterCondition.SpecifiesFieldPath(fp)
}
func (cond *FilterConditionNot) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionNot) GetSubCondition() gotenresource.FilterCondition {
return cond.FilterCondition
}
func (cond *FilterConditionNot) ConditionNot() {}
type FilterConditionIsNull struct {
Not bool
FieldPath AttestationDomain_FieldPath
}
func (cond *FilterConditionIsNull) String() string {
if cond.Not {
return cond.FieldPath.String() + " IS NOT NULL"
} else {
return cond.FieldPath.String() + " IS NULL"
}
}
func (cond *FilterConditionIsNull) _IsFilterCondition() {}
func (cond *FilterConditionIsNull) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionIsNull) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionIsNull) Evaluate(res *AttestationDomain) bool {
if v, ok := cond.FieldPath.GetSingleRaw(res); !ok {
return !cond.Not
} else {
return cond.Not != utils.IsNil(v)
}
}
func (cond *FilterConditionIsNull) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionIsNull) asCompare() FilterCondition {
res := &FilterConditionCompare{
Operator: filterParser.Eq,
AttestationDomain_FieldPathValue: cond.FieldPath.WithIValue(nil),
}
if cond.Not {
res.Operator = filterParser.Neq
}
return res
}
func (cond *FilterConditionIsNull) Satisfies(other FilterCondition) bool {
switch tother := other.(type) {
case *FilterConditionIsNull:
return cond.FieldPath.String() == tother.FieldPath.String() && cond.Not == tother.Not
case *FilterConditionCompare:
return cond.asCompare().Satisfies(tother)
default:
return false
}
}
func (cond *FilterConditionIsNull) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionIsNull) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
return cond.FieldPath.String() == fp.String()
}
func (cond *FilterConditionIsNull) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionIsNull) NotNull() bool {
return cond.Not
}
func (cond *FilterConditionIsNull) GetRawFieldPath() gotenobject.FieldPath {
return cond.FieldPath
}
func (cond *FilterConditionIsNull) ConditionIsNull() {}
type FilterConditionIsNaN struct {
Not bool
FieldPath AttestationDomain_FieldPath
}
func (cond *FilterConditionIsNaN) String() string {
if cond.Not {
return cond.FieldPath.String() + " IS NOT NaN"
} else {
return cond.FieldPath.String() + " IS NaN"
}
}
func (cond *FilterConditionIsNaN) _IsFilterCondition() {}
func (cond *FilterConditionIsNaN) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionIsNaN) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionIsNaN) Evaluate(res *AttestationDomain) bool {
v, ok := cond.FieldPath.GetSingleRaw(res)
if !ok {
return false
}
fv, ok := v.(float64)
if !ok {
return false
}
return math.IsNaN(fv)
}
func (cond *FilterConditionIsNaN) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionIsNaN) Satisfies(other FilterCondition) bool {
switch tother := other.(type) {
case *FilterConditionIsNaN:
return cond.FieldPath.String() == tother.FieldPath.String() && cond.Not == tother.Not
default:
return false
}
}
func (cond *FilterConditionIsNaN) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionIsNaN) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
return cond.FieldPath.String() == fp.String()
}
func (cond *FilterConditionIsNaN) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionIsNaN) GetRawFieldPath() gotenobject.FieldPath {
return cond.FieldPath
}
func (cond *FilterConditionIsNaN) ConditionIsNaN() {}
type FilterConditionCompare struct {
Operator filterParser.CompareOperator
AttestationDomain_FieldPathValue
}
func (cond *FilterConditionCompare) String() string {
jsonValue, err := utils.JsonMarshal(cond.AttestationDomain_FieldPathValue.GetRawValue())
if err != nil {
panic(err)
}
return fmt.Sprintf("%s %s %s", cond.AttestationDomain_FieldPathValue, cond.Operator, jsonValue)
}
func (cond *FilterConditionCompare) _IsFilterCondition() {}
func (cond *FilterConditionCompare) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionCompare) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionCompare) Evaluate(res *AttestationDomain) bool {
// Special evaluation for name or reference - may include wildcards
if nameOrRefFPV, ok := cond.AttestationDomain_FieldPathValue.GetRawValue().(gotenresource.Name); ok {
if otherObj, ok := cond.AttestationDomain_FieldPathValue.GetSingleRaw(res); ok {
match := nameOrRefFPV.Matches(otherObj)
switch cond.Operator {
case filterParser.Eq:
return match
case filterParser.Neq:
return !match
default:
return false
}
}
}
// special evaluation for objects
if objValue, ok := cond.AttestationDomain_FieldPathValue.GetRawValue().(proto.Message); ok {
if otherObj, ok := cond.AttestationDomain_FieldPathValue.GetSingleRaw(res); ok {
switch cond.Operator {
case filterParser.Eq:
return proto.Equal(objValue, otherObj.(proto.Message))
case filterParser.Neq:
return !proto.Equal(objValue, otherObj.(proto.Message))
default:
return false
}
}
}
cmpResult, comparable := cond.AttestationDomain_FieldPathValue.CompareWith(res)
if !comparable {
return false
}
return cond.Operator.MatchCompareResult(cmpResult)
}
func (cond *FilterConditionCompare) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionCompare) Satisfies(other FilterCondition) bool {
switch tother := other.(type) {
case *FilterConditionCompare:
if cond.AttestationDomain_FieldPathValue.String() != tother.AttestationDomain_FieldPathValue.String() {
return false
}
othertmp := new(AttestationDomain)
tother.SetTo(&othertmp)
if cmp, comparable := cond.CompareWith(othertmp); !comparable {
return false
} else {
return filterParser.CompareSatisfies(tother.Operator, cond.Operator, cmp)
}
case *FilterConditionIn:
if cond.Operator != filterParser.Eq {
return false
}
if cond.AttestationDomain_FieldPathValue.String() != tother.AttestationDomain_FieldPathArrayOfValues.String() {
return false
}
for _, inv := range tother.GetRawValues() {
othertmp := new(AttestationDomain)
tother.WithIValue(inv).SetTo(&othertmp)
if cmp, comparable := cond.AttestationDomain_FieldPathValue.CompareWith(othertmp); comparable && cmp == 0 {
return true
}
}
return false
case *FilterConditionComposite:
if tother.Operator == filterParser.AND {
for _, othersubcnd := range tother.flattenConditions() {
if !cond.Satisfies(othersubcnd) {
return false
}
}
return true
} else { // OR
for _, othersubcnd := range tother.flattenConditions() {
if cond.Satisfies(othersubcnd) {
return true
}
}
return false
}
default:
return false
}
}
func (cond *FilterConditionCompare) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionCompare) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
return cond.AttestationDomain_FieldPathValue.String() == fp.String()
}
func (cond *FilterConditionCompare) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionCompare) GetOperator() filterParser.CompareOperator {
return cond.Operator
}
func (cond *FilterConditionCompare) GetRawFieldPath() gotenobject.FieldPath {
return cond.AttestationDomain_FieldPathValue
}
func (cond *FilterConditionCompare) GetRawFieldPathValue() gotenobject.FieldPathValue {
return cond.AttestationDomain_FieldPathValue
}
func (cond *FilterConditionCompare) ConditionCompare() {}
type FilterConditionContains struct {
Type gotenresource.ConditionContainsType
FieldPath AttestationDomain_FieldPath
Value AttestationDomain_FieldPathArrayItemValue
Values []AttestationDomain_FieldPathArrayItemValue
}
func (cond *FilterConditionContains) String() string {
switch cond.ConditionContainsType() {
case gotenresource.ConditionContainsTypeValue:
jsonValue, err := utils.JsonMarshal(cond.Value.GetRawItemValue())
if err != nil {
panic(err)
}
return fmt.Sprintf("%s CONTAINS %s", cond.FieldPath, string(jsonValue))
case gotenresource.ConditionContainsTypeAny, gotenresource.ConditionContainsTypeAll:
jsonValues := make([]string, len(cond.Values))
for i, v := range cond.Values {
if jsonValue, err := utils.JsonMarshal(v.GetRawItemValue()); err != nil {
panic(err)
} else {
jsonValues[i] = string(jsonValue)
}
}
return fmt.Sprintf("%s CONTAINS %s %s", cond.FieldPath, cond.ConditionContainsType(), fmt.Sprintf("(%s)", strings.Join(jsonValues, ", ")))
default:
panic(gotenresource.NewUnknownConditionContainsType(cond.ConditionContainsType()))
}
}
func (cond *FilterConditionContains) ConditionContainsType() gotenresource.ConditionContainsType {
return cond.Type
}
func (cond *FilterConditionContains) _IsFilterCondition() {}
func (cond *FilterConditionContains) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionContains) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionContains) Evaluate(res *AttestationDomain) bool {
switch cond.ConditionContainsType() {
case gotenresource.ConditionContainsTypeValue:
return cond.Value.ContainsValue(res)
case gotenresource.ConditionContainsTypeAny:
for _, v := range cond.Values {
if v.ContainsValue(res) {
return true
}
}
return false
case gotenresource.ConditionContainsTypeAll:
for _, v := range cond.Values {
if !v.ContainsValue(res) {
return false
}
}
return true
default:
panic(gotenresource.NewUnknownConditionContainsType(cond.ConditionContainsType()))
}
}
func (cond *FilterConditionContains) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionContains) Satisfies(other FilterCondition) bool {
switch tother := other.(type) {
case *FilterConditionContains:
if cond.ConditionContainsType().IsValue() && tother.ConditionContainsType().IsValue() {
othertmp := new(AttestationDomain)
tother.Value.WithIValue(tother.GetRawFieldPathItemValue().GetRawItemValue()).SetTo(&othertmp)
return cond.Value.ContainsValue(othertmp)
}
return false
default:
return false
}
}
func (cond *FilterConditionContains) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionContains) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
return cond.FieldPath.String() == fp.String()
}
func (cond *FilterConditionContains) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionContains) GetFieldPath() AttestationDomain_FieldPath {
return cond.FieldPath
}
func (cond *FilterConditionContains) GetRawFieldPath() gotenobject.FieldPath {
return cond.FieldPath
}
func (cond *FilterConditionContains) GetRawFieldPathItemValue() gotenobject.FieldPathArrayItemValue {
switch cond.ConditionContainsType() {
case gotenresource.ConditionContainsTypeValue:
return cond.Value
default:
panic(fmt.Errorf("unable to get value for condition contains type %s", cond.ConditionContainsType()))
}
}
func (cond *FilterConditionContains) GetRawFieldPathItemValues() (res []gotenobject.FieldPathArrayItemValue) {
switch cond.ConditionContainsType() {
case gotenresource.ConditionContainsTypeAny, gotenresource.ConditionContainsTypeAll:
for _, fpaiv := range cond.Values {
res = append(res, fpaiv)
}
default:
panic(fmt.Errorf("unable to get values for condition contains type %s", cond.ConditionContainsType()))
}
return
}
func (cond *FilterConditionContains) ConditionContains() {}
type FilterConditionIn struct {
AttestationDomain_FieldPathArrayOfValues
}
func (cond *FilterConditionIn) String() string {
jsonValues, err := utils.JsonMarshal(cond.AttestationDomain_FieldPathArrayOfValues.GetRawValues())
if err != nil {
panic(err)
}
return fmt.Sprintf("%s IN %s", cond.AttestationDomain_FieldPathArrayOfValues, jsonValues)
}
func (cond *FilterConditionIn) _IsFilterCondition() {}
func (cond *FilterConditionIn) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionIn) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionIn) Evaluate(res *AttestationDomain) bool {
for _, inValue := range cond.AttestationDomain_FieldPathArrayOfValues.GetRawValues() {
if cmp, ok := cond.AttestationDomain_FieldPathArrayOfValues.WithIValue(inValue).CompareWith(res); ok && cmp == 0 {
return true
}
}
return false
}
func (cond *FilterConditionIn) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionIn) Satisfies(other FilterCondition) bool {
switch tother := other.(type) {
case *FilterConditionIn:
outer:
for _, cval := range cond.AttestationDomain_FieldPathArrayOfValues.GetRawValues() {
for _, otherval := range tother.AttestationDomain_FieldPathArrayOfValues.GetRawValues() {
othertmp := new(AttestationDomain)
tother.AttestationDomain_FieldPathArrayOfValues.WithIValue(otherval).SetTo(&othertmp)
if cmp, comparable := cond.AttestationDomain_FieldPathArrayOfValues.WithIValue(cval).CompareWith(othertmp); comparable && cmp == 0 {
continue outer
}
}
return false
}
return true
default:
for _, cval := range cond.AttestationDomain_FieldPathArrayOfValues.GetRawValues() {
subcnd := &FilterConditionCompare{
Operator: filterParser.Eq,
AttestationDomain_FieldPathValue: cond.AttestationDomain_FieldPathArrayOfValues.WithIValue(cval),
}
if !subcnd.Satisfies(tother) {
return false
}
}
return true
}
}
func (cond *FilterConditionIn) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionIn) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
return cond.AttestationDomain_FieldPathArrayOfValues.String() == fp.String()
}
func (cond *FilterConditionIn) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionIn) GetRawFieldPath() gotenobject.FieldPath {
return cond.AttestationDomain_FieldPathArrayOfValues
}
func (cond *FilterConditionIn) GetRawFieldPathArrayOfValues() gotenobject.FieldPathArrayOfValues {
return cond.AttestationDomain_FieldPathArrayOfValues
}
func (cond *FilterConditionIn) ConditionIn() {}
type FilterConditionNotIn struct {
AttestationDomain_FieldPathArrayOfValues
}
func (cond *FilterConditionNotIn) String() string {
jsonValues, err := utils.JsonMarshal(cond.AttestationDomain_FieldPathArrayOfValues.GetRawValues())
if err != nil {
panic(err)
}
return fmt.Sprintf("%s NOT IN %s", cond.AttestationDomain_FieldPathArrayOfValues, jsonValues)
}
func (cond *FilterConditionNotIn) _IsFilterCondition() {}
func (cond *FilterConditionNotIn) _IsAttestationDomainFilterBuilderOrCondition() {}
func (cond *FilterConditionNotIn) And(conds ...FilterCondition) FilterCondition {
return AndFilterConditions(append([]FilterCondition{cond}, conds...)...)
}
func (cond *FilterConditionNotIn) Evaluate(res *AttestationDomain) bool {
for _, inValue := range cond.AttestationDomain_FieldPathArrayOfValues.GetRawValues() {
if cmp, ok := cond.AttestationDomain_FieldPathArrayOfValues.WithIValue(inValue).CompareWith(res); ok && cmp == 0 {
return false
}
}
return true
}
func (cond *FilterConditionNotIn) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return cond.Evaluate(typedRes)
}
}
func (cond *FilterConditionNotIn) Satisfies(other FilterCondition) bool {
return false
}
func (cond *FilterConditionNotIn) SatisfiesRaw(other gotenresource.FilterCondition) bool {
if typedCond, ok := other.(FilterCondition); !ok {
return false
} else {
return cond.Satisfies(typedCond)
}
}
func (cond *FilterConditionNotIn) SpecifiesFieldPath(fp AttestationDomain_FieldPath) bool {
return cond.AttestationDomain_FieldPathArrayOfValues.String() == fp.String()
}
func (cond *FilterConditionNotIn) SpecifiesRawFieldPath(fp gotenobject.FieldPath) bool {
if typedFp, ok := fp.(AttestationDomain_FieldPath); !ok {
return false
} else {
return cond.SpecifiesFieldPath(typedFp)
}
}
func (cond *FilterConditionNotIn) GetRawFieldPath() gotenobject.FieldPath {
return cond.AttestationDomain_FieldPathArrayOfValues
}
func (cond *FilterConditionNotIn) GetRawFieldPathArrayOfValues() gotenobject.FieldPathArrayOfValues {
return cond.AttestationDomain_FieldPathArrayOfValues
}
func (cond *FilterConditionNotIn) ConditionNotIn() {}
type Filter struct {
FilterCondition
}
func (filter *Filter) _IsAttestationDomainFilterBuilderOrCondition() {}
// GetCondition is a getter of FilterCondition, which also handles nil pointer
func (filter *Filter) GetCondition() FilterCondition {
if filter == nil {
return AndFilterConditions()
} else {
return filter.FilterCondition
}
}
// Evaluate is a wrapper on FilterCondition, which also handles nil pointer
func (filter *Filter) Evaluate(res *AttestationDomain) bool {
return filter.GetCondition().Evaluate(res)
}
func (filter *Filter) EvaluateRaw(res gotenresource.Resource) bool {
if typedRes, ok := res.(*AttestationDomain); !ok {
return false
} else {
return filter.Evaluate(typedRes)
}
}
func (filter *Filter) GetRawCondition() gotenresource.FilterCondition {
if filter == nil {
return nil
}
return filter.GetCondition()
}
// FilterSlice is a helper for filtering arrays
func (filter *Filter) FilterSlice(in []*AttestationDomain) (out []*AttestationDomain) {
for _, res := range in {
if filter.Evaluate(res) {
out = append(out, res)
}
}
return
}
// implement methods required by protobuf-go library for string-struct conversion
func (filter *Filter) ProtoString() (string, error) {
if filter == nil || filter.FilterCondition == nil {
return "", nil
}
return filter.FilterCondition.String(), nil
}
func (filter *Filter) ParseProtoString(data string) error {
expression, err := filterParser.Parse([]byte(data))
if err != nil {
return status.Error(codes.InvalidArgument, err.Error())
}
condition, err := makeFilterConditionFromOr(expression.And)
if err != nil {
return err
}
filter.FilterCondition = condition
return nil
}
func (filter *Filter) String() string {
if filter == nil || filter.FilterCondition == nil {
return "<nil>"
}
return filter.FilterCondition.String()
}
func (filter *Filter) SetFromCliFlag(raw string) error {
return filter.ParseProtoString(raw)
}
// Google CEL integration Type