Debian Codegraph @

envoy/extensions/common/dynamic_forward_proxy/v3/dns_cache.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/common/dynamic_forward_proxy/v3/dns_cache.proto
4
5 package dynamic_forward_proxyv3
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/cluster/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.Cluster_DnsLookupFamily(0)
41 )
42
43 // Validate checks the field values on DnsCacheCircuitBreakers with the rules
44 // defined in the proto definition for this message. If any rules are
45 // violated, the first error encountered is returned, or nil if there are no violations.
46 func (m *DnsCacheCircuitBreakers) Validate() error {
47 return m.validate(false)
48 }
49
50 // ValidateAll checks the field values on DnsCacheCircuitBreakers with the
51 // rules 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 // DnsCacheCircuitBreakersMultiError, or nil if none found.
54 func (m *DnsCacheCircuitBreakers) ValidateAll() error {
55 return m.validate(true)
56 }
57
58 func (m *DnsCacheCircuitBreakers) validate(all bool) error {
59 if m == nil {
60 return nil
61 }
62
63 var errors []error
64
65 if all {
66 switch v := interface{}(m.GetMaxPendingRequests()).(type) {
67 case interface{ ValidateAll() error }:
68 if err := v.ValidateAll(); err != nil {
69 errors = append(errors, DnsCacheCircuitBreakersValidationError{
70 field: "MaxPendingRequests",
71 reason: "embedded message failed validation",
72 cause: err,
73 })
74 }
75 case interface{ Validate() error }:
76 if err := v.Validate(); err != nil {
77 errors = append(errors, DnsCacheCircuitBreakersValidationError{
78 field: "MaxPendingRequests",
79 reason: "embedded message failed validation",
80 cause: err,
81 })
82 }
83 }
84 } else if v, ok := interface{}(m.GetMaxPendingRequests()).(interface{ Validate() error }); ok {
85 if err := v.Validate(); err != nil {
86 return DnsCacheCircuitBreakersValidationError{
87 field: "MaxPendingRequests",
88 reason: "embedded message failed validation",
89 cause: err,
90 }
91 }
92 }
93
94 if len(errors) > 0 {
95 return DnsCacheCircuitBreakersMultiError(errors)
96 }
97
98 return nil
99 }
100
101 // DnsCacheCircuitBreakersMultiError is an error wrapping multiple validation
102 // errors returned by DnsCacheCircuitBreakers.ValidateAll() if the designated
103 // constraints aren't met.
104 type DnsCacheCircuitBreakersMultiError []error
105
106 // Error returns a concatenation of all the error messages it wraps.
107 func (m DnsCacheCircuitBreakersMultiError) Error() string {
108 var msgs []string
109 for _, err := range m {
110 msgs = append(msgs, err.Error())
111 }
112 return strings.Join(msgs, "; ")
113 }
114
115 // AllErrors returns a list of validation violation errors.
116 func (m DnsCacheCircuitBreakersMultiError) AllErrors() []error { return m }
117
118 // DnsCacheCircuitBreakersValidationError is the validation error returned by
119 // DnsCacheCircuitBreakers.Validate if the designated constraints aren't met.
120 type DnsCacheCircuitBreakersValidationError struct {
121 field string
122 reason string
123 cause error
124 key bool
125 }
126
127 // Field function returns field value.
128 func (e DnsCacheCircuitBreakersValidationError) Field() string { return e.field }
129
130 // Reason function returns reason value.
131 func (e DnsCacheCircuitBreakersValidationError) Reason() string { return e.reason }
132
133 // Cause function returns cause value.
134 func (e DnsCacheCircuitBreakersValidationError) Cause() error { return e.cause }
135
136 // Key function returns key value.
137 func (e DnsCacheCircuitBreakersValidationError) Key() bool { return e.key }
138
139 // ErrorName returns error name.
140 func (e DnsCacheCircuitBreakersValidationError) ErrorName() string {
141 return "DnsCacheCircuitBreakersValidationError"
142 }
143
144 // Error satisfies the builtin error interface
145 func (e DnsCacheCircuitBreakersValidationError) Error() string {
146 cause := ""
147 if e.cause != nil {
148 cause = fmt.Sprintf(" | caused by: %v", e.cause)
149 }
150
151 key := ""
152 if e.key {
153 key = "key for "
154 }
155
156 return fmt.Sprintf(
157 "invalid %sDnsCacheCircuitBreakers.%s: %s%s",
158 key,
159 e.field,
160 e.reason,
161 cause)
162 }
163
164 var _ error = DnsCacheCircuitBreakersValidationError{}
165
166 var _ interface {
167 Field() string
168 Reason() string
169 Key() bool
170 Cause() error
171 ErrorName() string
172 } = DnsCacheCircuitBreakersValidationError{}
173
174 // Validate checks the field values on DnsCacheConfig with the rules defined in
175 // the proto definition for this message. If any rules are violated, the first
176 // error encountered is returned, or nil if there are no violations.
177 func (m *DnsCacheConfig) Validate() error {
178 return m.validate(false)
179 }
180
181 // ValidateAll checks the field values on DnsCacheConfig with the rules defined
182 // in the proto definition for this message. If any rules are violated, the
183 // result is a list of violation errors wrapped in DnsCacheConfigMultiError,
184 // or nil if none found.
185 func (m *DnsCacheConfig) ValidateAll() error {
186 return m.validate(true)
187 }
188
189 func (m *DnsCacheConfig) validate(all bool) error {
190 if m == nil {
191 return nil
192 }
193
194 var errors []error
195
196 if utf8.RuneCountInString(m.GetName()) < 1 {
197 err := DnsCacheConfigValidationError{
198 field: "Name",
199 reason: "value length must be at least 1 runes",
200 }
201 if !all {
202 return err
203 }
204 errors = append(errors, err)
205 }
206
207 if _, ok := v3.Cluster_DnsLookupFamily_name[int32(m.GetDnsLookupFamily())]; !ok {
208 err := DnsCacheConfigValidationError{
209 field: "DnsLookupFamily",
210 reason: "value must be one of the defined enum values",
211 }
212 if !all {
213 return err
214 }
215 errors = append(errors, err)
216 }
217
218 if d := m.GetDnsRefreshRate(); d != nil {
219 dur, err := d.AsDuration(), d.CheckValid()
220 if err != nil {
221 err = DnsCacheConfigValidationError{
222 field: "DnsRefreshRate",
223 reason: "value is not a valid duration",
224 cause: err,
225 }
226 if !all {
227 return err
228 }
229 errors = append(errors, err)
230 } else {
231
232 gte := time.Duration(0*time.Second + 1000000*time.Nanosecond)
233
234 if dur < gte {
235 err := DnsCacheConfigValidationError{
236 field: "DnsRefreshRate",
237 reason: "value must be greater than or equal to 1ms",
238 }
239 if !all {
240 return err
241 }
242 errors = append(errors, err)
243 }
244
245 }
246 }
247
248 if d := m.GetDnsMinRefreshRate(); d != nil {
249 dur, err := d.AsDuration(), d.CheckValid()
250 if err != nil {
251 err = DnsCacheConfigValidationError{
252 field: "DnsMinRefreshRate",
253 reason: "value is not a valid duration",
254 cause: err,
255 }
256 if !all {
257 return err
258 }
259 errors = append(errors, err)
260 } else {
261
262 gte := time.Duration(1*time.Second + 0*time.Nanosecond)
263
264 if dur < gte {
265 err := DnsCacheConfigValidationError{
266 field: "DnsMinRefreshRate",
267 reason: "value must be greater than or equal to 1s",
268 }
269 if !all {
270 return err
271 }
272 errors = append(errors, err)
273 }
274
275 }
276 }
277
278 if d := m.GetHostTtl(); d != nil {
279 dur, err := d.AsDuration(), d.CheckValid()
280 if err != nil {
281 err = DnsCacheConfigValidationError{
282 field: "HostTtl",
283 reason: "value is not a valid duration",
284 cause: err,
285 }
286 if !all {
287 return err
288 }
289 errors = append(errors, err)
290 } else {
291
292 gt := time.Duration(0*time.Second + 0*time.Nanosecond)
293
294 if dur <= gt {
295 err := DnsCacheConfigValidationError{
296 field: "HostTtl",
297 reason: "value must be greater than 0s",
298 }
299 if !all {
300 return err
301 }
302 errors = append(errors, err)
303 }
304
305 }
306 }
307
308 if wrapper := m.GetMaxHosts(); wrapper != nil {
309
310 if wrapper.GetValue() <= 0 {
311 err := DnsCacheConfigValidationError{
312 field: "MaxHosts",
313 reason: "value must be greater than 0",
314 }
315 if !all {
316 return err
317 }
318 errors = append(errors, err)
319 }
320
321 }
322
323 if all {
324 switch v := interface{}(m.GetDnsFailureRefreshRate()).(type) {
325 case interface{ ValidateAll() error }:
326 if err := v.ValidateAll(); err != nil {
327 errors = append(errors, DnsCacheConfigValidationError{
328 field: "DnsFailureRefreshRate",
329 reason: "embedded message failed validation",
330 cause: err,
331 })
332 }
333 case interface{ Validate() error }:
334 if err := v.Validate(); err != nil {
335 errors = append(errors, DnsCacheConfigValidationError{
336 field: "DnsFailureRefreshRate",
337 reason: "embedded message failed validation",
338 cause: err,
339 })
340 }
341 }
342 } else if v, ok := interface{}(m.GetDnsFailureRefreshRate()).(interface{ Validate() error }); ok {
343 if err := v.Validate(); err != nil {
344 return DnsCacheConfigValidationError{
345 field: "DnsFailureRefreshRate",
346 reason: "embedded message failed validation",
347 cause: err,
348 }
349 }
350 }
351
352 if all {
353 switch v := interface{}(m.GetDnsCacheCircuitBreaker()).(type) {
354 case interface{ ValidateAll() error }:
355 if err := v.ValidateAll(); err != nil {
356 errors = append(errors, DnsCacheConfigValidationError{
357 field: "DnsCacheCircuitBreaker",
358 reason: "embedded message failed validation",
359 cause: err,
360 })
361 }
362 case interface{ Validate() error }:
363 if err := v.Validate(); err != nil {
364 errors = append(errors, DnsCacheConfigValidationError{
365 field: "DnsCacheCircuitBreaker",
366 reason: "embedded message failed validation",
367 cause: err,
368 })
369 }
370 }
371 } else if v, ok := interface{}(m.GetDnsCacheCircuitBreaker()).(interface{ Validate() error }); ok {
372 if err := v.Validate(); err != nil {
373 return DnsCacheConfigValidationError{
374 field: "DnsCacheCircuitBreaker",
375 reason: "embedded message failed validation",
376 cause: err,
377 }
378 }
379 }
380
381 // no validation rules for UseTcpForDnsLookups
382
383 if all {
384 switch v := interface{}(m.GetDnsResolutionConfig()).(type) {
385 case interface{ ValidateAll() error }:
386 if err := v.ValidateAll(); err != nil {
387 errors = append(errors, DnsCacheConfigValidationError{
388 field: "DnsResolutionConfig",
389 reason: "embedded message failed validation",
390 cause: err,
391 })
392 }
393 case interface{ Validate() error }:
394 if err := v.Validate(); err != nil {
395 errors = append(errors, DnsCacheConfigValidationError{
396 field: "DnsResolutionConfig",
397 reason: "embedded message failed validation",
398 cause: err,
399 })
400 }
401 }
402 } else if v, ok := interface{}(m.GetDnsResolutionConfig()).(interface{ Validate() error }); ok {
403 if err := v.Validate(); err != nil {
404 return DnsCacheConfigValidationError{
405 field: "DnsResolutionConfig",
406 reason: "embedded message failed validation",
407 cause: err,
408 }
409 }
410 }
411
412 if all {
413 switch v := interface{}(m.GetTypedDnsResolverConfig()).(type) {
414 case interface{ ValidateAll() error }:
415 if err := v.ValidateAll(); err != nil {
416 errors = append(errors, DnsCacheConfigValidationError{
417 field: "TypedDnsResolverConfig",
418 reason: "embedded message failed validation",
419 cause: err,
420 })
421 }
422 case interface{ Validate() error }:
423 if err := v.Validate(); err != nil {
424 errors = append(errors, DnsCacheConfigValidationError{
425 field: "TypedDnsResolverConfig",
426 reason: "embedded message failed validation",
427 cause: err,
428 })
429 }
430 }
431 } else if v, ok := interface{}(m.GetTypedDnsResolverConfig()).(interface{ Validate() error }); ok {
432 if err := v.Validate(); err != nil {
433 return DnsCacheConfigValidationError{
434 field: "TypedDnsResolverConfig",
435 reason: "embedded message failed validation",
436 cause: err,
437 }
438 }
439 }
440
441 for idx, item := range m.GetPreresolveHostnames() {
442 _, _ = idx, item
443
444 if all {
445 switch v := interface{}(item).(type) {
446 case interface{ ValidateAll() error }:
447 if err := v.ValidateAll(); err != nil {
448 errors = append(errors, DnsCacheConfigValidationError{
449 field: fmt.Sprintf("PreresolveHostnames[%v]", idx),
450 reason: "embedded message failed validation",
451 cause: err,
452 })
453 }
454 case interface{ Validate() error }:
455 if err := v.Validate(); err != nil {
456 errors = append(errors, DnsCacheConfigValidationError{
457 field: fmt.Sprintf("PreresolveHostnames[%v]", idx),
458 reason: "embedded message failed validation",
459 cause: err,
460 })
461 }
462 }
463 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
464 if err := v.Validate(); err != nil {
465 return DnsCacheConfigValidationError{
466 field: fmt.Sprintf("PreresolveHostnames[%v]", idx),
467 reason: "embedded message failed validation",
468 cause: err,
469 }
470 }
471 }
472
473 }
474
475 if d := m.GetDnsQueryTimeout(); d != nil {
476 dur, err := d.AsDuration(), d.CheckValid()
477 if err != nil {
478 err = DnsCacheConfigValidationError{
479 field: "DnsQueryTimeout",
480 reason: "value is not a valid duration",
481 cause: err,
482 }
483 if !all {
484 return err
485 }
486 errors = append(errors, err)
487 } else {
488
489 gt := time.Duration(0*time.Second + 0*time.Nanosecond)
490
491 if dur <= gt {
492 err := DnsCacheConfigValidationError{
493 field: "DnsQueryTimeout",
494 reason: "value must be greater than 0s",
495 }
496 if !all {
497 return err
498 }
499 errors = append(errors, err)
500 }
501
502 }
503 }
504
505 if all {
506 switch v := interface{}(m.GetKeyValueConfig()).(type) {
507 case interface{ ValidateAll() error }:
508 if err := v.ValidateAll(); err != nil {
509 errors = append(errors, DnsCacheConfigValidationError{
510 field: "KeyValueConfig",
511 reason: "embedded message failed validation",
512 cause: err,
513 })
514 }
515 case interface{ Validate() error }:
516 if err := v.Validate(); err != nil {
517 errors = append(errors, DnsCacheConfigValidationError{
518 field: "KeyValueConfig",
519 reason: "embedded message failed validation",
520 cause: err,
521 })
522 }
523 }
524 } else if v, ok := interface{}(m.GetKeyValueConfig()).(interface{ Validate() error }); ok {
525 if err := v.Validate(); err != nil {
526 return DnsCacheConfigValidationError{
527 field: "KeyValueConfig",
528 reason: "embedded message failed validation",
529 cause: err,
530 }
531 }
532 }
533
534 if len(errors) > 0 {
535 return DnsCacheConfigMultiError(errors)
536 }
537
538 return nil
539 }
540
541 // DnsCacheConfigMultiError is an error wrapping multiple validation errors
542 // returned by DnsCacheConfig.ValidateAll() if the designated constraints
543 // aren't met.
544 type DnsCacheConfigMultiError []error
545
546 // Error returns a concatenation of all the error messages it wraps.
547 func (m DnsCacheConfigMultiError) Error() string {
548 var msgs []string
549 for _, err := range m {
550 msgs = append(msgs, err.Error())
551 }
552 return strings.Join(msgs, "; ")
553 }
554
555 // AllErrors returns a list of validation violation errors.
556 func (m DnsCacheConfigMultiError) AllErrors() []error { return m }
557
558 // DnsCacheConfigValidationError is the validation error returned by
559 // DnsCacheConfig.Validate if the designated constraints aren't met.
560 type DnsCacheConfigValidationError struct {
561 field string
562 reason string
563 cause error
564 key bool
565 }
566
567 // Field function returns field value.
568 func (e DnsCacheConfigValidationError) Field() string { return e.field }
569
570 // Reason function returns reason value.
571 func (e DnsCacheConfigValidationError) Reason() string { return e.reason }
572
573 // Cause function returns cause value.
574 func (e DnsCacheConfigValidationError) Cause() error { return e.cause }
575
576 // Key function returns key value.
577 func (e DnsCacheConfigValidationError) Key() bool { return e.key }
578
579 // ErrorName returns error name.
580 func (e DnsCacheConfigValidationError) ErrorName() string { return "DnsCacheConfigValidationError" }
581
582 // Error satisfies the builtin error interface
583 func (e DnsCacheConfigValidationError) Error() string {
584 cause := ""
585 if e.cause != nil {
586 cause = fmt.Sprintf(" | caused by: %v", e.cause)
587 }
588
589 key := ""
590 if e.key {
591 key = "key for "
592 }
593
594 return fmt.Sprintf(
595 "invalid %sDnsCacheConfig.%s: %s%s",
596 key,
597 e.field,
598 e.reason,
599 cause)
600 }
601
602 var _ error = DnsCacheConfigValidationError{}
603
604 var _ interface {
605 Field() string
606 Reason() string
607 Key() bool
608 Cause() error
609 ErrorName() string
610 } = DnsCacheConfigValidationError{}