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