1
2
3
4 package discoveryv2
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 core "github.com/emissary-ingress/emissary/v3/pkg/api/envoy/api/v2/core"
22 )
23
24
25 var (
26 _ = bytes.MinRead
27 _ = errors.New("")
28 _ = fmt.Print
29 _ = utf8.UTFMax
30 _ = (*regexp.Regexp)(nil)
31 _ = (*strings.Reader)(nil)
32 _ = net.IPv4len
33 _ = time.Duration(0)
34 _ = (*url.URL)(nil)
35 _ = (*mail.Address)(nil)
36 _ = anypb.Any{}
37 _ = sort.Sort
38
39 _ = core.HealthStatus(0)
40 )
41
42
43
44
45 func (m *Capability) Validate() error {
46 return m.validate(false)
47 }
48
49
50
51
52
53 func (m *Capability) ValidateAll() error {
54 return m.validate(true)
55 }
56
57 func (m *Capability) validate(all bool) error {
58 if m == nil {
59 return nil
60 }
61
62 var errors []error
63
64 if len(errors) > 0 {
65 return CapabilityMultiError(errors)
66 }
67
68 return nil
69 }
70
71
72
73 type CapabilityMultiError []error
74
75
76 func (m CapabilityMultiError) Error() string {
77 var msgs []string
78 for _, err := range m {
79 msgs = append(msgs, err.Error())
80 }
81 return strings.Join(msgs, "; ")
82 }
83
84
85 func (m CapabilityMultiError) AllErrors() []error { return m }
86
87
88
89 type CapabilityValidationError struct {
90 field string
91 reason string
92 cause error
93 key bool
94 }
95
96
97 func (e CapabilityValidationError) Field() string { return e.field }
98
99
100 func (e CapabilityValidationError) Reason() string { return e.reason }
101
102
103 func (e CapabilityValidationError) Cause() error { return e.cause }
104
105
106 func (e CapabilityValidationError) Key() bool { return e.key }
107
108
109 func (e CapabilityValidationError) ErrorName() string { return "CapabilityValidationError" }
110
111
112 func (e CapabilityValidationError) Error() string {
113 cause := ""
114 if e.cause != nil {
115 cause = fmt.Sprintf(" | caused by: %v", e.cause)
116 }
117
118 key := ""
119 if e.key {
120 key = "key for "
121 }
122
123 return fmt.Sprintf(
124 "invalid %sCapability.%s: %s%s",
125 key,
126 e.field,
127 e.reason,
128 cause)
129 }
130
131 var _ error = CapabilityValidationError{}
132
133 var _ interface {
134 Field() string
135 Reason() string
136 Key() bool
137 Cause() error
138 ErrorName() string
139 } = CapabilityValidationError{}
140
141
142
143
144 func (m *HealthCheckRequest) Validate() error {
145 return m.validate(false)
146 }
147
148
149
150
151
152 func (m *HealthCheckRequest) ValidateAll() error {
153 return m.validate(true)
154 }
155
156 func (m *HealthCheckRequest) validate(all bool) error {
157 if m == nil {
158 return nil
159 }
160
161 var errors []error
162
163 if all {
164 switch v := interface{}(m.GetNode()).(type) {
165 case interface{ ValidateAll() error }:
166 if err := v.ValidateAll(); err != nil {
167 errors = append(errors, HealthCheckRequestValidationError{
168 field: "Node",
169 reason: "embedded message failed validation",
170 cause: err,
171 })
172 }
173 case interface{ Validate() error }:
174 if err := v.Validate(); err != nil {
175 errors = append(errors, HealthCheckRequestValidationError{
176 field: "Node",
177 reason: "embedded message failed validation",
178 cause: err,
179 })
180 }
181 }
182 } else if v, ok := interface{}(m.GetNode()).(interface{ Validate() error }); ok {
183 if err := v.Validate(); err != nil {
184 return HealthCheckRequestValidationError{
185 field: "Node",
186 reason: "embedded message failed validation",
187 cause: err,
188 }
189 }
190 }
191
192 if all {
193 switch v := interface{}(m.GetCapability()).(type) {
194 case interface{ ValidateAll() error }:
195 if err := v.ValidateAll(); err != nil {
196 errors = append(errors, HealthCheckRequestValidationError{
197 field: "Capability",
198 reason: "embedded message failed validation",
199 cause: err,
200 })
201 }
202 case interface{ Validate() error }:
203 if err := v.Validate(); err != nil {
204 errors = append(errors, HealthCheckRequestValidationError{
205 field: "Capability",
206 reason: "embedded message failed validation",
207 cause: err,
208 })
209 }
210 }
211 } else if v, ok := interface{}(m.GetCapability()).(interface{ Validate() error }); ok {
212 if err := v.Validate(); err != nil {
213 return HealthCheckRequestValidationError{
214 field: "Capability",
215 reason: "embedded message failed validation",
216 cause: err,
217 }
218 }
219 }
220
221 if len(errors) > 0 {
222 return HealthCheckRequestMultiError(errors)
223 }
224
225 return nil
226 }
227
228
229
230
231 type HealthCheckRequestMultiError []error
232
233
234 func (m HealthCheckRequestMultiError) Error() string {
235 var msgs []string
236 for _, err := range m {
237 msgs = append(msgs, err.Error())
238 }
239 return strings.Join(msgs, "; ")
240 }
241
242
243 func (m HealthCheckRequestMultiError) AllErrors() []error { return m }
244
245
246
247 type HealthCheckRequestValidationError struct {
248 field string
249 reason string
250 cause error
251 key bool
252 }
253
254
255 func (e HealthCheckRequestValidationError) Field() string { return e.field }
256
257
258 func (e HealthCheckRequestValidationError) Reason() string { return e.reason }
259
260
261 func (e HealthCheckRequestValidationError) Cause() error { return e.cause }
262
263
264 func (e HealthCheckRequestValidationError) Key() bool { return e.key }
265
266
267 func (e HealthCheckRequestValidationError) ErrorName() string {
268 return "HealthCheckRequestValidationError"
269 }
270
271
272 func (e HealthCheckRequestValidationError) Error() string {
273 cause := ""
274 if e.cause != nil {
275 cause = fmt.Sprintf(" | caused by: %v", e.cause)
276 }
277
278 key := ""
279 if e.key {
280 key = "key for "
281 }
282
283 return fmt.Sprintf(
284 "invalid %sHealthCheckRequest.%s: %s%s",
285 key,
286 e.field,
287 e.reason,
288 cause)
289 }
290
291 var _ error = HealthCheckRequestValidationError{}
292
293 var _ interface {
294 Field() string
295 Reason() string
296 Key() bool
297 Cause() error
298 ErrorName() string
299 } = HealthCheckRequestValidationError{}
300
301
302
303
304 func (m *EndpointHealth) Validate() error {
305 return m.validate(false)
306 }
307
308
309
310
311
312 func (m *EndpointHealth) ValidateAll() error {
313 return m.validate(true)
314 }
315
316 func (m *EndpointHealth) validate(all bool) error {
317 if m == nil {
318 return nil
319 }
320
321 var errors []error
322
323 if all {
324 switch v := interface{}(m.GetEndpoint()).(type) {
325 case interface{ ValidateAll() error }:
326 if err := v.ValidateAll(); err != nil {
327 errors = append(errors, EndpointHealthValidationError{
328 field: "Endpoint",
329 reason: "embedded message failed validation",
330 cause: err,
331 })
332 }
333 case interface{ Validate() error }:
334 if err := v.Validate(); err != nil {
335 errors = append(errors, EndpointHealthValidationError{
336 field: "Endpoint",
337 reason: "embedded message failed validation",
338 cause: err,
339 })
340 }
341 }
342 } else if v, ok := interface{}(m.GetEndpoint()).(interface{ Validate() error }); ok {
343 if err := v.Validate(); err != nil {
344 return EndpointHealthValidationError{
345 field: "Endpoint",
346 reason: "embedded message failed validation",
347 cause: err,
348 }
349 }
350 }
351
352
353
354 if len(errors) > 0 {
355 return EndpointHealthMultiError(errors)
356 }
357
358 return nil
359 }
360
361
362
363
364 type EndpointHealthMultiError []error
365
366
367 func (m EndpointHealthMultiError) Error() string {
368 var msgs []string
369 for _, err := range m {
370 msgs = append(msgs, err.Error())
371 }
372 return strings.Join(msgs, "; ")
373 }
374
375
376 func (m EndpointHealthMultiError) AllErrors() []error { return m }
377
378
379
380 type EndpointHealthValidationError struct {
381 field string
382 reason string
383 cause error
384 key bool
385 }
386
387
388 func (e EndpointHealthValidationError) Field() string { return e.field }
389
390
391 func (e EndpointHealthValidationError) Reason() string { return e.reason }
392
393
394 func (e EndpointHealthValidationError) Cause() error { return e.cause }
395
396
397 func (e EndpointHealthValidationError) Key() bool { return e.key }
398
399
400 func (e EndpointHealthValidationError) ErrorName() string { return "EndpointHealthValidationError" }
401
402
403 func (e EndpointHealthValidationError) Error() string {
404 cause := ""
405 if e.cause != nil {
406 cause = fmt.Sprintf(" | caused by: %v", e.cause)
407 }
408
409 key := ""
410 if e.key {
411 key = "key for "
412 }
413
414 return fmt.Sprintf(
415 "invalid %sEndpointHealth.%s: %s%s",
416 key,
417 e.field,
418 e.reason,
419 cause)
420 }
421
422 var _ error = EndpointHealthValidationError{}
423
424 var _ interface {
425 Field() string
426 Reason() string
427 Key() bool
428 Cause() error
429 ErrorName() string
430 } = EndpointHealthValidationError{}
431
432
433
434
435 func (m *EndpointHealthResponse) Validate() error {
436 return m.validate(false)
437 }
438
439
440
441
442
443 func (m *EndpointHealthResponse) ValidateAll() error {
444 return m.validate(true)
445 }
446
447 func (m *EndpointHealthResponse) validate(all bool) error {
448 if m == nil {
449 return nil
450 }
451
452 var errors []error
453
454 for idx, item := range m.GetEndpointsHealth() {
455 _, _ = idx, item
456
457 if all {
458 switch v := interface{}(item).(type) {
459 case interface{ ValidateAll() error }:
460 if err := v.ValidateAll(); err != nil {
461 errors = append(errors, EndpointHealthResponseValidationError{
462 field: fmt.Sprintf("EndpointsHealth[%v]", idx),
463 reason: "embedded message failed validation",
464 cause: err,
465 })
466 }
467 case interface{ Validate() error }:
468 if err := v.Validate(); err != nil {
469 errors = append(errors, EndpointHealthResponseValidationError{
470 field: fmt.Sprintf("EndpointsHealth[%v]", idx),
471 reason: "embedded message failed validation",
472 cause: err,
473 })
474 }
475 }
476 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
477 if err := v.Validate(); err != nil {
478 return EndpointHealthResponseValidationError{
479 field: fmt.Sprintf("EndpointsHealth[%v]", idx),
480 reason: "embedded message failed validation",
481 cause: err,
482 }
483 }
484 }
485
486 }
487
488 if len(errors) > 0 {
489 return EndpointHealthResponseMultiError(errors)
490 }
491
492 return nil
493 }
494
495
496
497
498 type EndpointHealthResponseMultiError []error
499
500
501 func (m EndpointHealthResponseMultiError) Error() string {
502 var msgs []string
503 for _, err := range m {
504 msgs = append(msgs, err.Error())
505 }
506 return strings.Join(msgs, "; ")
507 }
508
509
510 func (m EndpointHealthResponseMultiError) AllErrors() []error { return m }
511
512
513
514 type EndpointHealthResponseValidationError struct {
515 field string
516 reason string
517 cause error
518 key bool
519 }
520
521
522 func (e EndpointHealthResponseValidationError) Field() string { return e.field }
523
524
525 func (e EndpointHealthResponseValidationError) Reason() string { return e.reason }
526
527
528 func (e EndpointHealthResponseValidationError) Cause() error { return e.cause }
529
530
531 func (e EndpointHealthResponseValidationError) Key() bool { return e.key }
532
533
534 func (e EndpointHealthResponseValidationError) ErrorName() string {
535 return "EndpointHealthResponseValidationError"
536 }
537
538
539 func (e EndpointHealthResponseValidationError) Error() string {
540 cause := ""
541 if e.cause != nil {
542 cause = fmt.Sprintf(" | caused by: %v", e.cause)
543 }
544
545 key := ""
546 if e.key {
547 key = "key for "
548 }
549
550 return fmt.Sprintf(
551 "invalid %sEndpointHealthResponse.%s: %s%s",
552 key,
553 e.field,
554 e.reason,
555 cause)
556 }
557
558 var _ error = EndpointHealthResponseValidationError{}
559
560 var _ interface {
561 Field() string
562 Reason() string
563 Key() bool
564 Cause() error
565 ErrorName() string
566 } = EndpointHealthResponseValidationError{}
567
568
569
570
571
572 func (m *HealthCheckRequestOrEndpointHealthResponse) Validate() error {
573 return m.validate(false)
574 }
575
576
577
578
579
580
581 func (m *HealthCheckRequestOrEndpointHealthResponse) ValidateAll() error {
582 return m.validate(true)
583 }
584
585 func (m *HealthCheckRequestOrEndpointHealthResponse) validate(all bool) error {
586 if m == nil {
587 return nil
588 }
589
590 var errors []error
591
592 switch v := m.RequestType.(type) {
593 case *HealthCheckRequestOrEndpointHealthResponse_HealthCheckRequest:
594 if v == nil {
595 err := HealthCheckRequestOrEndpointHealthResponseValidationError{
596 field: "RequestType",
597 reason: "oneof value cannot be a typed-nil",
598 }
599 if !all {
600 return err
601 }
602 errors = append(errors, err)
603 }
604
605 if all {
606 switch v := interface{}(m.GetHealthCheckRequest()).(type) {
607 case interface{ ValidateAll() error }:
608 if err := v.ValidateAll(); err != nil {
609 errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{
610 field: "HealthCheckRequest",
611 reason: "embedded message failed validation",
612 cause: err,
613 })
614 }
615 case interface{ Validate() error }:
616 if err := v.Validate(); err != nil {
617 errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{
618 field: "HealthCheckRequest",
619 reason: "embedded message failed validation",
620 cause: err,
621 })
622 }
623 }
624 } else if v, ok := interface{}(m.GetHealthCheckRequest()).(interface{ Validate() error }); ok {
625 if err := v.Validate(); err != nil {
626 return HealthCheckRequestOrEndpointHealthResponseValidationError{
627 field: "HealthCheckRequest",
628 reason: "embedded message failed validation",
629 cause: err,
630 }
631 }
632 }
633
634 case *HealthCheckRequestOrEndpointHealthResponse_EndpointHealthResponse:
635 if v == nil {
636 err := HealthCheckRequestOrEndpointHealthResponseValidationError{
637 field: "RequestType",
638 reason: "oneof value cannot be a typed-nil",
639 }
640 if !all {
641 return err
642 }
643 errors = append(errors, err)
644 }
645
646 if all {
647 switch v := interface{}(m.GetEndpointHealthResponse()).(type) {
648 case interface{ ValidateAll() error }:
649 if err := v.ValidateAll(); err != nil {
650 errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{
651 field: "EndpointHealthResponse",
652 reason: "embedded message failed validation",
653 cause: err,
654 })
655 }
656 case interface{ Validate() error }:
657 if err := v.Validate(); err != nil {
658 errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{
659 field: "EndpointHealthResponse",
660 reason: "embedded message failed validation",
661 cause: err,
662 })
663 }
664 }
665 } else if v, ok := interface{}(m.GetEndpointHealthResponse()).(interface{ Validate() error }); ok {
666 if err := v.Validate(); err != nil {
667 return HealthCheckRequestOrEndpointHealthResponseValidationError{
668 field: "EndpointHealthResponse",
669 reason: "embedded message failed validation",
670 cause: err,
671 }
672 }
673 }
674
675 default:
676 _ = v
677 }
678
679 if len(errors) > 0 {
680 return HealthCheckRequestOrEndpointHealthResponseMultiError(errors)
681 }
682
683 return nil
684 }
685
686
687
688
689
690 type HealthCheckRequestOrEndpointHealthResponseMultiError []error
691
692
693 func (m HealthCheckRequestOrEndpointHealthResponseMultiError) Error() string {
694 var msgs []string
695 for _, err := range m {
696 msgs = append(msgs, err.Error())
697 }
698 return strings.Join(msgs, "; ")
699 }
700
701
702 func (m HealthCheckRequestOrEndpointHealthResponseMultiError) AllErrors() []error { return m }
703
704
705
706
707 type HealthCheckRequestOrEndpointHealthResponseValidationError struct {
708 field string
709 reason string
710 cause error
711 key bool
712 }
713
714
715 func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Field() string { return e.field }
716
717
718 func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Reason() string { return e.reason }
719
720
721 func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Cause() error { return e.cause }
722
723
724 func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Key() bool { return e.key }
725
726
727 func (e HealthCheckRequestOrEndpointHealthResponseValidationError) ErrorName() string {
728 return "HealthCheckRequestOrEndpointHealthResponseValidationError"
729 }
730
731
732 func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Error() string {
733 cause := ""
734 if e.cause != nil {
735 cause = fmt.Sprintf(" | caused by: %v", e.cause)
736 }
737
738 key := ""
739 if e.key {
740 key = "key for "
741 }
742
743 return fmt.Sprintf(
744 "invalid %sHealthCheckRequestOrEndpointHealthResponse.%s: %s%s",
745 key,
746 e.field,
747 e.reason,
748 cause)
749 }
750
751 var _ error = HealthCheckRequestOrEndpointHealthResponseValidationError{}
752
753 var _ interface {
754 Field() string
755 Reason() string
756 Key() bool
757 Cause() error
758 ErrorName() string
759 } = HealthCheckRequestOrEndpointHealthResponseValidationError{}
760
761
762
763
764 func (m *LocalityEndpoints) Validate() error {
765 return m.validate(false)
766 }
767
768
769
770
771
772 func (m *LocalityEndpoints) ValidateAll() error {
773 return m.validate(true)
774 }
775
776 func (m *LocalityEndpoints) validate(all bool) error {
777 if m == nil {
778 return nil
779 }
780
781 var errors []error
782
783 if all {
784 switch v := interface{}(m.GetLocality()).(type) {
785 case interface{ ValidateAll() error }:
786 if err := v.ValidateAll(); err != nil {
787 errors = append(errors, LocalityEndpointsValidationError{
788 field: "Locality",
789 reason: "embedded message failed validation",
790 cause: err,
791 })
792 }
793 case interface{ Validate() error }:
794 if err := v.Validate(); err != nil {
795 errors = append(errors, LocalityEndpointsValidationError{
796 field: "Locality",
797 reason: "embedded message failed validation",
798 cause: err,
799 })
800 }
801 }
802 } else if v, ok := interface{}(m.GetLocality()).(interface{ Validate() error }); ok {
803 if err := v.Validate(); err != nil {
804 return LocalityEndpointsValidationError{
805 field: "Locality",
806 reason: "embedded message failed validation",
807 cause: err,
808 }
809 }
810 }
811
812 for idx, item := range m.GetEndpoints() {
813 _, _ = idx, item
814
815 if all {
816 switch v := interface{}(item).(type) {
817 case interface{ ValidateAll() error }:
818 if err := v.ValidateAll(); err != nil {
819 errors = append(errors, LocalityEndpointsValidationError{
820 field: fmt.Sprintf("Endpoints[%v]", idx),
821 reason: "embedded message failed validation",
822 cause: err,
823 })
824 }
825 case interface{ Validate() error }:
826 if err := v.Validate(); err != nil {
827 errors = append(errors, LocalityEndpointsValidationError{
828 field: fmt.Sprintf("Endpoints[%v]", idx),
829 reason: "embedded message failed validation",
830 cause: err,
831 })
832 }
833 }
834 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
835 if err := v.Validate(); err != nil {
836 return LocalityEndpointsValidationError{
837 field: fmt.Sprintf("Endpoints[%v]", idx),
838 reason: "embedded message failed validation",
839 cause: err,
840 }
841 }
842 }
843
844 }
845
846 if len(errors) > 0 {
847 return LocalityEndpointsMultiError(errors)
848 }
849
850 return nil
851 }
852
853
854
855
856 type LocalityEndpointsMultiError []error
857
858
859 func (m LocalityEndpointsMultiError) Error() string {
860 var msgs []string
861 for _, err := range m {
862 msgs = append(msgs, err.Error())
863 }
864 return strings.Join(msgs, "; ")
865 }
866
867
868 func (m LocalityEndpointsMultiError) AllErrors() []error { return m }
869
870
871
872 type LocalityEndpointsValidationError struct {
873 field string
874 reason string
875 cause error
876 key bool
877 }
878
879
880 func (e LocalityEndpointsValidationError) Field() string { return e.field }
881
882
883 func (e LocalityEndpointsValidationError) Reason() string { return e.reason }
884
885
886 func (e LocalityEndpointsValidationError) Cause() error { return e.cause }
887
888
889 func (e LocalityEndpointsValidationError) Key() bool { return e.key }
890
891
892 func (e LocalityEndpointsValidationError) ErrorName() string {
893 return "LocalityEndpointsValidationError"
894 }
895
896
897 func (e LocalityEndpointsValidationError) Error() string {
898 cause := ""
899 if e.cause != nil {
900 cause = fmt.Sprintf(" | caused by: %v", e.cause)
901 }
902
903 key := ""
904 if e.key {
905 key = "key for "
906 }
907
908 return fmt.Sprintf(
909 "invalid %sLocalityEndpoints.%s: %s%s",
910 key,
911 e.field,
912 e.reason,
913 cause)
914 }
915
916 var _ error = LocalityEndpointsValidationError{}
917
918 var _ interface {
919 Field() string
920 Reason() string
921 Key() bool
922 Cause() error
923 ErrorName() string
924 } = LocalityEndpointsValidationError{}
925
926
927
928
929 func (m *ClusterHealthCheck) Validate() error {
930 return m.validate(false)
931 }
932
933
934
935
936
937 func (m *ClusterHealthCheck) ValidateAll() error {
938 return m.validate(true)
939 }
940
941 func (m *ClusterHealthCheck) validate(all bool) error {
942 if m == nil {
943 return nil
944 }
945
946 var errors []error
947
948
949
950 for idx, item := range m.GetHealthChecks() {
951 _, _ = idx, item
952
953 if all {
954 switch v := interface{}(item).(type) {
955 case interface{ ValidateAll() error }:
956 if err := v.ValidateAll(); err != nil {
957 errors = append(errors, ClusterHealthCheckValidationError{
958 field: fmt.Sprintf("HealthChecks[%v]", idx),
959 reason: "embedded message failed validation",
960 cause: err,
961 })
962 }
963 case interface{ Validate() error }:
964 if err := v.Validate(); err != nil {
965 errors = append(errors, ClusterHealthCheckValidationError{
966 field: fmt.Sprintf("HealthChecks[%v]", idx),
967 reason: "embedded message failed validation",
968 cause: err,
969 })
970 }
971 }
972 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
973 if err := v.Validate(); err != nil {
974 return ClusterHealthCheckValidationError{
975 field: fmt.Sprintf("HealthChecks[%v]", idx),
976 reason: "embedded message failed validation",
977 cause: err,
978 }
979 }
980 }
981
982 }
983
984 for idx, item := range m.GetLocalityEndpoints() {
985 _, _ = idx, item
986
987 if all {
988 switch v := interface{}(item).(type) {
989 case interface{ ValidateAll() error }:
990 if err := v.ValidateAll(); err != nil {
991 errors = append(errors, ClusterHealthCheckValidationError{
992 field: fmt.Sprintf("LocalityEndpoints[%v]", idx),
993 reason: "embedded message failed validation",
994 cause: err,
995 })
996 }
997 case interface{ Validate() error }:
998 if err := v.Validate(); err != nil {
999 errors = append(errors, ClusterHealthCheckValidationError{
1000 field: fmt.Sprintf("LocalityEndpoints[%v]", idx),
1001 reason: "embedded message failed validation",
1002 cause: err,
1003 })
1004 }
1005 }
1006 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
1007 if err := v.Validate(); err != nil {
1008 return ClusterHealthCheckValidationError{
1009 field: fmt.Sprintf("LocalityEndpoints[%v]", idx),
1010 reason: "embedded message failed validation",
1011 cause: err,
1012 }
1013 }
1014 }
1015
1016 }
1017
1018 if len(errors) > 0 {
1019 return ClusterHealthCheckMultiError(errors)
1020 }
1021
1022 return nil
1023 }
1024
1025
1026
1027
1028 type ClusterHealthCheckMultiError []error
1029
1030
1031 func (m ClusterHealthCheckMultiError) Error() string {
1032 var msgs []string
1033 for _, err := range m {
1034 msgs = append(msgs, err.Error())
1035 }
1036 return strings.Join(msgs, "; ")
1037 }
1038
1039
1040 func (m ClusterHealthCheckMultiError) AllErrors() []error { return m }
1041
1042
1043
1044 type ClusterHealthCheckValidationError struct {
1045 field string
1046 reason string
1047 cause error
1048 key bool
1049 }
1050
1051
1052 func (e ClusterHealthCheckValidationError) Field() string { return e.field }
1053
1054
1055 func (e ClusterHealthCheckValidationError) Reason() string { return e.reason }
1056
1057
1058 func (e ClusterHealthCheckValidationError) Cause() error { return e.cause }
1059
1060
1061 func (e ClusterHealthCheckValidationError) Key() bool { return e.key }
1062
1063
1064 func (e ClusterHealthCheckValidationError) ErrorName() string {
1065 return "ClusterHealthCheckValidationError"
1066 }
1067
1068
1069 func (e ClusterHealthCheckValidationError) Error() string {
1070 cause := ""
1071 if e.cause != nil {
1072 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1073 }
1074
1075 key := ""
1076 if e.key {
1077 key = "key for "
1078 }
1079
1080 return fmt.Sprintf(
1081 "invalid %sClusterHealthCheck.%s: %s%s",
1082 key,
1083 e.field,
1084 e.reason,
1085 cause)
1086 }
1087
1088 var _ error = ClusterHealthCheckValidationError{}
1089
1090 var _ interface {
1091 Field() string
1092 Reason() string
1093 Key() bool
1094 Cause() error
1095 ErrorName() string
1096 } = ClusterHealthCheckValidationError{}
1097
1098
1099
1100
1101 func (m *HealthCheckSpecifier) Validate() error {
1102 return m.validate(false)
1103 }
1104
1105
1106
1107
1108
1109 func (m *HealthCheckSpecifier) ValidateAll() error {
1110 return m.validate(true)
1111 }
1112
1113 func (m *HealthCheckSpecifier) validate(all bool) error {
1114 if m == nil {
1115 return nil
1116 }
1117
1118 var errors []error
1119
1120 for idx, item := range m.GetClusterHealthChecks() {
1121 _, _ = idx, item
1122
1123 if all {
1124 switch v := interface{}(item).(type) {
1125 case interface{ ValidateAll() error }:
1126 if err := v.ValidateAll(); err != nil {
1127 errors = append(errors, HealthCheckSpecifierValidationError{
1128 field: fmt.Sprintf("ClusterHealthChecks[%v]", idx),
1129 reason: "embedded message failed validation",
1130 cause: err,
1131 })
1132 }
1133 case interface{ Validate() error }:
1134 if err := v.Validate(); err != nil {
1135 errors = append(errors, HealthCheckSpecifierValidationError{
1136 field: fmt.Sprintf("ClusterHealthChecks[%v]", idx),
1137 reason: "embedded message failed validation",
1138 cause: err,
1139 })
1140 }
1141 }
1142 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
1143 if err := v.Validate(); err != nil {
1144 return HealthCheckSpecifierValidationError{
1145 field: fmt.Sprintf("ClusterHealthChecks[%v]", idx),
1146 reason: "embedded message failed validation",
1147 cause: err,
1148 }
1149 }
1150 }
1151
1152 }
1153
1154 if all {
1155 switch v := interface{}(m.GetInterval()).(type) {
1156 case interface{ ValidateAll() error }:
1157 if err := v.ValidateAll(); err != nil {
1158 errors = append(errors, HealthCheckSpecifierValidationError{
1159 field: "Interval",
1160 reason: "embedded message failed validation",
1161 cause: err,
1162 })
1163 }
1164 case interface{ Validate() error }:
1165 if err := v.Validate(); err != nil {
1166 errors = append(errors, HealthCheckSpecifierValidationError{
1167 field: "Interval",
1168 reason: "embedded message failed validation",
1169 cause: err,
1170 })
1171 }
1172 }
1173 } else if v, ok := interface{}(m.GetInterval()).(interface{ Validate() error }); ok {
1174 if err := v.Validate(); err != nil {
1175 return HealthCheckSpecifierValidationError{
1176 field: "Interval",
1177 reason: "embedded message failed validation",
1178 cause: err,
1179 }
1180 }
1181 }
1182
1183 if len(errors) > 0 {
1184 return HealthCheckSpecifierMultiError(errors)
1185 }
1186
1187 return nil
1188 }
1189
1190
1191
1192
1193 type HealthCheckSpecifierMultiError []error
1194
1195
1196 func (m HealthCheckSpecifierMultiError) Error() string {
1197 var msgs []string
1198 for _, err := range m {
1199 msgs = append(msgs, err.Error())
1200 }
1201 return strings.Join(msgs, "; ")
1202 }
1203
1204
1205 func (m HealthCheckSpecifierMultiError) AllErrors() []error { return m }
1206
1207
1208
1209 type HealthCheckSpecifierValidationError struct {
1210 field string
1211 reason string
1212 cause error
1213 key bool
1214 }
1215
1216
1217 func (e HealthCheckSpecifierValidationError) Field() string { return e.field }
1218
1219
1220 func (e HealthCheckSpecifierValidationError) Reason() string { return e.reason }
1221
1222
1223 func (e HealthCheckSpecifierValidationError) Cause() error { return e.cause }
1224
1225
1226 func (e HealthCheckSpecifierValidationError) Key() bool { return e.key }
1227
1228
1229 func (e HealthCheckSpecifierValidationError) ErrorName() string {
1230 return "HealthCheckSpecifierValidationError"
1231 }
1232
1233
1234 func (e HealthCheckSpecifierValidationError) Error() string {
1235 cause := ""
1236 if e.cause != nil {
1237 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1238 }
1239
1240 key := ""
1241 if e.key {
1242 key = "key for "
1243 }
1244
1245 return fmt.Sprintf(
1246 "invalid %sHealthCheckSpecifier.%s: %s%s",
1247 key,
1248 e.field,
1249 e.reason,
1250 cause)
1251 }
1252
1253 var _ error = HealthCheckSpecifierValidationError{}
1254
1255 var _ interface {
1256 Field() string
1257 Reason() string
1258 Key() bool
1259 Cause() error
1260 ErrorName() string
1261 } = HealthCheckSpecifierValidationError{}
1262
View as plain text