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