Debian Codegraph @

envoy/config/core/v3/config_source.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/core/v3/config_source.proto
4
5 package corev3
6
7 import (
8 "bytes"
9 "errors"
10 "fmt"
11 "net"
12 "net/mail"
13 "net/url"
14 "regexp"
15 "sort"
16 "strings"
17 "time"
18 "unicode/utf8"
19
20 "google.golang.org/protobuf/types/known/anypb"
21 )
22
23 // ensure the imports are used
24 var (
25 _ = bytes.MinRead
26 _ = errors.New("")
27 _ = fmt.Print
28 _ = utf8.UTFMax
29 _ = (*regexp.Regexp)(nil)
30 _ = (*strings.Reader)(nil)
31 _ = net.IPv4len
32 _ = time.Duration(0)
33 _ = (*url.URL)(nil)
34 _ = (*mail.Address)(nil)
35 _ = anypb.Any{}
36 _ = sort.Sort
37 )
38
39 // Validate checks the field values on ApiConfigSource with the rules defined
40 // in the proto definition for this message. If any rules are violated, the
41 // first error encountered is returned, or nil if there are no violations.
42 func (m *ApiConfigSource) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on ApiConfigSource with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // ApiConfigSourceMultiError, or nil if none found.
50 func (m *ApiConfigSource) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *ApiConfigSource) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if _, ok := ApiConfigSource_ApiType_name[int32(m.GetApiType())]; !ok {
62 err := ApiConfigSourceValidationError{
63 field: "ApiType",
64 reason: "value must be one of the defined enum values",
65 }
66 if !all {
67 return err
68 }
69 errors = append(errors, err)
70 }
71
72 if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
73 err := ApiConfigSourceValidationError{
74 field: "TransportApiVersion",
75 reason: "value must be one of the defined enum values",
76 }
77 if !all {
78 return err
79 }
80 errors = append(errors, err)
81 }
82
83 for idx, item := range m.GetGrpcServices() {
84 _, _ = idx, item
85
86 if all {
87 switch v := interface{}(item).(type) {
88 case interface{ ValidateAll() error }:
89 if err := v.ValidateAll(); err != nil {
90 errors = append(errors, ApiConfigSourceValidationError{
91 field: fmt.Sprintf("GrpcServices[%v]", idx),
92 reason: "embedded message failed validation",
93 cause: err,
94 })
95 }
96 case interface{ Validate() error }:
97 if err := v.Validate(); err != nil {
98 errors = append(errors, ApiConfigSourceValidationError{
99 field: fmt.Sprintf("GrpcServices[%v]", idx),
100 reason: "embedded message failed validation",
101 cause: err,
102 })
103 }
104 }
105 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
106 if err := v.Validate(); err != nil {
107 return ApiConfigSourceValidationError{
108 field: fmt.Sprintf("GrpcServices[%v]", idx),
109 reason: "embedded message failed validation",
110 cause: err,
111 }
112 }
113 }
114
115 }
116
117 if all {
118 switch v := interface{}(m.GetRefreshDelay()).(type) {
119 case interface{ ValidateAll() error }:
120 if err := v.ValidateAll(); err != nil {
121 errors = append(errors, ApiConfigSourceValidationError{
122 field: "RefreshDelay",
123 reason: "embedded message failed validation",
124 cause: err,
125 })
126 }
127 case interface{ Validate() error }:
128 if err := v.Validate(); err != nil {
129 errors = append(errors, ApiConfigSourceValidationError{
130 field: "RefreshDelay",
131 reason: "embedded message failed validation",
132 cause: err,
133 })
134 }
135 }
136 } else if v, ok := interface{}(m.GetRefreshDelay()).(interface{ Validate() error }); ok {
137 if err := v.Validate(); err != nil {
138 return ApiConfigSourceValidationError{
139 field: "RefreshDelay",
140 reason: "embedded message failed validation",
141 cause: err,
142 }
143 }
144 }
145
146 if d := m.GetRequestTimeout(); d != nil {
147 dur, err := d.AsDuration(), d.CheckValid()
148 if err != nil {
149 err = ApiConfigSourceValidationError{
150 field: "RequestTimeout",
151 reason: "value is not a valid duration",
152 cause: err,
153 }
154 if !all {
155 return err
156 }
157 errors = append(errors, err)
158 } else {
159
160 gt := time.Duration(0*time.Second + 0*time.Nanosecond)
161
162 if dur <= gt {
163 err := ApiConfigSourceValidationError{
164 field: "RequestTimeout",
165 reason: "value must be greater than 0s",
166 }
167 if !all {
168 return err
169 }
170 errors = append(errors, err)
171 }
172
173 }
174 }
175
176 if all {
177 switch v := interface{}(m.GetRateLimitSettings()).(type) {
178 case interface{ ValidateAll() error }:
179 if err := v.ValidateAll(); err != nil {
180 errors = append(errors, ApiConfigSourceValidationError{
181 field: "RateLimitSettings",
182 reason: "embedded message failed validation",
183 cause: err,
184 })
185 }
186 case interface{ Validate() error }:
187 if err := v.Validate(); err != nil {
188 errors = append(errors, ApiConfigSourceValidationError{
189 field: "RateLimitSettings",
190 reason: "embedded message failed validation",
191 cause: err,
192 })
193 }
194 }
195 } else if v, ok := interface{}(m.GetRateLimitSettings()).(interface{ Validate() error }); ok {
196 if err := v.Validate(); err != nil {
197 return ApiConfigSourceValidationError{
198 field: "RateLimitSettings",
199 reason: "embedded message failed validation",
200 cause: err,
201 }
202 }
203 }
204
205 // no validation rules for SetNodeOnFirstMessageOnly
206
207 for idx, item := range m.GetConfigValidators() {
208 _, _ = idx, item
209
210 if all {
211 switch v := interface{}(item).(type) {
212 case interface{ ValidateAll() error }:
213 if err := v.ValidateAll(); err != nil {
214 errors = append(errors, ApiConfigSourceValidationError{
215 field: fmt.Sprintf("ConfigValidators[%v]", idx),
216 reason: "embedded message failed validation",
217 cause: err,
218 })
219 }
220 case interface{ Validate() error }:
221 if err := v.Validate(); err != nil {
222 errors = append(errors, ApiConfigSourceValidationError{
223 field: fmt.Sprintf("ConfigValidators[%v]", idx),
224 reason: "embedded message failed validation",
225 cause: err,
226 })
227 }
228 }
229 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
230 if err := v.Validate(); err != nil {
231 return ApiConfigSourceValidationError{
232 field: fmt.Sprintf("ConfigValidators[%v]", idx),
233 reason: "embedded message failed validation",
234 cause: err,
235 }
236 }
237 }
238
239 }
240
241 if len(errors) > 0 {
242 return ApiConfigSourceMultiError(errors)
243 }
244
245 return nil
246 }
247
248 // ApiConfigSourceMultiError is an error wrapping multiple validation errors
249 // returned by ApiConfigSource.ValidateAll() if the designated constraints
250 // aren't met.
251 type ApiConfigSourceMultiError []error
252
253 // Error returns a concatenation of all the error messages it wraps.
254 func (m ApiConfigSourceMultiError) Error() string {
255 var msgs []string
256 for _, err := range m {
257 msgs = append(msgs, err.Error())
258 }
259 return strings.Join(msgs, "; ")
260 }
261
262 // AllErrors returns a list of validation violation errors.
263 func (m ApiConfigSourceMultiError) AllErrors() []error { return m }
264
265 // ApiConfigSourceValidationError is the validation error returned by
266 // ApiConfigSource.Validate if the designated constraints aren't met.
267 type ApiConfigSourceValidationError struct {
268 field string
269 reason string
270 cause error
271 key bool
272 }
273
274 // Field function returns field value.
275 func (e ApiConfigSourceValidationError) Field() string { return e.field }
276
277 // Reason function returns reason value.
278 func (e ApiConfigSourceValidationError) Reason() string { return e.reason }
279
280 // Cause function returns cause value.
281 func (e ApiConfigSourceValidationError) Cause() error { return e.cause }
282
283 // Key function returns key value.
284 func (e ApiConfigSourceValidationError) Key() bool { return e.key }
285
286 // ErrorName returns error name.
287 func (e ApiConfigSourceValidationError) ErrorName() string { return "ApiConfigSourceValidationError" }
288
289 // Error satisfies the builtin error interface
290 func (e ApiConfigSourceValidationError) Error() string {
291 cause := ""
292 if e.cause != nil {
293 cause = fmt.Sprintf(" | caused by: %v", e.cause)
294 }
295
296 key := ""
297 if e.key {
298 key = "key for "
299 }
300
301 return fmt.Sprintf(
302 "invalid %sApiConfigSource.%s: %s%s",
303 key,
304 e.field,
305 e.reason,
306 cause)
307 }
308
309 var _ error = ApiConfigSourceValidationError{}
310
311 var _ interface {
312 Field() string
313 Reason() string
314 Key() bool
315 Cause() error
316 ErrorName() string
317 } = ApiConfigSourceValidationError{}
318
319 // Validate checks the field values on AggregatedConfigSource with the rules
320 // defined in the proto definition for this message. If any rules are
321 // violated, the first error encountered is returned, or nil if there are no violations.
322 func (m *AggregatedConfigSource) Validate() error {
323 return m.validate(false)
324 }
325
326 // ValidateAll checks the field values on AggregatedConfigSource with the rules
327 // defined in the proto definition for this message. If any rules are
328 // violated, the result is a list of violation errors wrapped in
329 // AggregatedConfigSourceMultiError, or nil if none found.
330 func (m *AggregatedConfigSource) ValidateAll() error {
331 return m.validate(true)
332 }
333
334 func (m *AggregatedConfigSource) validate(all bool) error {
335 if m == nil {
336 return nil
337 }
338
339 var errors []error
340
341 if len(errors) > 0 {
342 return AggregatedConfigSourceMultiError(errors)
343 }
344
345 return nil
346 }
347
348 // AggregatedConfigSourceMultiError is an error wrapping multiple validation
349 // errors returned by AggregatedConfigSource.ValidateAll() if the designated
350 // constraints aren't met.
351 type AggregatedConfigSourceMultiError []error
352
353 // Error returns a concatenation of all the error messages it wraps.
354 func (m AggregatedConfigSourceMultiError) Error() string {
355 var msgs []string
356 for _, err := range m {
357 msgs = append(msgs, err.Error())
358 }
359 return strings.Join(msgs, "; ")
360 }
361
362 // AllErrors returns a list of validation violation errors.
363 func (m AggregatedConfigSourceMultiError) AllErrors() []error { return m }
364
365 // AggregatedConfigSourceValidationError is the validation error returned by
366 // AggregatedConfigSource.Validate if the designated constraints aren't met.
367 type AggregatedConfigSourceValidationError struct {
368 field string
369 reason string
370 cause error
371 key bool
372 }
373
374 // Field function returns field value.
375 func (e AggregatedConfigSourceValidationError) Field() string { return e.field }
376
377 // Reason function returns reason value.
378 func (e AggregatedConfigSourceValidationError) Reason() string { return e.reason }
379
380 // Cause function returns cause value.
381 func (e AggregatedConfigSourceValidationError) Cause() error { return e.cause }
382
383 // Key function returns key value.
384 func (e AggregatedConfigSourceValidationError) Key() bool { return e.key }
385
386 // ErrorName returns error name.
387 func (e AggregatedConfigSourceValidationError) ErrorName() string {
388 return "AggregatedConfigSourceValidationError"
389 }
390
391 // Error satisfies the builtin error interface
392 func (e AggregatedConfigSourceValidationError) Error() string {
393 cause := ""
394 if e.cause != nil {
395 cause = fmt.Sprintf(" | caused by: %v", e.cause)
396 }
397
398 key := ""
399 if e.key {
400 key = "key for "
401 }
402
403 return fmt.Sprintf(
404 "invalid %sAggregatedConfigSource.%s: %s%s",
405 key,
406 e.field,
407 e.reason,
408 cause)
409 }
410
411 var _ error = AggregatedConfigSourceValidationError{}
412
413 var _ interface {
414 Field() string
415 Reason() string
416 Key() bool
417 Cause() error
418 ErrorName() string
419 } = AggregatedConfigSourceValidationError{}
420
421 // Validate checks the field values on SelfConfigSource with the rules defined
422 // in the proto definition for this message. If any rules are violated, the
423 // first error encountered is returned, or nil if there are no violations.
424 func (m *SelfConfigSource) Validate() error {
425 return m.validate(false)
426 }
427
428 // ValidateAll checks the field values on SelfConfigSource with the rules
429 // defined in the proto definition for this message. If any rules are
430 // violated, the result is a list of violation errors wrapped in
431 // SelfConfigSourceMultiError, or nil if none found.
432 func (m *SelfConfigSource) ValidateAll() error {
433 return m.validate(true)
434 }
435
436 func (m *SelfConfigSource) validate(all bool) error {
437 if m == nil {
438 return nil
439 }
440
441 var errors []error
442
443 if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
444 err := SelfConfigSourceValidationError{
445 field: "TransportApiVersion",
446 reason: "value must be one of the defined enum values",
447 }
448 if !all {
449 return err
450 }
451 errors = append(errors, err)
452 }
453
454 if len(errors) > 0 {
455 return SelfConfigSourceMultiError(errors)
456 }
457
458 return nil
459 }
460
461 // SelfConfigSourceMultiError is an error wrapping multiple validation errors
462 // returned by SelfConfigSource.ValidateAll() if the designated constraints
463 // aren't met.
464 type SelfConfigSourceMultiError []error
465
466 // Error returns a concatenation of all the error messages it wraps.
467 func (m SelfConfigSourceMultiError) Error() string {
468 var msgs []string
469 for _, err := range m {
470 msgs = append(msgs, err.Error())
471 }
472 return strings.Join(msgs, "; ")
473 }
474
475 // AllErrors returns a list of validation violation errors.
476 func (m SelfConfigSourceMultiError) AllErrors() []error { return m }
477
478 // SelfConfigSourceValidationError is the validation error returned by
479 // SelfConfigSource.Validate if the designated constraints aren't met.
480 type SelfConfigSourceValidationError struct {
481 field string
482 reason string
483 cause error
484 key bool
485 }
486
487 // Field function returns field value.
488 func (e SelfConfigSourceValidationError) Field() string { return e.field }
489
490 // Reason function returns reason value.
491 func (e SelfConfigSourceValidationError) Reason() string { return e.reason }
492
493 // Cause function returns cause value.
494 func (e SelfConfigSourceValidationError) Cause() error { return e.cause }
495
496 // Key function returns key value.
497 func (e SelfConfigSourceValidationError) Key() bool { return e.key }
498
499 // ErrorName returns error name.
500 func (e SelfConfigSourceValidationError) ErrorName() string { return "SelfConfigSourceValidationError" }
501
502 // Error satisfies the builtin error interface
503 func (e SelfConfigSourceValidationError) 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 %sSelfConfigSource.%s: %s%s",
516 key,
517 e.field,
518 e.reason,
519 cause)
520 }
521
522 var _ error = SelfConfigSourceValidationError{}
523
524 var _ interface {
525 Field() string
526 Reason() string
527 Key() bool
528 Cause() error
529 ErrorName() string
530 } = SelfConfigSourceValidationError{}
531
532 // Validate checks the field values on RateLimitSettings with the rules defined
533 // in the proto definition for this message. If any rules are violated, the
534 // first error encountered is returned, or nil if there are no violations.
535 func (m *RateLimitSettings) Validate() error {
536 return m.validate(false)
537 }
538
539 // ValidateAll checks the field values on RateLimitSettings with the rules
540 // defined in the proto definition for this message. If any rules are
541 // violated, the result is a list of violation errors wrapped in
542 // RateLimitSettingsMultiError, or nil if none found.
543 func (m *RateLimitSettings) ValidateAll() error {
544 return m.validate(true)
545 }
546
547 func (m *RateLimitSettings) validate(all bool) error {
548 if m == nil {
549 return nil
550 }
551
552 var errors []error
553
554 if all {
555 switch v := interface{}(m.GetMaxTokens()).(type) {
556 case interface{ ValidateAll() error }:
557 if err := v.ValidateAll(); err != nil {
558 errors = append(errors, RateLimitSettingsValidationError{
559 field: "MaxTokens",
560 reason: "embedded message failed validation",
561 cause: err,
562 })
563 }
564 case interface{ Validate() error }:
565 if err := v.Validate(); err != nil {
566 errors = append(errors, RateLimitSettingsValidationError{
567 field: "MaxTokens",
568 reason: "embedded message failed validation",
569 cause: err,
570 })
571 }
572 }
573 } else if v, ok := interface{}(m.GetMaxTokens()).(interface{ Validate() error }); ok {
574 if err := v.Validate(); err != nil {
575 return RateLimitSettingsValidationError{
576 field: "MaxTokens",
577 reason: "embedded message failed validation",
578 cause: err,
579 }
580 }
581 }
582
583 if wrapper := m.GetFillRate(); wrapper != nil {
584
585 if wrapper.GetValue() <= 0 {
586 err := RateLimitSettingsValidationError{
587 field: "FillRate",
588 reason: "value must be greater than 0",
589 }
590 if !all {
591 return err
592 }
593 errors = append(errors, err)
594 }
595
596 }
597
598 if len(errors) > 0 {
599 return RateLimitSettingsMultiError(errors)
600 }
601
602 return nil
603 }
604
605 // RateLimitSettingsMultiError is an error wrapping multiple validation errors
606 // returned by RateLimitSettings.ValidateAll() if the designated constraints
607 // aren't met.
608 type RateLimitSettingsMultiError []error
609
610 // Error returns a concatenation of all the error messages it wraps.
611 func (m RateLimitSettingsMultiError) Error() string {
612 var msgs []string
613 for _, err := range m {
614 msgs = append(msgs, err.Error())
615 }
616 return strings.Join(msgs, "; ")
617 }
618
619 // AllErrors returns a list of validation violation errors.
620 func (m RateLimitSettingsMultiError) AllErrors() []error { return m }
621
622 // RateLimitSettingsValidationError is the validation error returned by
623 // RateLimitSettings.Validate if the designated constraints aren't met.
624 type RateLimitSettingsValidationError struct {
625 field string
626 reason string
627 cause error
628 key bool
629 }
630
631 // Field function returns field value.
632 func (e RateLimitSettingsValidationError) Field() string { return e.field }
633
634 // Reason function returns reason value.
635 func (e RateLimitSettingsValidationError) Reason() string { return e.reason }
636
637 // Cause function returns cause value.
638 func (e RateLimitSettingsValidationError) Cause() error { return e.cause }
639
640 // Key function returns key value.
641 func (e RateLimitSettingsValidationError) Key() bool { return e.key }
642
643 // ErrorName returns error name.
644 func (e RateLimitSettingsValidationError) ErrorName() string {
645 return "RateLimitSettingsValidationError"
646 }
647
648 // Error satisfies the builtin error interface
649 func (e RateLimitSettingsValidationError) Error() string {
650 cause := ""
651 if e.cause != nil {
652 cause = fmt.Sprintf(" | caused by: %v", e.cause)
653 }
654
655 key := ""
656 if e.key {
657 key = "key for "
658 }
659
660 return fmt.Sprintf(
661 "invalid %sRateLimitSettings.%s: %s%s",
662 key,
663 e.field,
664 e.reason,
665 cause)
666 }
667
668 var _ error = RateLimitSettingsValidationError{}
669
670 var _ interface {
671 Field() string
672 Reason() string
673 Key() bool
674 Cause() error
675 ErrorName() string
676 } = RateLimitSettingsValidationError{}
677
678 // Validate checks the field values on PathConfigSource with the rules defined
679 // in the proto definition for this message. If any rules are violated, the
680 // first error encountered is returned, or nil if there are no violations.
681 func (m *PathConfigSource) Validate() error {
682 return m.validate(false)
683 }
684
685 // ValidateAll checks the field values on PathConfigSource with the rules
686 // defined in the proto definition for this message. If any rules are
687 // violated, the result is a list of violation errors wrapped in
688 // PathConfigSourceMultiError, or nil if none found.
689 func (m *PathConfigSource) ValidateAll() error {
690 return m.validate(true)
691 }
692
693 func (m *PathConfigSource) validate(all bool) error {
694 if m == nil {
695 return nil
696 }
697
698 var errors []error
699
700 if utf8.RuneCountInString(m.GetPath()) < 1 {
701 err := PathConfigSourceValidationError{
702 field: "Path",
703 reason: "value length must be at least 1 runes",
704 }
705 if !all {
706 return err
707 }
708 errors = append(errors, err)
709 }
710
711 if all {
712 switch v := interface{}(m.GetWatchedDirectory()).(type) {
713 case interface{ ValidateAll() error }:
714 if err := v.ValidateAll(); err != nil {
715 errors = append(errors, PathConfigSourceValidationError{
716 field: "WatchedDirectory",
717 reason: "embedded message failed validation",
718 cause: err,
719 })
720 }
721 case interface{ Validate() error }:
722 if err := v.Validate(); err != nil {
723 errors = append(errors, PathConfigSourceValidationError{
724 field: "WatchedDirectory",
725 reason: "embedded message failed validation",
726 cause: err,
727 })
728 }
729 }
730 } else if v, ok := interface{}(m.GetWatchedDirectory()).(interface{ Validate() error }); ok {
731 if err := v.Validate(); err != nil {
732 return PathConfigSourceValidationError{
733 field: "WatchedDirectory",
734 reason: "embedded message failed validation",
735 cause: err,
736 }
737 }
738 }
739
740 if len(errors) > 0 {
741 return PathConfigSourceMultiError(errors)
742 }
743
744 return nil
745 }
746
747 // PathConfigSourceMultiError is an error wrapping multiple validation errors
748 // returned by PathConfigSource.ValidateAll() if the designated constraints
749 // aren't met.
750 type PathConfigSourceMultiError []error
751
752 // Error returns a concatenation of all the error messages it wraps.
753 func (m PathConfigSourceMultiError) Error() string {
754 var msgs []string
755 for _, err := range m {
756 msgs = append(msgs, err.Error())
757 }
758 return strings.Join(msgs, "; ")
759 }
760
761 // AllErrors returns a list of validation violation errors.
762 func (m PathConfigSourceMultiError) AllErrors() []error { return m }
763
764 // PathConfigSourceValidationError is the validation error returned by
765 // PathConfigSource.Validate if the designated constraints aren't met.
766 type PathConfigSourceValidationError struct {
767 field string
768 reason string
769 cause error
770 key bool
771 }
772
773 // Field function returns field value.
774 func (e PathConfigSourceValidationError) Field() string { return e.field }
775
776 // Reason function returns reason value.
777 func (e PathConfigSourceValidationError) Reason() string { return e.reason }
778
779 // Cause function returns cause value.
780 func (e PathConfigSourceValidationError) Cause() error { return e.cause }
781
782 // Key function returns key value.
783 func (e PathConfigSourceValidationError) Key() bool { return e.key }
784
785 // ErrorName returns error name.
786 func (e PathConfigSourceValidationError) ErrorName() string { return "PathConfigSourceValidationError" }
787
788 // Error satisfies the builtin error interface
789 func (e PathConfigSourceValidationError) Error() string {
790 cause := ""
791 if e.cause != nil {
792 cause = fmt.Sprintf(" | caused by: %v", e.cause)
793 }
794
795 key := ""
796 if e.key {
797 key = "key for "
798 }
799
800 return fmt.Sprintf(
801 "invalid %sPathConfigSource.%s: %s%s",
802 key,
803 e.field,
804 e.reason,
805 cause)
806 }
807
808 var _ error = PathConfigSourceValidationError{}
809
810 var _ interface {
811 Field() string
812 Reason() string
813 Key() bool
814 Cause() error
815 ErrorName() string
816 } = PathConfigSourceValidationError{}
817
818 // Validate checks the field values on ConfigSource with the rules defined in
819 // the proto definition for this message. If any rules are violated, the first
820 // error encountered is returned, or nil if there are no violations.
821 func (m *ConfigSource) Validate() error {
822 return m.validate(false)
823 }
824
825 // ValidateAll checks the field values on ConfigSource with the rules defined
826 // in the proto definition for this message. If any rules are violated, the
827 // result is a list of violation errors wrapped in ConfigSourceMultiError, or
828 // nil if none found.
829 func (m *ConfigSource) ValidateAll() error {
830 return m.validate(true)
831 }
832
833 func (m *ConfigSource) validate(all bool) error {
834 if m == nil {
835 return nil
836 }
837
838 var errors []error
839
840 for idx, item := range m.GetAuthorities() {
841 _, _ = idx, item
842
843 if all {
844 switch v := interface{}(item).(type) {
845 case interface{ ValidateAll() error }:
846 if err := v.ValidateAll(); err != nil {
847 errors = append(errors, ConfigSourceValidationError{
848 field: fmt.Sprintf("Authorities[%v]", idx),
849 reason: "embedded message failed validation",
850 cause: err,
851 })
852 }
853 case interface{ Validate() error }:
854 if err := v.Validate(); err != nil {
855 errors = append(errors, ConfigSourceValidationError{
856 field: fmt.Sprintf("Authorities[%v]", idx),
857 reason: "embedded message failed validation",
858 cause: err,
859 })
860 }
861 }
862 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
863 if err := v.Validate(); err != nil {
864 return ConfigSourceValidationError{
865 field: fmt.Sprintf("Authorities[%v]", idx),
866 reason: "embedded message failed validation",
867 cause: err,
868 }
869 }
870 }
871
872 }
873
874 if all {
875 switch v := interface{}(m.GetInitialFetchTimeout()).(type) {
876 case interface{ ValidateAll() error }:
877 if err := v.ValidateAll(); err != nil {
878 errors = append(errors, ConfigSourceValidationError{
879 field: "InitialFetchTimeout",
880 reason: "embedded message failed validation",
881 cause: err,
882 })
883 }
884 case interface{ Validate() error }:
885 if err := v.Validate(); err != nil {
886 errors = append(errors, ConfigSourceValidationError{
887 field: "InitialFetchTimeout",
888 reason: "embedded message failed validation",
889 cause: err,
890 })
891 }
892 }
893 } else if v, ok := interface{}(m.GetInitialFetchTimeout()).(interface{ Validate() error }); ok {
894 if err := v.Validate(); err != nil {
895 return ConfigSourceValidationError{
896 field: "InitialFetchTimeout",
897 reason: "embedded message failed validation",
898 cause: err,
899 }
900 }
901 }
902
903 if _, ok := ApiVersion_name[int32(m.GetResourceApiVersion())]; !ok {
904 err := ConfigSourceValidationError{
905 field: "ResourceApiVersion",
906 reason: "value must be one of the defined enum values",
907 }
908 if !all {
909 return err
910 }
911 errors = append(errors, err)
912 }
913
914 oneofConfigSourceSpecifierPresent := false
915 switch v := m.ConfigSourceSpecifier.(type) {
916 case *ConfigSource_Path:
917 if v == nil {
918 err := ConfigSourceValidationError{
919 field: "ConfigSourceSpecifier",
920 reason: "oneof value cannot be a typed-nil",
921 }
922 if !all {
923 return err
924 }
925 errors = append(errors, err)
926 }
927 oneofConfigSourceSpecifierPresent = true
928 // no validation rules for Path
929 case *ConfigSource_PathConfigSource:
930 if v == nil {
931 err := ConfigSourceValidationError{
932 field: "ConfigSourceSpecifier",
933 reason: "oneof value cannot be a typed-nil",
934 }
935 if !all {
936 return err
937 }
938 errors = append(errors, err)
939 }
940 oneofConfigSourceSpecifierPresent = true
941
942 if all {
943 switch v := interface{}(m.GetPathConfigSource()).(type) {
944 case interface{ ValidateAll() error }:
945 if err := v.ValidateAll(); err != nil {
946 errors = append(errors, ConfigSourceValidationError{
947 field: "PathConfigSource",
948 reason: "embedded message failed validation",
949 cause: err,
950 })
951 }
952 case interface{ Validate() error }:
953 if err := v.Validate(); err != nil {
954 errors = append(errors, ConfigSourceValidationError{
955 field: "PathConfigSource",
956 reason: "embedded message failed validation",
957 cause: err,
958 })
959 }
960 }
961 } else if v, ok := interface{}(m.GetPathConfigSource()).(interface{ Validate() error }); ok {
962 if err := v.Validate(); err != nil {
963 return ConfigSourceValidationError{
964 field: "PathConfigSource",
965 reason: "embedded message failed validation",
966 cause: err,
967 }
968 }
969 }
970
971 case *ConfigSource_ApiConfigSource:
972 if v == nil {
973 err := ConfigSourceValidationError{
974 field: "ConfigSourceSpecifier",
975 reason: "oneof value cannot be a typed-nil",
976 }
977 if !all {
978 return err
979 }
980 errors = append(errors, err)
981 }
982 oneofConfigSourceSpecifierPresent = true
983
984 if all {
985 switch v := interface{}(m.GetApiConfigSource()).(type) {
986 case interface{ ValidateAll() error }:
987 if err := v.ValidateAll(); err != nil {
988 errors = append(errors, ConfigSourceValidationError{
989 field: "ApiConfigSource",
990 reason: "embedded message failed validation",
991 cause: err,
992 })
993 }
994 case interface{ Validate() error }:
995 if err := v.Validate(); err != nil {
996 errors = append(errors, ConfigSourceValidationError{
997 field: "ApiConfigSource",
998 reason: "embedded message failed validation",
999 cause: err,
1000 })
1001 }
1002 }
1003 } else if v, ok := interface{}(m.GetApiConfigSource()).(interface{ Validate() error }); ok {
1004 if err := v.Validate(); err != nil {
1005 return ConfigSourceValidationError{
1006 field: "ApiConfigSource",
1007 reason: "embedded message failed validation",
1008 cause: err,
1009 }
1010 }
1011 }
1012
1013 case *ConfigSource_Ads:
1014 if v == nil {
1015 err := ConfigSourceValidationError{
1016 field: "ConfigSourceSpecifier",
1017 reason: "oneof value cannot be a typed-nil",
1018 }
1019 if !all {
1020 return err
1021 }
1022 errors = append(errors, err)
1023 }
1024 oneofConfigSourceSpecifierPresent = true
1025
1026 if all {
1027 switch v := interface{}(m.GetAds()).(type) {
1028 case interface{ ValidateAll() error }:
1029 if err := v.ValidateAll(); err != nil {
1030 errors = append(errors, ConfigSourceValidationError{
1031 field: "Ads",
1032 reason: "embedded message failed validation",
1033 cause: err,
1034 })
1035 }
1036 case interface{ Validate() error }:
1037 if err := v.Validate(); err != nil {
1038 errors = append(errors, ConfigSourceValidationError{
1039 field: "Ads",
1040 reason: "embedded message failed validation",
1041 cause: err,
1042 })
1043 }
1044 }
1045 } else if v, ok := interface{}(m.GetAds()).(interface{ Validate() error }); ok {
1046 if err := v.Validate(); err != nil {
1047 return ConfigSourceValidationError{
1048 field: "Ads",
1049 reason: "embedded message failed validation",
1050 cause: err,
1051 }
1052 }
1053 }
1054
1055 case *ConfigSource_Self:
1056 if v == nil {
1057 err := ConfigSourceValidationError{
1058 field: "ConfigSourceSpecifier",
1059 reason: "oneof value cannot be a typed-nil",
1060 }
1061 if !all {
1062 return err
1063 }
1064 errors = append(errors, err)
1065 }
1066 oneofConfigSourceSpecifierPresent = true
1067
1068 if all {
1069 switch v := interface{}(m.GetSelf()).(type) {
1070 case interface{ ValidateAll() error }:
1071 if err := v.ValidateAll(); err != nil {
1072 errors = append(errors, ConfigSourceValidationError{
1073 field: "Self",
1074 reason: "embedded message failed validation",
1075 cause: err,
1076 })
1077 }
1078 case interface{ Validate() error }:
1079 if err := v.Validate(); err != nil {
1080 errors = append(errors, ConfigSourceValidationError{
1081 field: "Self",
1082 reason: "embedded message failed validation",
1083 cause: err,
1084 })
1085 }
1086 }
1087 } else if v, ok := interface{}(m.GetSelf()).(interface{ Validate() error }); ok {
1088 if err := v.Validate(); err != nil {
1089 return ConfigSourceValidationError{
1090 field: "Self",
1091 reason: "embedded message failed validation",
1092 cause: err,
1093 }
1094 }
1095 }
1096
1097 default:
1098 _ = v // ensures v is used
1099 }
1100 if !oneofConfigSourceSpecifierPresent {
1101 err := ConfigSourceValidationError{
1102 field: "ConfigSourceSpecifier",
1103 reason: "value is required",
1104 }
1105 if !all {
1106 return err
1107 }
1108 errors = append(errors, err)
1109 }
1110
1111 if len(errors) > 0 {
1112 return ConfigSourceMultiError(errors)
1113 }
1114
1115 return nil
1116 }
1117
1118 // ConfigSourceMultiError is an error wrapping multiple validation errors
1119 // returned by ConfigSource.ValidateAll() if the designated constraints aren't met.
1120 type ConfigSourceMultiError []error
1121
1122 // Error returns a concatenation of all the error messages it wraps.
1123 func (m ConfigSourceMultiError) Error() string {
1124 var msgs []string
1125 for _, err := range m {
1126 msgs = append(msgs, err.Error())
1127 }
1128 return strings.Join(msgs, "; ")
1129 }
1130
1131 // AllErrors returns a list of validation violation errors.
1132 func (m ConfigSourceMultiError) AllErrors() []error { return m }
1133
1134 // ConfigSourceValidationError is the validation error returned by
1135 // ConfigSource.Validate if the designated constraints aren't met.
1136 type ConfigSourceValidationError struct {
1137 field string
1138 reason string
1139 cause error
1140 key bool
1141 }
1142
1143 // Field function returns field value.
1144 func (e ConfigSourceValidationError) Field() string { return e.field }
1145
1146 // Reason function returns reason value.
1147 func (e ConfigSourceValidationError) Reason() string { return e.reason }
1148
1149 // Cause function returns cause value.
1150 func (e ConfigSourceValidationError) Cause() error { return e.cause }
1151
1152 // Key function returns key value.
1153 func (e ConfigSourceValidationError) Key() bool { return e.key }
1154
1155 // ErrorName returns error name.
1156 func (e ConfigSourceValidationError) ErrorName() string { return "ConfigSourceValidationError" }
1157
1158 // Error satisfies the builtin error interface
1159 func (e ConfigSourceValidationError) Error() string {
1160 cause := ""
1161 if e.cause != nil {
1162 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1163 }
1164
1165 key := ""
1166 if e.key {
1167 key = "key for "
1168 }
1169
1170 return fmt.Sprintf(
1171 "invalid %sConfigSource.%s: %s%s",
1172 key,
1173 e.field,
1174 e.reason,
1175 cause)
1176 }
1177
1178 var _ error = ConfigSourceValidationError{}
1179
1180 var _ interface {
1181 Field() string
1182 Reason() string
1183 Key() bool
1184 Cause() error
1185 ErrorName() string
1186 } = ConfigSourceValidationError{}
1187
1188 // Validate checks the field values on ExtensionConfigSource with the rules
1189 // defined in the proto definition for this message. If any rules are
1190 // violated, the first error encountered is returned, or nil if there are no violations.
1191 func (m *ExtensionConfigSource) Validate() error {
1192 return m.validate(false)
1193 }
1194
1195 // ValidateAll checks the field values on ExtensionConfigSource with the rules
1196 // defined in the proto definition for this message. If any rules are
1197 // violated, the result is a list of violation errors wrapped in
1198 // ExtensionConfigSourceMultiError, or nil if none found.
1199 func (m *ExtensionConfigSource) ValidateAll() error {
1200 return m.validate(true)
1201 }
1202
1203 func (m *ExtensionConfigSource) validate(all bool) error {
1204 if m == nil {
1205 return nil
1206 }
1207
1208 var errors []error
1209
1210 if m.GetConfigSource() == nil {
1211 err := ExtensionConfigSourceValidationError{
1212 field: "ConfigSource",
1213 reason: "value is required",
1214 }
1215 if !all {
1216 return err
1217 }
1218 errors = append(errors, err)
1219 }
1220
1221 if a := m.GetConfigSource(); a != nil {
1222
1223 }
1224
1225 if all {
1226 switch v := interface{}(m.GetDefaultConfig()).(type) {
1227 case interface{ ValidateAll() error }:
1228 if err := v.ValidateAll(); err != nil {
1229 errors = append(errors, ExtensionConfigSourceValidationError{
1230 field: "DefaultConfig",
1231 reason: "embedded message failed validation",
1232 cause: err,
1233 })
1234 }
1235 case interface{ Validate() error }:
1236 if err := v.Validate(); err != nil {
1237 errors = append(errors, ExtensionConfigSourceValidationError{
1238 field: "DefaultConfig",
1239 reason: "embedded message failed validation",
1240 cause: err,
1241 })
1242 }
1243 }
1244 } else if v, ok := interface{}(m.GetDefaultConfig()).(interface{ Validate() error }); ok {
1245 if err := v.Validate(); err != nil {
1246 return ExtensionConfigSourceValidationError{
1247 field: "DefaultConfig",
1248 reason: "embedded message failed validation",
1249 cause: err,
1250 }
1251 }
1252 }
1253
1254 // no validation rules for ApplyDefaultConfigWithoutWarming
1255
1256 if len(m.GetTypeUrls()) < 1 {
1257 err := ExtensionConfigSourceValidationError{
1258 field: "TypeUrls",
1259 reason: "value must contain at least 1 item(s)",
1260 }
1261 if !all {
1262 return err
1263 }
1264 errors = append(errors, err)
1265 }
1266
1267 if len(errors) > 0 {
1268 return ExtensionConfigSourceMultiError(errors)
1269 }
1270
1271 return nil
1272 }
1273
1274 // ExtensionConfigSourceMultiError is an error wrapping multiple validation
1275 // errors returned by ExtensionConfigSource.ValidateAll() if the designated
1276 // constraints aren't met.
1277 type ExtensionConfigSourceMultiError []error
1278
1279 // Error returns a concatenation of all the error messages it wraps.
1280 func (m ExtensionConfigSourceMultiError) Error() string {
1281 var msgs []string
1282 for _, err := range m {
1283 msgs = append(msgs, err.Error())
1284 }
1285 return strings.Join(msgs, "; ")
1286 }
1287
1288 // AllErrors returns a list of validation violation errors.
1289 func (m ExtensionConfigSourceMultiError) AllErrors() []error { return m }
1290
1291 // ExtensionConfigSourceValidationError is the validation error returned by
1292 // ExtensionConfigSource.Validate if the designated constraints aren't met.
1293 type ExtensionConfigSourceValidationError struct {
1294 field string
1295 reason string
1296 cause error
1297 key bool
1298 }
1299
1300 // Field function returns field value.
1301 func (e ExtensionConfigSourceValidationError) Field() string { return e.field }
1302
1303 // Reason function returns reason value.
1304 func (e ExtensionConfigSourceValidationError) Reason() string { return e.reason }
1305
1306 // Cause function returns cause value.
1307 func (e ExtensionConfigSourceValidationError) Cause() error { return e.cause }
1308
1309 // Key function returns key value.
1310 func (e ExtensionConfigSourceValidationError) Key() bool { return e.key }
1311
1312 // ErrorName returns error name.
1313 func (e ExtensionConfigSourceValidationError) ErrorName() string {
1314 return "ExtensionConfigSourceValidationError"
1315 }
1316
1317 // Error satisfies the builtin error interface
1318 func (e ExtensionConfigSourceValidationError) Error() string {
1319 cause := ""
1320 if e.cause != nil {
1321 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1322 }
1323
1324 key := ""
1325 if e.key {
1326 key = "key for "
1327 }
1328
1329 return fmt.Sprintf(
1330 "invalid %sExtensionConfigSource.%s: %s%s",
1331 key,
1332 e.field,
1333 e.reason,
1334 cause)
1335 }
1336
1337 var _ error = ExtensionConfigSourceValidationError{}
1338
1339 var _ interface {
1340 Field() string
1341 Reason() string
1342 Key() bool
1343 Cause() error
1344 ErrorName() string
1345 } = ExtensionConfigSourceValidationError{}