Debian Codegraph @

envoy/config/cluster/v3/circuit_breaker.pb.validate.go

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