1
2
3
4 package envoy_config_metrics_v4alpha
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "strings"
15 "time"
16 "unicode/utf8"
17
18 "github.com/golang/protobuf/ptypes"
19 )
20
21
22 var (
23 _ = bytes.MinRead
24 _ = errors.New("")
25 _ = fmt.Print
26 _ = utf8.UTFMax
27 _ = (*regexp.Regexp)(nil)
28 _ = (*strings.Reader)(nil)
29 _ = net.IPv4len
30 _ = time.Duration(0)
31 _ = (*url.URL)(nil)
32 _ = (*mail.Address)(nil)
33 _ = ptypes.DynamicAny{}
34 )
35
36
37
38 func (m *StatsSink) Validate() error {
39 if m == nil {
40 return nil
41 }
42
43
44
45 switch m.ConfigType.(type) {
46
47 case *StatsSink_TypedConfig:
48
49 if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
50 if err := v.Validate(); err != nil {
51 return StatsSinkValidationError{
52 field: "TypedConfig",
53 reason: "embedded message failed validation",
54 cause: err,
55 }
56 }
57 }
58
59 }
60
61 return nil
62 }
63
64
65
66 type StatsSinkValidationError struct {
67 field string
68 reason string
69 cause error
70 key bool
71 }
72
73
74 func (e StatsSinkValidationError) Field() string { return e.field }
75
76
77 func (e StatsSinkValidationError) Reason() string { return e.reason }
78
79
80 func (e StatsSinkValidationError) Cause() error { return e.cause }
81
82
83 func (e StatsSinkValidationError) Key() bool { return e.key }
84
85
86 func (e StatsSinkValidationError) ErrorName() string { return "StatsSinkValidationError" }
87
88
89 func (e StatsSinkValidationError) Error() string {
90 cause := ""
91 if e.cause != nil {
92 cause = fmt.Sprintf(" | caused by: %v", e.cause)
93 }
94
95 key := ""
96 if e.key {
97 key = "key for "
98 }
99
100 return fmt.Sprintf(
101 "invalid %sStatsSink.%s: %s%s",
102 key,
103 e.field,
104 e.reason,
105 cause)
106 }
107
108 var _ error = StatsSinkValidationError{}
109
110 var _ interface {
111 Field() string
112 Reason() string
113 Key() bool
114 Cause() error
115 ErrorName() string
116 } = StatsSinkValidationError{}
117
118
119
120
121 func (m *StatsConfig) Validate() error {
122 if m == nil {
123 return nil
124 }
125
126 for idx, item := range m.GetStatsTags() {
127 _, _ = idx, item
128
129 if v, ok := interface{}(item).(interface{ Validate() error }); ok {
130 if err := v.Validate(); err != nil {
131 return StatsConfigValidationError{
132 field: fmt.Sprintf("StatsTags[%v]", idx),
133 reason: "embedded message failed validation",
134 cause: err,
135 }
136 }
137 }
138
139 }
140
141 if v, ok := interface{}(m.GetUseAllDefaultTags()).(interface{ Validate() error }); ok {
142 if err := v.Validate(); err != nil {
143 return StatsConfigValidationError{
144 field: "UseAllDefaultTags",
145 reason: "embedded message failed validation",
146 cause: err,
147 }
148 }
149 }
150
151 if v, ok := interface{}(m.GetStatsMatcher()).(interface{ Validate() error }); ok {
152 if err := v.Validate(); err != nil {
153 return StatsConfigValidationError{
154 field: "StatsMatcher",
155 reason: "embedded message failed validation",
156 cause: err,
157 }
158 }
159 }
160
161 for idx, item := range m.GetHistogramBucketSettings() {
162 _, _ = idx, item
163
164 if v, ok := interface{}(item).(interface{ Validate() error }); ok {
165 if err := v.Validate(); err != nil {
166 return StatsConfigValidationError{
167 field: fmt.Sprintf("HistogramBucketSettings[%v]", idx),
168 reason: "embedded message failed validation",
169 cause: err,
170 }
171 }
172 }
173
174 }
175
176 return nil
177 }
178
179
180
181 type StatsConfigValidationError struct {
182 field string
183 reason string
184 cause error
185 key bool
186 }
187
188
189 func (e StatsConfigValidationError) Field() string { return e.field }
190
191
192 func (e StatsConfigValidationError) Reason() string { return e.reason }
193
194
195 func (e StatsConfigValidationError) Cause() error { return e.cause }
196
197
198 func (e StatsConfigValidationError) Key() bool { return e.key }
199
200
201 func (e StatsConfigValidationError) ErrorName() string { return "StatsConfigValidationError" }
202
203
204 func (e StatsConfigValidationError) Error() string {
205 cause := ""
206 if e.cause != nil {
207 cause = fmt.Sprintf(" | caused by: %v", e.cause)
208 }
209
210 key := ""
211 if e.key {
212 key = "key for "
213 }
214
215 return fmt.Sprintf(
216 "invalid %sStatsConfig.%s: %s%s",
217 key,
218 e.field,
219 e.reason,
220 cause)
221 }
222
223 var _ error = StatsConfigValidationError{}
224
225 var _ interface {
226 Field() string
227 Reason() string
228 Key() bool
229 Cause() error
230 ErrorName() string
231 } = StatsConfigValidationError{}
232
233
234
235
236 func (m *StatsMatcher) Validate() error {
237 if m == nil {
238 return nil
239 }
240
241 switch m.StatsMatcher.(type) {
242
243 case *StatsMatcher_RejectAll:
244
245
246 case *StatsMatcher_ExclusionList:
247
248 if v, ok := interface{}(m.GetExclusionList()).(interface{ Validate() error }); ok {
249 if err := v.Validate(); err != nil {
250 return StatsMatcherValidationError{
251 field: "ExclusionList",
252 reason: "embedded message failed validation",
253 cause: err,
254 }
255 }
256 }
257
258 case *StatsMatcher_InclusionList:
259
260 if v, ok := interface{}(m.GetInclusionList()).(interface{ Validate() error }); ok {
261 if err := v.Validate(); err != nil {
262 return StatsMatcherValidationError{
263 field: "InclusionList",
264 reason: "embedded message failed validation",
265 cause: err,
266 }
267 }
268 }
269
270 default:
271 return StatsMatcherValidationError{
272 field: "StatsMatcher",
273 reason: "value is required",
274 }
275
276 }
277
278 return nil
279 }
280
281
282
283 type StatsMatcherValidationError struct {
284 field string
285 reason string
286 cause error
287 key bool
288 }
289
290
291 func (e StatsMatcherValidationError) Field() string { return e.field }
292
293
294 func (e StatsMatcherValidationError) Reason() string { return e.reason }
295
296
297 func (e StatsMatcherValidationError) Cause() error { return e.cause }
298
299
300 func (e StatsMatcherValidationError) Key() bool { return e.key }
301
302
303 func (e StatsMatcherValidationError) ErrorName() string { return "StatsMatcherValidationError" }
304
305
306 func (e StatsMatcherValidationError) Error() string {
307 cause := ""
308 if e.cause != nil {
309 cause = fmt.Sprintf(" | caused by: %v", e.cause)
310 }
311
312 key := ""
313 if e.key {
314 key = "key for "
315 }
316
317 return fmt.Sprintf(
318 "invalid %sStatsMatcher.%s: %s%s",
319 key,
320 e.field,
321 e.reason,
322 cause)
323 }
324
325 var _ error = StatsMatcherValidationError{}
326
327 var _ interface {
328 Field() string
329 Reason() string
330 Key() bool
331 Cause() error
332 ErrorName() string
333 } = StatsMatcherValidationError{}
334
335
336
337
338 func (m *TagSpecifier) Validate() error {
339 if m == nil {
340 return nil
341 }
342
343
344
345 switch m.TagValue.(type) {
346
347 case *TagSpecifier_Regex:
348
349 if len(m.GetRegex()) > 1024 {
350 return TagSpecifierValidationError{
351 field: "Regex",
352 reason: "value length must be at most 1024 bytes",
353 }
354 }
355
356 case *TagSpecifier_FixedValue:
357
358
359 }
360
361 return nil
362 }
363
364
365
366 type TagSpecifierValidationError struct {
367 field string
368 reason string
369 cause error
370 key bool
371 }
372
373
374 func (e TagSpecifierValidationError) Field() string { return e.field }
375
376
377 func (e TagSpecifierValidationError) Reason() string { return e.reason }
378
379
380 func (e TagSpecifierValidationError) Cause() error { return e.cause }
381
382
383 func (e TagSpecifierValidationError) Key() bool { return e.key }
384
385
386 func (e TagSpecifierValidationError) ErrorName() string { return "TagSpecifierValidationError" }
387
388
389 func (e TagSpecifierValidationError) Error() string {
390 cause := ""
391 if e.cause != nil {
392 cause = fmt.Sprintf(" | caused by: %v", e.cause)
393 }
394
395 key := ""
396 if e.key {
397 key = "key for "
398 }
399
400 return fmt.Sprintf(
401 "invalid %sTagSpecifier.%s: %s%s",
402 key,
403 e.field,
404 e.reason,
405 cause)
406 }
407
408 var _ error = TagSpecifierValidationError{}
409
410 var _ interface {
411 Field() string
412 Reason() string
413 Key() bool
414 Cause() error
415 ErrorName() string
416 } = TagSpecifierValidationError{}
417
418
419
420
421 func (m *HistogramBucketSettings) Validate() error {
422 if m == nil {
423 return nil
424 }
425
426 if m.GetMatch() == nil {
427 return HistogramBucketSettingsValidationError{
428 field: "Match",
429 reason: "value is required",
430 }
431 }
432
433 if v, ok := interface{}(m.GetMatch()).(interface{ Validate() error }); ok {
434 if err := v.Validate(); err != nil {
435 return HistogramBucketSettingsValidationError{
436 field: "Match",
437 reason: "embedded message failed validation",
438 cause: err,
439 }
440 }
441 }
442
443 if len(m.GetBuckets()) < 1 {
444 return HistogramBucketSettingsValidationError{
445 field: "Buckets",
446 reason: "value must contain at least 1 item(s)",
447 }
448 }
449
450 _HistogramBucketSettings_Buckets_Unique := make(map[float64]struct{}, len(m.GetBuckets()))
451
452 for idx, item := range m.GetBuckets() {
453 _, _ = idx, item
454
455 if _, exists := _HistogramBucketSettings_Buckets_Unique[item]; exists {
456 return HistogramBucketSettingsValidationError{
457 field: fmt.Sprintf("Buckets[%v]", idx),
458 reason: "repeated value must contain unique items",
459 }
460 } else {
461 _HistogramBucketSettings_Buckets_Unique[item] = struct{}{}
462 }
463
464 if item <= 0 {
465 return HistogramBucketSettingsValidationError{
466 field: fmt.Sprintf("Buckets[%v]", idx),
467 reason: "value must be greater than 0",
468 }
469 }
470
471 }
472
473 return nil
474 }
475
476
477
478 type HistogramBucketSettingsValidationError struct {
479 field string
480 reason string
481 cause error
482 key bool
483 }
484
485
486 func (e HistogramBucketSettingsValidationError) Field() string { return e.field }
487
488
489 func (e HistogramBucketSettingsValidationError) Reason() string { return e.reason }
490
491
492 func (e HistogramBucketSettingsValidationError) Cause() error { return e.cause }
493
494
495 func (e HistogramBucketSettingsValidationError) Key() bool { return e.key }
496
497
498 func (e HistogramBucketSettingsValidationError) ErrorName() string {
499 return "HistogramBucketSettingsValidationError"
500 }
501
502
503 func (e HistogramBucketSettingsValidationError) Error() string {
504 cause := ""
505 if e.cause != nil {
506 cause = fmt.Sprintf(" | caused by: %v", e.cause)
507 }
508
509 key := ""
510 if e.key {
511 key = "key for "
512 }
513
514 return fmt.Sprintf(
515 "invalid %sHistogramBucketSettings.%s: %s%s",
516 key,
517 e.field,
518 e.reason,
519 cause)
520 }
521
522 var _ error = HistogramBucketSettingsValidationError{}
523
524 var _ interface {
525 Field() string
526 Reason() string
527 Key() bool
528 Cause() error
529 ErrorName() string
530 } = HistogramBucketSettingsValidationError{}
531
532
533
534 func (m *StatsdSink) Validate() error {
535 if m == nil {
536 return nil
537 }
538
539
540
541 switch m.StatsdSpecifier.(type) {
542
543 case *StatsdSink_Address:
544
545 if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
546 if err := v.Validate(); err != nil {
547 return StatsdSinkValidationError{
548 field: "Address",
549 reason: "embedded message failed validation",
550 cause: err,
551 }
552 }
553 }
554
555 case *StatsdSink_TcpClusterName:
556
557
558 default:
559 return StatsdSinkValidationError{
560 field: "StatsdSpecifier",
561 reason: "value is required",
562 }
563
564 }
565
566 return nil
567 }
568
569
570
571 type StatsdSinkValidationError struct {
572 field string
573 reason string
574 cause error
575 key bool
576 }
577
578
579 func (e StatsdSinkValidationError) Field() string { return e.field }
580
581
582 func (e StatsdSinkValidationError) Reason() string { return e.reason }
583
584
585 func (e StatsdSinkValidationError) Cause() error { return e.cause }
586
587
588 func (e StatsdSinkValidationError) Key() bool { return e.key }
589
590
591 func (e StatsdSinkValidationError) ErrorName() string { return "StatsdSinkValidationError" }
592
593
594 func (e StatsdSinkValidationError) Error() string {
595 cause := ""
596 if e.cause != nil {
597 cause = fmt.Sprintf(" | caused by: %v", e.cause)
598 }
599
600 key := ""
601 if e.key {
602 key = "key for "
603 }
604
605 return fmt.Sprintf(
606 "invalid %sStatsdSink.%s: %s%s",
607 key,
608 e.field,
609 e.reason,
610 cause)
611 }
612
613 var _ error = StatsdSinkValidationError{}
614
615 var _ interface {
616 Field() string
617 Reason() string
618 Key() bool
619 Cause() error
620 ErrorName() string
621 } = StatsdSinkValidationError{}
622
623
624
625
626 func (m *DogStatsdSink) Validate() error {
627 if m == nil {
628 return nil
629 }
630
631
632
633 if wrapper := m.GetMaxBytesPerDatagram(); wrapper != nil {
634
635 if wrapper.GetValue() <= 0 {
636 return DogStatsdSinkValidationError{
637 field: "MaxBytesPerDatagram",
638 reason: "value must be greater than 0",
639 }
640 }
641
642 }
643
644 switch m.DogStatsdSpecifier.(type) {
645
646 case *DogStatsdSink_Address:
647
648 if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
649 if err := v.Validate(); err != nil {
650 return DogStatsdSinkValidationError{
651 field: "Address",
652 reason: "embedded message failed validation",
653 cause: err,
654 }
655 }
656 }
657
658 default:
659 return DogStatsdSinkValidationError{
660 field: "DogStatsdSpecifier",
661 reason: "value is required",
662 }
663
664 }
665
666 return nil
667 }
668
669
670
671 type DogStatsdSinkValidationError struct {
672 field string
673 reason string
674 cause error
675 key bool
676 }
677
678
679 func (e DogStatsdSinkValidationError) Field() string { return e.field }
680
681
682 func (e DogStatsdSinkValidationError) Reason() string { return e.reason }
683
684
685 func (e DogStatsdSinkValidationError) Cause() error { return e.cause }
686
687
688 func (e DogStatsdSinkValidationError) Key() bool { return e.key }
689
690
691 func (e DogStatsdSinkValidationError) ErrorName() string { return "DogStatsdSinkValidationError" }
692
693
694 func (e DogStatsdSinkValidationError) Error() string {
695 cause := ""
696 if e.cause != nil {
697 cause = fmt.Sprintf(" | caused by: %v", e.cause)
698 }
699
700 key := ""
701 if e.key {
702 key = "key for "
703 }
704
705 return fmt.Sprintf(
706 "invalid %sDogStatsdSink.%s: %s%s",
707 key,
708 e.field,
709 e.reason,
710 cause)
711 }
712
713 var _ error = DogStatsdSinkValidationError{}
714
715 var _ interface {
716 Field() string
717 Reason() string
718 Key() bool
719 Cause() error
720 ErrorName() string
721 } = DogStatsdSinkValidationError{}
722
723
724
725
726 func (m *HystrixSink) Validate() error {
727 if m == nil {
728 return nil
729 }
730
731
732
733 return nil
734 }
735
736
737
738 type HystrixSinkValidationError struct {
739 field string
740 reason string
741 cause error
742 key bool
743 }
744
745
746 func (e HystrixSinkValidationError) Field() string { return e.field }
747
748
749 func (e HystrixSinkValidationError) Reason() string { return e.reason }
750
751
752 func (e HystrixSinkValidationError) Cause() error { return e.cause }
753
754
755 func (e HystrixSinkValidationError) Key() bool { return e.key }
756
757
758 func (e HystrixSinkValidationError) ErrorName() string { return "HystrixSinkValidationError" }
759
760
761 func (e HystrixSinkValidationError) Error() string {
762 cause := ""
763 if e.cause != nil {
764 cause = fmt.Sprintf(" | caused by: %v", e.cause)
765 }
766
767 key := ""
768 if e.key {
769 key = "key for "
770 }
771
772 return fmt.Sprintf(
773 "invalid %sHystrixSink.%s: %s%s",
774 key,
775 e.field,
776 e.reason,
777 cause)
778 }
779
780 var _ error = HystrixSinkValidationError{}
781
782 var _ interface {
783 Field() string
784 Reason() string
785 Key() bool
786 Cause() error
787 ErrorName() string
788 } = HystrixSinkValidationError{}
789
View as plain text