Debian Codegraph @

envoy/config/route/v3/route.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/route/v3/route.proto
4
5 package routev3
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 RouteConfiguration with the rules
40 // defined in the proto definition for this message. If any rules are
41 // violated, the first error encountered is returned, or nil if there are no violations.
42 func (m *RouteConfiguration) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on RouteConfiguration 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 // RouteConfigurationMultiError, or nil if none found.
50 func (m *RouteConfiguration) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *RouteConfiguration) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 // no validation rules for Name
62
63 for idx, item := range m.GetVirtualHosts() {
64 _, _ = idx, item
65
66 if all {
67 switch v := interface{}(item).(type) {
68 case interface{ ValidateAll() error }:
69 if err := v.ValidateAll(); err != nil {
70 errors = append(errors, RouteConfigurationValidationError{
71 field: fmt.Sprintf("VirtualHosts[%v]", idx),
72 reason: "embedded message failed validation",
73 cause: err,
74 })
75 }
76 case interface{ Validate() error }:
77 if err := v.Validate(); err != nil {
78 errors = append(errors, RouteConfigurationValidationError{
79 field: fmt.Sprintf("VirtualHosts[%v]", idx),
80 reason: "embedded message failed validation",
81 cause: err,
82 })
83 }
84 }
85 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
86 if err := v.Validate(); err != nil {
87 return RouteConfigurationValidationError{
88 field: fmt.Sprintf("VirtualHosts[%v]", idx),
89 reason: "embedded message failed validation",
90 cause: err,
91 }
92 }
93 }
94
95 }
96
97 if all {
98 switch v := interface{}(m.GetVhds()).(type) {
99 case interface{ ValidateAll() error }:
100 if err := v.ValidateAll(); err != nil {
101 errors = append(errors, RouteConfigurationValidationError{
102 field: "Vhds",
103 reason: "embedded message failed validation",
104 cause: err,
105 })
106 }
107 case interface{ Validate() error }:
108 if err := v.Validate(); err != nil {
109 errors = append(errors, RouteConfigurationValidationError{
110 field: "Vhds",
111 reason: "embedded message failed validation",
112 cause: err,
113 })
114 }
115 }
116 } else if v, ok := interface{}(m.GetVhds()).(interface{ Validate() error }); ok {
117 if err := v.Validate(); err != nil {
118 return RouteConfigurationValidationError{
119 field: "Vhds",
120 reason: "embedded message failed validation",
121 cause: err,
122 }
123 }
124 }
125
126 for idx, item := range m.GetInternalOnlyHeaders() {
127 _, _ = idx, item
128
129 if !_RouteConfiguration_InternalOnlyHeaders_Pattern.MatchString(item) {
130 err := RouteConfigurationValidationError{
131 field: fmt.Sprintf("InternalOnlyHeaders[%v]", idx),
132 reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
133 }
134 if !all {
135 return err
136 }
137 errors = append(errors, err)
138 }
139
140 }
141
142 if len(m.GetResponseHeadersToAdd()) > 1000 {
143 err := RouteConfigurationValidationError{
144 field: "ResponseHeadersToAdd",
145 reason: "value must contain no more than 1000 item(s)",
146 }
147 if !all {
148 return err
149 }
150 errors = append(errors, err)
151 }
152
153 for idx, item := range m.GetResponseHeadersToAdd() {
154 _, _ = idx, item
155
156 if all {
157 switch v := interface{}(item).(type) {
158 case interface{ ValidateAll() error }:
159 if err := v.ValidateAll(); err != nil {
160 errors = append(errors, RouteConfigurationValidationError{
161 field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
162 reason: "embedded message failed validation",
163 cause: err,
164 })
165 }
166 case interface{ Validate() error }:
167 if err := v.Validate(); err != nil {
168 errors = append(errors, RouteConfigurationValidationError{
169 field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
170 reason: "embedded message failed validation",
171 cause: err,
172 })
173 }
174 }
175 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
176 if err := v.Validate(); err != nil {
177 return RouteConfigurationValidationError{
178 field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
179 reason: "embedded message failed validation",
180 cause: err,
181 }
182 }
183 }
184
185 }
186
187 for idx, item := range m.GetResponseHeadersToRemove() {
188 _, _ = idx, item
189
190 if !_RouteConfiguration_ResponseHeadersToRemove_Pattern.MatchString(item) {
191 err := RouteConfigurationValidationError{
192 field: fmt.Sprintf("ResponseHeadersToRemove[%v]", idx),
193 reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
194 }
195 if !all {
196 return err
197 }
198 errors = append(errors, err)
199 }
200
201 }
202
203 if len(m.GetRequestHeadersToAdd()) > 1000 {
204 err := RouteConfigurationValidationError{
205 field: "RequestHeadersToAdd",
206 reason: "value must contain no more than 1000 item(s)",
207 }
208 if !all {
209 return err
210 }
211 errors = append(errors, err)
212 }
213
214 for idx, item := range m.GetRequestHeadersToAdd() {
215 _, _ = idx, item
216
217 if all {
218 switch v := interface{}(item).(type) {
219 case interface{ ValidateAll() error }:
220 if err := v.ValidateAll(); err != nil {
221 errors = append(errors, RouteConfigurationValidationError{
222 field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
223 reason: "embedded message failed validation",
224 cause: err,
225 })
226 }
227 case interface{ Validate() error }:
228 if err := v.Validate(); err != nil {
229 errors = append(errors, RouteConfigurationValidationError{
230 field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
231 reason: "embedded message failed validation",
232 cause: err,
233 })
234 }
235 }
236 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
237 if err := v.Validate(); err != nil {
238 return RouteConfigurationValidationError{
239 field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
240 reason: "embedded message failed validation",
241 cause: err,
242 }
243 }
244 }
245
246 }
247
248 for idx, item := range m.GetRequestHeadersToRemove() {
249 _, _ = idx, item
250
251 if !_RouteConfiguration_RequestHeadersToRemove_Pattern.MatchString(item) {
252 err := RouteConfigurationValidationError{
253 field: fmt.Sprintf("RequestHeadersToRemove[%v]", idx),
254 reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
255 }
256 if !all {
257 return err
258 }
259 errors = append(errors, err)
260 }
261
262 }
263
264 // no validation rules for MostSpecificHeaderMutationsWins
265
266 if all {
267 switch v := interface{}(m.GetValidateClusters()).(type) {
268 case interface{ ValidateAll() error }:
269 if err := v.ValidateAll(); err != nil {
270 errors = append(errors, RouteConfigurationValidationError{
271 field: "ValidateClusters",
272 reason: "embedded message failed validation",
273 cause: err,
274 })
275 }
276 case interface{ Validate() error }:
277 if err := v.Validate(); err != nil {
278 errors = append(errors, RouteConfigurationValidationError{
279 field: "ValidateClusters",
280 reason: "embedded message failed validation",
281 cause: err,
282 })
283 }
284 }
285 } else if v, ok := interface{}(m.GetValidateClusters()).(interface{ Validate() error }); ok {
286 if err := v.Validate(); err != nil {
287 return RouteConfigurationValidationError{
288 field: "ValidateClusters",
289 reason: "embedded message failed validation",
290 cause: err,
291 }
292 }
293 }
294
295 if all {
296 switch v := interface{}(m.GetMaxDirectResponseBodySizeBytes()).(type) {
297 case interface{ ValidateAll() error }:
298 if err := v.ValidateAll(); err != nil {
299 errors = append(errors, RouteConfigurationValidationError{
300 field: "MaxDirectResponseBodySizeBytes",
301 reason: "embedded message failed validation",
302 cause: err,
303 })
304 }
305 case interface{ Validate() error }:
306 if err := v.Validate(); err != nil {
307 errors = append(errors, RouteConfigurationValidationError{
308 field: "MaxDirectResponseBodySizeBytes",
309 reason: "embedded message failed validation",
310 cause: err,
311 })
312 }
313 }
314 } else if v, ok := interface{}(m.GetMaxDirectResponseBodySizeBytes()).(interface{ Validate() error }); ok {
315 if err := v.Validate(); err != nil {
316 return RouteConfigurationValidationError{
317 field: "MaxDirectResponseBodySizeBytes",
318 reason: "embedded message failed validation",
319 cause: err,
320 }
321 }
322 }
323
324 for idx, item := range m.GetClusterSpecifierPlugins() {
325 _, _ = idx, item
326
327 if all {
328 switch v := interface{}(item).(type) {
329 case interface{ ValidateAll() error }:
330 if err := v.ValidateAll(); err != nil {
331 errors = append(errors, RouteConfigurationValidationError{
332 field: fmt.Sprintf("ClusterSpecifierPlugins[%v]", idx),
333 reason: "embedded message failed validation",
334 cause: err,
335 })
336 }
337 case interface{ Validate() error }:
338 if err := v.Validate(); err != nil {
339 errors = append(errors, RouteConfigurationValidationError{
340 field: fmt.Sprintf("ClusterSpecifierPlugins[%v]", idx),
341 reason: "embedded message failed validation",
342 cause: err,
343 })
344 }
345 }
346 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
347 if err := v.Validate(); err != nil {
348 return RouteConfigurationValidationError{
349 field: fmt.Sprintf("ClusterSpecifierPlugins[%v]", idx),
350 reason: "embedded message failed validation",
351 cause: err,
352 }
353 }
354 }
355
356 }
357
358 for idx, item := range m.GetRequestMirrorPolicies() {
359 _, _ = idx, item
360
361 if all {
362 switch v := interface{}(item).(type) {
363 case interface{ ValidateAll() error }:
364 if err := v.ValidateAll(); err != nil {
365 errors = append(errors, RouteConfigurationValidationError{
366 field: fmt.Sprintf("RequestMirrorPolicies[%v]", idx),
367 reason: "embedded message failed validation",
368 cause: err,
369 })
370 }
371 case interface{ Validate() error }:
372 if err := v.Validate(); err != nil {
373 errors = append(errors, RouteConfigurationValidationError{
374 field: fmt.Sprintf("RequestMirrorPolicies[%v]", idx),
375 reason: "embedded message failed validation",
376 cause: err,
377 })
378 }
379 }
380 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
381 if err := v.Validate(); err != nil {
382 return RouteConfigurationValidationError{
383 field: fmt.Sprintf("RequestMirrorPolicies[%v]", idx),
384 reason: "embedded message failed validation",
385 cause: err,
386 }
387 }
388 }
389
390 }
391
392 // no validation rules for IgnorePortInHostMatching
393
394 // no validation rules for IgnorePathParametersInPathMatching
395
396 {
397 sorted_keys := make([]string, len(m.GetTypedPerFilterConfig()))
398 i := 0
399 for key := range m.GetTypedPerFilterConfig() {
400 sorted_keys[i] = key
401 i++
402 }
403 sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
404 for _, key := range sorted_keys {
405 val := m.GetTypedPerFilterConfig()[key]
406 _ = val
407
408 // no validation rules for TypedPerFilterConfig[key]
409
410 if all {
411 switch v := interface{}(val).(type) {
412 case interface{ ValidateAll() error }:
413 if err := v.ValidateAll(); err != nil {
414 errors = append(errors, RouteConfigurationValidationError{
415 field: fmt.Sprintf("TypedPerFilterConfig[%v]", key),
416 reason: "embedded message failed validation",
417 cause: err,
418 })
419 }
420 case interface{ Validate() error }:
421 if err := v.Validate(); err != nil {
422 errors = append(errors, RouteConfigurationValidationError{
423 field: fmt.Sprintf("TypedPerFilterConfig[%v]", key),
424 reason: "embedded message failed validation",
425 cause: err,
426 })
427 }
428 }
429 } else if v, ok := interface{}(val).(interface{ Validate() error }); ok {
430 if err := v.Validate(); err != nil {
431 return RouteConfigurationValidationError{
432 field: fmt.Sprintf("TypedPerFilterConfig[%v]", key),
433 reason: "embedded message failed validation",
434 cause: err,
435 }
436 }
437 }
438
439 }
440 }
441
442 if all {
443 switch v := interface{}(m.GetMetadata()).(type) {
444 case interface{ ValidateAll() error }:
445 if err := v.ValidateAll(); err != nil {
446 errors = append(errors, RouteConfigurationValidationError{
447 field: "Metadata",
448 reason: "embedded message failed validation",
449 cause: err,
450 })
451 }
452 case interface{ Validate() error }:
453 if err := v.Validate(); err != nil {
454 errors = append(errors, RouteConfigurationValidationError{
455 field: "Metadata",
456 reason: "embedded message failed validation",
457 cause: err,
458 })
459 }
460 }
461 } else if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
462 if err := v.Validate(); err != nil {
463 return RouteConfigurationValidationError{
464 field: "Metadata",
465 reason: "embedded message failed validation",
466 cause: err,
467 }
468 }
469 }
470
471 if len(errors) > 0 {
472 return RouteConfigurationMultiError(errors)
473 }
474
475 return nil
476 }
477
478 // RouteConfigurationMultiError is an error wrapping multiple validation errors
479 // returned by RouteConfiguration.ValidateAll() if the designated constraints
480 // aren't met.
481 type RouteConfigurationMultiError []error
482
483 // Error returns a concatenation of all the error messages it wraps.
484 func (m RouteConfigurationMultiError) Error() string {
485 var msgs []string
486 for _, err := range m {
487 msgs = append(msgs, err.Error())
488 }
489 return strings.Join(msgs, "; ")
490 }
491
492 // AllErrors returns a list of validation violation errors.
493 func (m RouteConfigurationMultiError) AllErrors() []error { return m }
494
495 // RouteConfigurationValidationError is the validation error returned by
496 // RouteConfiguration.Validate if the designated constraints aren't met.
497 type RouteConfigurationValidationError struct {
498 field string
499 reason string
500 cause error
501 key bool
502 }
503
504 // Field function returns field value.
505 func (e RouteConfigurationValidationError) Field() string { return e.field }
506
507 // Reason function returns reason value.
508 func (e RouteConfigurationValidationError) Reason() string { return e.reason }
509
510 // Cause function returns cause value.
511 func (e RouteConfigurationValidationError) Cause() error { return e.cause }
512
513 // Key function returns key value.
514 func (e RouteConfigurationValidationError) Key() bool { return e.key }
515
516 // ErrorName returns error name.
517 func (e RouteConfigurationValidationError) ErrorName() string {
518 return "RouteConfigurationValidationError"
519 }
520
521 // Error satisfies the builtin error interface
522 func (e RouteConfigurationValidationError) Error() string {
523 cause := ""
524 if e.cause != nil {
525 cause = fmt.Sprintf(" | caused by: %v", e.cause)
526 }
527
528 key := ""
529 if e.key {
530 key = "key for "
531 }
532
533 return fmt.Sprintf(
534 "invalid %sRouteConfiguration.%s: %s%s",
535 key,
536 e.field,
537 e.reason,
538 cause)
539 }
540
541 var _ error = RouteConfigurationValidationError{}
542
543 var _ interface {
544 Field() string
545 Reason() string
546 Key() bool
547 Cause() error
548 ErrorName() string
549 } = RouteConfigurationValidationError{}
550
551 var _RouteConfiguration_InternalOnlyHeaders_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
552
553 var _RouteConfiguration_ResponseHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
554
555 var _RouteConfiguration_RequestHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
556
557 // Validate checks the field values on Vhds with the rules defined in the proto
558 // definition for this message. If any rules are violated, the first error
559 // encountered is returned, or nil if there are no violations.
560 func (m *Vhds) Validate() error {
561 return m.validate(false)
562 }
563
564 // ValidateAll checks the field values on Vhds with the rules defined in the
565 // proto definition for this message. If any rules are violated, the result is
566 // a list of violation errors wrapped in VhdsMultiError, or nil if none found.
567 func (m *Vhds) ValidateAll() error {
568 return m.validate(true)
569 }
570
571 func (m *Vhds) validate(all bool) error {
572 if m == nil {
573 return nil
574 }
575
576 var errors []error
577
578 if m.GetConfigSource() == nil {
579 err := VhdsValidationError{
580 field: "ConfigSource",
581 reason: "value is required",
582 }
583 if !all {
584 return err
585 }
586 errors = append(errors, err)
587 }
588
589 if all {
590 switch v := interface{}(m.GetConfigSource()).(type) {
591 case interface{ ValidateAll() error }:
592 if err := v.ValidateAll(); err != nil {
593 errors = append(errors, VhdsValidationError{
594 field: "ConfigSource",
595 reason: "embedded message failed validation",
596 cause: err,
597 })
598 }
599 case interface{ Validate() error }:
600 if err := v.Validate(); err != nil {
601 errors = append(errors, VhdsValidationError{
602 field: "ConfigSource",
603 reason: "embedded message failed validation",
604 cause: err,
605 })
606 }
607 }
608 } else if v, ok := interface{}(m.GetConfigSource()).(interface{ Validate() error }); ok {
609 if err := v.Validate(); err != nil {
610 return VhdsValidationError{
611 field: "ConfigSource",
612 reason: "embedded message failed validation",
613 cause: err,
614 }
615 }
616 }
617
618 if len(errors) > 0 {
619 return VhdsMultiError(errors)
620 }
621
622 return nil
623 }
624
625 // VhdsMultiError is an error wrapping multiple validation errors returned by
626 // Vhds.ValidateAll() if the designated constraints aren't met.
627 type VhdsMultiError []error
628
629 // Error returns a concatenation of all the error messages it wraps.
630 func (m VhdsMultiError) Error() string {
631 var msgs []string
632 for _, err := range m {
633 msgs = append(msgs, err.Error())
634 }
635 return strings.Join(msgs, "; ")
636 }
637
638 // AllErrors returns a list of validation violation errors.
639 func (m VhdsMultiError) AllErrors() []error { return m }
640
641 // VhdsValidationError is the validation error returned by Vhds.Validate if the
642 // designated constraints aren't met.
643 type VhdsValidationError struct {
644 field string
645 reason string
646 cause error
647 key bool
648 }
649
650 // Field function returns field value.
651 func (e VhdsValidationError) Field() string { return e.field }
652
653 // Reason function returns reason value.
654 func (e VhdsValidationError) Reason() string { return e.reason }
655
656 // Cause function returns cause value.
657 func (e VhdsValidationError) Cause() error { return e.cause }
658
659 // Key function returns key value.
660 func (e VhdsValidationError) Key() bool { return e.key }
661
662 // ErrorName returns error name.
663 func (e VhdsValidationError) ErrorName() string { return "VhdsValidationError" }
664
665 // Error satisfies the builtin error interface
666 func (e VhdsValidationError) Error() string {
667 cause := ""
668 if e.cause != nil {
669 cause = fmt.Sprintf(" | caused by: %v", e.cause)
670 }
671
672 key := ""
673 if e.key {
674 key = "key for "
675 }
676
677 return fmt.Sprintf(
678 "invalid %sVhds.%s: %s%s",
679 key,
680 e.field,
681 e.reason,
682 cause)
683 }
684
685 var _ error = VhdsValidationError{}
686
687 var _ interface {
688 Field() string
689 Reason() string
690 Key() bool
691 Cause() error
692 ErrorName() string
693 } = VhdsValidationError{}