1
2
3
4 package v2alpha
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "sort"
15 "strings"
16 "time"
17 "unicode/utf8"
18
19 "google.golang.org/protobuf/types/known/anypb"
20 )
21
22
23 var (
24 _ = bytes.MinRead
25 _ = errors.New("")
26 _ = fmt.Print
27 _ = utf8.UTFMax
28 _ = (*regexp.Regexp)(nil)
29 _ = (*strings.Reader)(nil)
30 _ = net.IPv4len
31 _ = time.Duration(0)
32 _ = (*url.URL)(nil)
33 _ = (*mail.Address)(nil)
34 _ = anypb.Any{}
35 _ = sort.Sort
36 )
37
38
39
40
41 func (m *OutlierDetectionEvent) Validate() error {
42 return m.validate(false)
43 }
44
45
46
47
48
49 func (m *OutlierDetectionEvent) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *OutlierDetectionEvent) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if _, ok := OutlierEjectionType_name[int32(m.GetType())]; !ok {
61 err := OutlierDetectionEventValidationError{
62 field: "Type",
63 reason: "value must be one of the defined enum values",
64 }
65 if !all {
66 return err
67 }
68 errors = append(errors, err)
69 }
70
71 if all {
72 switch v := interface{}(m.GetTimestamp()).(type) {
73 case interface{ ValidateAll() error }:
74 if err := v.ValidateAll(); err != nil {
75 errors = append(errors, OutlierDetectionEventValidationError{
76 field: "Timestamp",
77 reason: "embedded message failed validation",
78 cause: err,
79 })
80 }
81 case interface{ Validate() error }:
82 if err := v.Validate(); err != nil {
83 errors = append(errors, OutlierDetectionEventValidationError{
84 field: "Timestamp",
85 reason: "embedded message failed validation",
86 cause: err,
87 })
88 }
89 }
90 } else if v, ok := interface{}(m.GetTimestamp()).(interface{ Validate() error }); ok {
91 if err := v.Validate(); err != nil {
92 return OutlierDetectionEventValidationError{
93 field: "Timestamp",
94 reason: "embedded message failed validation",
95 cause: err,
96 }
97 }
98 }
99
100 if all {
101 switch v := interface{}(m.GetSecsSinceLastAction()).(type) {
102 case interface{ ValidateAll() error }:
103 if err := v.ValidateAll(); err != nil {
104 errors = append(errors, OutlierDetectionEventValidationError{
105 field: "SecsSinceLastAction",
106 reason: "embedded message failed validation",
107 cause: err,
108 })
109 }
110 case interface{ Validate() error }:
111 if err := v.Validate(); err != nil {
112 errors = append(errors, OutlierDetectionEventValidationError{
113 field: "SecsSinceLastAction",
114 reason: "embedded message failed validation",
115 cause: err,
116 })
117 }
118 }
119 } else if v, ok := interface{}(m.GetSecsSinceLastAction()).(interface{ Validate() error }); ok {
120 if err := v.Validate(); err != nil {
121 return OutlierDetectionEventValidationError{
122 field: "SecsSinceLastAction",
123 reason: "embedded message failed validation",
124 cause: err,
125 }
126 }
127 }
128
129 if len(m.GetClusterName()) < 1 {
130 err := OutlierDetectionEventValidationError{
131 field: "ClusterName",
132 reason: "value length must be at least 1 bytes",
133 }
134 if !all {
135 return err
136 }
137 errors = append(errors, err)
138 }
139
140 if len(m.GetUpstreamUrl()) < 1 {
141 err := OutlierDetectionEventValidationError{
142 field: "UpstreamUrl",
143 reason: "value length must be at least 1 bytes",
144 }
145 if !all {
146 return err
147 }
148 errors = append(errors, err)
149 }
150
151 if _, ok := Action_name[int32(m.GetAction())]; !ok {
152 err := OutlierDetectionEventValidationError{
153 field: "Action",
154 reason: "value must be one of the defined enum values",
155 }
156 if !all {
157 return err
158 }
159 errors = append(errors, err)
160 }
161
162
163
164
165
166 oneofEventPresent := false
167 switch v := m.Event.(type) {
168 case *OutlierDetectionEvent_EjectSuccessRateEvent:
169 if v == nil {
170 err := OutlierDetectionEventValidationError{
171 field: "Event",
172 reason: "oneof value cannot be a typed-nil",
173 }
174 if !all {
175 return err
176 }
177 errors = append(errors, err)
178 }
179 oneofEventPresent = true
180
181 if all {
182 switch v := interface{}(m.GetEjectSuccessRateEvent()).(type) {
183 case interface{ ValidateAll() error }:
184 if err := v.ValidateAll(); err != nil {
185 errors = append(errors, OutlierDetectionEventValidationError{
186 field: "EjectSuccessRateEvent",
187 reason: "embedded message failed validation",
188 cause: err,
189 })
190 }
191 case interface{ Validate() error }:
192 if err := v.Validate(); err != nil {
193 errors = append(errors, OutlierDetectionEventValidationError{
194 field: "EjectSuccessRateEvent",
195 reason: "embedded message failed validation",
196 cause: err,
197 })
198 }
199 }
200 } else if v, ok := interface{}(m.GetEjectSuccessRateEvent()).(interface{ Validate() error }); ok {
201 if err := v.Validate(); err != nil {
202 return OutlierDetectionEventValidationError{
203 field: "EjectSuccessRateEvent",
204 reason: "embedded message failed validation",
205 cause: err,
206 }
207 }
208 }
209
210 case *OutlierDetectionEvent_EjectConsecutiveEvent:
211 if v == nil {
212 err := OutlierDetectionEventValidationError{
213 field: "Event",
214 reason: "oneof value cannot be a typed-nil",
215 }
216 if !all {
217 return err
218 }
219 errors = append(errors, err)
220 }
221 oneofEventPresent = true
222
223 if all {
224 switch v := interface{}(m.GetEjectConsecutiveEvent()).(type) {
225 case interface{ ValidateAll() error }:
226 if err := v.ValidateAll(); err != nil {
227 errors = append(errors, OutlierDetectionEventValidationError{
228 field: "EjectConsecutiveEvent",
229 reason: "embedded message failed validation",
230 cause: err,
231 })
232 }
233 case interface{ Validate() error }:
234 if err := v.Validate(); err != nil {
235 errors = append(errors, OutlierDetectionEventValidationError{
236 field: "EjectConsecutiveEvent",
237 reason: "embedded message failed validation",
238 cause: err,
239 })
240 }
241 }
242 } else if v, ok := interface{}(m.GetEjectConsecutiveEvent()).(interface{ Validate() error }); ok {
243 if err := v.Validate(); err != nil {
244 return OutlierDetectionEventValidationError{
245 field: "EjectConsecutiveEvent",
246 reason: "embedded message failed validation",
247 cause: err,
248 }
249 }
250 }
251
252 case *OutlierDetectionEvent_EjectFailurePercentageEvent:
253 if v == nil {
254 err := OutlierDetectionEventValidationError{
255 field: "Event",
256 reason: "oneof value cannot be a typed-nil",
257 }
258 if !all {
259 return err
260 }
261 errors = append(errors, err)
262 }
263 oneofEventPresent = true
264
265 if all {
266 switch v := interface{}(m.GetEjectFailurePercentageEvent()).(type) {
267 case interface{ ValidateAll() error }:
268 if err := v.ValidateAll(); err != nil {
269 errors = append(errors, OutlierDetectionEventValidationError{
270 field: "EjectFailurePercentageEvent",
271 reason: "embedded message failed validation",
272 cause: err,
273 })
274 }
275 case interface{ Validate() error }:
276 if err := v.Validate(); err != nil {
277 errors = append(errors, OutlierDetectionEventValidationError{
278 field: "EjectFailurePercentageEvent",
279 reason: "embedded message failed validation",
280 cause: err,
281 })
282 }
283 }
284 } else if v, ok := interface{}(m.GetEjectFailurePercentageEvent()).(interface{ Validate() error }); ok {
285 if err := v.Validate(); err != nil {
286 return OutlierDetectionEventValidationError{
287 field: "EjectFailurePercentageEvent",
288 reason: "embedded message failed validation",
289 cause: err,
290 }
291 }
292 }
293
294 default:
295 _ = v
296 }
297 if !oneofEventPresent {
298 err := OutlierDetectionEventValidationError{
299 field: "Event",
300 reason: "value is required",
301 }
302 if !all {
303 return err
304 }
305 errors = append(errors, err)
306 }
307
308 if len(errors) > 0 {
309 return OutlierDetectionEventMultiError(errors)
310 }
311
312 return nil
313 }
314
315
316
317
318 type OutlierDetectionEventMultiError []error
319
320
321 func (m OutlierDetectionEventMultiError) Error() string {
322 var msgs []string
323 for _, err := range m {
324 msgs = append(msgs, err.Error())
325 }
326 return strings.Join(msgs, "; ")
327 }
328
329
330 func (m OutlierDetectionEventMultiError) AllErrors() []error { return m }
331
332
333
334 type OutlierDetectionEventValidationError struct {
335 field string
336 reason string
337 cause error
338 key bool
339 }
340
341
342 func (e OutlierDetectionEventValidationError) Field() string { return e.field }
343
344
345 func (e OutlierDetectionEventValidationError) Reason() string { return e.reason }
346
347
348 func (e OutlierDetectionEventValidationError) Cause() error { return e.cause }
349
350
351 func (e OutlierDetectionEventValidationError) Key() bool { return e.key }
352
353
354 func (e OutlierDetectionEventValidationError) ErrorName() string {
355 return "OutlierDetectionEventValidationError"
356 }
357
358
359 func (e OutlierDetectionEventValidationError) Error() string {
360 cause := ""
361 if e.cause != nil {
362 cause = fmt.Sprintf(" | caused by: %v", e.cause)
363 }
364
365 key := ""
366 if e.key {
367 key = "key for "
368 }
369
370 return fmt.Sprintf(
371 "invalid %sOutlierDetectionEvent.%s: %s%s",
372 key,
373 e.field,
374 e.reason,
375 cause)
376 }
377
378 var _ error = OutlierDetectionEventValidationError{}
379
380 var _ interface {
381 Field() string
382 Reason() string
383 Key() bool
384 Cause() error
385 ErrorName() string
386 } = OutlierDetectionEventValidationError{}
387
388
389
390
391 func (m *OutlierEjectSuccessRate) Validate() error {
392 return m.validate(false)
393 }
394
395
396
397
398
399 func (m *OutlierEjectSuccessRate) ValidateAll() error {
400 return m.validate(true)
401 }
402
403 func (m *OutlierEjectSuccessRate) validate(all bool) error {
404 if m == nil {
405 return nil
406 }
407
408 var errors []error
409
410 if m.GetHostSuccessRate() > 100 {
411 err := OutlierEjectSuccessRateValidationError{
412 field: "HostSuccessRate",
413 reason: "value must be less than or equal to 100",
414 }
415 if !all {
416 return err
417 }
418 errors = append(errors, err)
419 }
420
421 if m.GetClusterAverageSuccessRate() > 100 {
422 err := OutlierEjectSuccessRateValidationError{
423 field: "ClusterAverageSuccessRate",
424 reason: "value must be less than or equal to 100",
425 }
426 if !all {
427 return err
428 }
429 errors = append(errors, err)
430 }
431
432 if m.GetClusterSuccessRateEjectionThreshold() > 100 {
433 err := OutlierEjectSuccessRateValidationError{
434 field: "ClusterSuccessRateEjectionThreshold",
435 reason: "value must be less than or equal to 100",
436 }
437 if !all {
438 return err
439 }
440 errors = append(errors, err)
441 }
442
443 if len(errors) > 0 {
444 return OutlierEjectSuccessRateMultiError(errors)
445 }
446
447 return nil
448 }
449
450
451
452
453 type OutlierEjectSuccessRateMultiError []error
454
455
456 func (m OutlierEjectSuccessRateMultiError) Error() string {
457 var msgs []string
458 for _, err := range m {
459 msgs = append(msgs, err.Error())
460 }
461 return strings.Join(msgs, "; ")
462 }
463
464
465 func (m OutlierEjectSuccessRateMultiError) AllErrors() []error { return m }
466
467
468
469 type OutlierEjectSuccessRateValidationError struct {
470 field string
471 reason string
472 cause error
473 key bool
474 }
475
476
477 func (e OutlierEjectSuccessRateValidationError) Field() string { return e.field }
478
479
480 func (e OutlierEjectSuccessRateValidationError) Reason() string { return e.reason }
481
482
483 func (e OutlierEjectSuccessRateValidationError) Cause() error { return e.cause }
484
485
486 func (e OutlierEjectSuccessRateValidationError) Key() bool { return e.key }
487
488
489 func (e OutlierEjectSuccessRateValidationError) ErrorName() string {
490 return "OutlierEjectSuccessRateValidationError"
491 }
492
493
494 func (e OutlierEjectSuccessRateValidationError) Error() string {
495 cause := ""
496 if e.cause != nil {
497 cause = fmt.Sprintf(" | caused by: %v", e.cause)
498 }
499
500 key := ""
501 if e.key {
502 key = "key for "
503 }
504
505 return fmt.Sprintf(
506 "invalid %sOutlierEjectSuccessRate.%s: %s%s",
507 key,
508 e.field,
509 e.reason,
510 cause)
511 }
512
513 var _ error = OutlierEjectSuccessRateValidationError{}
514
515 var _ interface {
516 Field() string
517 Reason() string
518 Key() bool
519 Cause() error
520 ErrorName() string
521 } = OutlierEjectSuccessRateValidationError{}
522
523
524
525
526 func (m *OutlierEjectConsecutive) Validate() error {
527 return m.validate(false)
528 }
529
530
531
532
533
534 func (m *OutlierEjectConsecutive) ValidateAll() error {
535 return m.validate(true)
536 }
537
538 func (m *OutlierEjectConsecutive) validate(all bool) error {
539 if m == nil {
540 return nil
541 }
542
543 var errors []error
544
545 if len(errors) > 0 {
546 return OutlierEjectConsecutiveMultiError(errors)
547 }
548
549 return nil
550 }
551
552
553
554
555 type OutlierEjectConsecutiveMultiError []error
556
557
558 func (m OutlierEjectConsecutiveMultiError) Error() string {
559 var msgs []string
560 for _, err := range m {
561 msgs = append(msgs, err.Error())
562 }
563 return strings.Join(msgs, "; ")
564 }
565
566
567 func (m OutlierEjectConsecutiveMultiError) AllErrors() []error { return m }
568
569
570
571 type OutlierEjectConsecutiveValidationError struct {
572 field string
573 reason string
574 cause error
575 key bool
576 }
577
578
579 func (e OutlierEjectConsecutiveValidationError) Field() string { return e.field }
580
581
582 func (e OutlierEjectConsecutiveValidationError) Reason() string { return e.reason }
583
584
585 func (e OutlierEjectConsecutiveValidationError) Cause() error { return e.cause }
586
587
588 func (e OutlierEjectConsecutiveValidationError) Key() bool { return e.key }
589
590
591 func (e OutlierEjectConsecutiveValidationError) ErrorName() string {
592 return "OutlierEjectConsecutiveValidationError"
593 }
594
595
596 func (e OutlierEjectConsecutiveValidationError) Error() string {
597 cause := ""
598 if e.cause != nil {
599 cause = fmt.Sprintf(" | caused by: %v", e.cause)
600 }
601
602 key := ""
603 if e.key {
604 key = "key for "
605 }
606
607 return fmt.Sprintf(
608 "invalid %sOutlierEjectConsecutive.%s: %s%s",
609 key,
610 e.field,
611 e.reason,
612 cause)
613 }
614
615 var _ error = OutlierEjectConsecutiveValidationError{}
616
617 var _ interface {
618 Field() string
619 Reason() string
620 Key() bool
621 Cause() error
622 ErrorName() string
623 } = OutlierEjectConsecutiveValidationError{}
624
625
626
627
628 func (m *OutlierEjectFailurePercentage) Validate() error {
629 return m.validate(false)
630 }
631
632
633
634
635
636 func (m *OutlierEjectFailurePercentage) ValidateAll() error {
637 return m.validate(true)
638 }
639
640 func (m *OutlierEjectFailurePercentage) validate(all bool) error {
641 if m == nil {
642 return nil
643 }
644
645 var errors []error
646
647 if m.GetHostSuccessRate() > 100 {
648 err := OutlierEjectFailurePercentageValidationError{
649 field: "HostSuccessRate",
650 reason: "value must be less than or equal to 100",
651 }
652 if !all {
653 return err
654 }
655 errors = append(errors, err)
656 }
657
658 if len(errors) > 0 {
659 return OutlierEjectFailurePercentageMultiError(errors)
660 }
661
662 return nil
663 }
664
665
666
667
668 type OutlierEjectFailurePercentageMultiError []error
669
670
671 func (m OutlierEjectFailurePercentageMultiError) Error() string {
672 var msgs []string
673 for _, err := range m {
674 msgs = append(msgs, err.Error())
675 }
676 return strings.Join(msgs, "; ")
677 }
678
679
680 func (m OutlierEjectFailurePercentageMultiError) AllErrors() []error { return m }
681
682
683
684
685 type OutlierEjectFailurePercentageValidationError struct {
686 field string
687 reason string
688 cause error
689 key bool
690 }
691
692
693 func (e OutlierEjectFailurePercentageValidationError) Field() string { return e.field }
694
695
696 func (e OutlierEjectFailurePercentageValidationError) Reason() string { return e.reason }
697
698
699 func (e OutlierEjectFailurePercentageValidationError) Cause() error { return e.cause }
700
701
702 func (e OutlierEjectFailurePercentageValidationError) Key() bool { return e.key }
703
704
705 func (e OutlierEjectFailurePercentageValidationError) ErrorName() string {
706 return "OutlierEjectFailurePercentageValidationError"
707 }
708
709
710 func (e OutlierEjectFailurePercentageValidationError) Error() string {
711 cause := ""
712 if e.cause != nil {
713 cause = fmt.Sprintf(" | caused by: %v", e.cause)
714 }
715
716 key := ""
717 if e.key {
718 key = "key for "
719 }
720
721 return fmt.Sprintf(
722 "invalid %sOutlierEjectFailurePercentage.%s: %s%s",
723 key,
724 e.field,
725 e.reason,
726 cause)
727 }
728
729 var _ error = OutlierEjectFailurePercentageValidationError{}
730
731 var _ interface {
732 Field() string
733 Reason() string
734 Key() bool
735 Cause() error
736 ErrorName() string
737 } = OutlierEjectFailurePercentageValidationError{}
738
View as plain text