Debian Codegraph @

envoy/extensions/transport_sockets/tls/v3/tls.pb.validate.go

raw symbols SCIP
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/transport_sockets/tls/v3/tls.proto
4
5 package tlsv3
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 UpstreamTlsContext 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 *UpstreamTlsContext) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on UpstreamTlsContext 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 // UpstreamTlsContextMultiError, or nil if none found.
50 func (m *UpstreamTlsContext) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *UpstreamTlsContext) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if all {
62 switch v := interface{}(m.GetCommonTlsContext()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, UpstreamTlsContextValidationError{
66 field: "CommonTlsContext",
67 reason: "embedded message failed validation",
68 cause: err,
69 })
70 }
71 case interface{ Validate() error }:
72 if err := v.Validate(); err != nil {
73 errors = append(errors, UpstreamTlsContextValidationError{
74 field: "CommonTlsContext",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetCommonTlsContext()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return UpstreamTlsContextValidationError{
83 field: "CommonTlsContext",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if len(m.GetSni()) > 255 {
91 err := UpstreamTlsContextValidationError{
92 field: "Sni",
93 reason: "value length must be at most 255 bytes",
94 }
95 if !all {
96 return err
97 }
98 errors = append(errors, err)
99 }
100
101 // no validation rules for AutoHostSni
102
103 // no validation rules for AutoSniSanValidation
104
105 // no validation rules for AllowRenegotiation
106
107 if all {
108 switch v := interface{}(m.GetMaxSessionKeys()).(type) {
109 case interface{ ValidateAll() error }:
110 if err := v.ValidateAll(); err != nil {
111 errors = append(errors, UpstreamTlsContextValidationError{
112 field: "MaxSessionKeys",
113 reason: "embedded message failed validation",
114 cause: err,
115 })
116 }
117 case interface{ Validate() error }:
118 if err := v.Validate(); err != nil {
119 errors = append(errors, UpstreamTlsContextValidationError{
120 field: "MaxSessionKeys",
121 reason: "embedded message failed validation",
122 cause: err,
123 })
124 }
125 }
126 } else if v, ok := interface{}(m.GetMaxSessionKeys()).(interface{ Validate() error }); ok {
127 if err := v.Validate(); err != nil {
128 return UpstreamTlsContextValidationError{
129 field: "MaxSessionKeys",
130 reason: "embedded message failed validation",
131 cause: err,
132 }
133 }
134 }
135
136 if all {
137 switch v := interface{}(m.GetEnforceRsaKeyUsage()).(type) {
138 case interface{ ValidateAll() error }:
139 if err := v.ValidateAll(); err != nil {
140 errors = append(errors, UpstreamTlsContextValidationError{
141 field: "EnforceRsaKeyUsage",
142 reason: "embedded message failed validation",
143 cause: err,
144 })
145 }
146 case interface{ Validate() error }:
147 if err := v.Validate(); err != nil {
148 errors = append(errors, UpstreamTlsContextValidationError{
149 field: "EnforceRsaKeyUsage",
150 reason: "embedded message failed validation",
151 cause: err,
152 })
153 }
154 }
155 } else if v, ok := interface{}(m.GetEnforceRsaKeyUsage()).(interface{ Validate() error }); ok {
156 if err := v.Validate(); err != nil {
157 return UpstreamTlsContextValidationError{
158 field: "EnforceRsaKeyUsage",
159 reason: "embedded message failed validation",
160 cause: err,
161 }
162 }
163 }
164
165 if len(errors) > 0 {
166 return UpstreamTlsContextMultiError(errors)
167 }
168
169 return nil
170 }
171
172 // UpstreamTlsContextMultiError is an error wrapping multiple validation errors
173 // returned by UpstreamTlsContext.ValidateAll() if the designated constraints
174 // aren't met.
175 type UpstreamTlsContextMultiError []error
176
177 // Error returns a concatenation of all the error messages it wraps.
178 func (m UpstreamTlsContextMultiError) Error() string {
179 var msgs []string
180 for _, err := range m {
181 msgs = append(msgs, err.Error())
182 }
183 return strings.Join(msgs, "; ")
184 }
185
186 // AllErrors returns a list of validation violation errors.
187 func (m UpstreamTlsContextMultiError) AllErrors() []error { return m }
188
189 // UpstreamTlsContextValidationError is the validation error returned by
190 // UpstreamTlsContext.Validate if the designated constraints aren't met.
191 type UpstreamTlsContextValidationError struct {
192 field string
193 reason string
194 cause error
195 key bool
196 }
197
198 // Field function returns field value.
199 func (e UpstreamTlsContextValidationError) Field() string { return e.field }
200
201 // Reason function returns reason value.
202 func (e UpstreamTlsContextValidationError) Reason() string { return e.reason }
203
204 // Cause function returns cause value.
205 func (e UpstreamTlsContextValidationError) Cause() error { return e.cause }
206
207 // Key function returns key value.
208 func (e UpstreamTlsContextValidationError) Key() bool { return e.key }
209
210 // ErrorName returns error name.
211 func (e UpstreamTlsContextValidationError) ErrorName() string {
212 return "UpstreamTlsContextValidationError"
213 }
214
215 // Error satisfies the builtin error interface
216 func (e UpstreamTlsContextValidationError) Error() string {
217 cause := ""
218 if e.cause != nil {
219 cause = fmt.Sprintf(" | caused by: %v", e.cause)
220 }
221
222 key := ""
223 if e.key {
224 key = "key for "
225 }
226
227 return fmt.Sprintf(
228 "invalid %sUpstreamTlsContext.%s: %s%s",
229 key,
230 e.field,
231 e.reason,
232 cause)
233 }
234
235 var _ error = UpstreamTlsContextValidationError{}
236
237 var _ interface {
238 Field() string
239 Reason() string
240 Key() bool
241 Cause() error
242 ErrorName() string
243 } = UpstreamTlsContextValidationError{}
244
245 // Validate checks the field values on DownstreamTlsContext with the rules
246 // defined in the proto definition for this message. If any rules are
247 // violated, the first error encountered is returned, or nil if there are no violations.
248 func (m *DownstreamTlsContext) Validate() error {
249 return m.validate(false)
250 }
251
252 // ValidateAll checks the field values on DownstreamTlsContext with the rules
253 // defined in the proto definition for this message. If any rules are
254 // violated, the result is a list of violation errors wrapped in
255 // DownstreamTlsContextMultiError, or nil if none found.
256 func (m *DownstreamTlsContext) ValidateAll() error {
257 return m.validate(true)
258 }
259
260 func (m *DownstreamTlsContext) validate(all bool) error {
261 if m == nil {
262 return nil
263 }
264
265 var errors []error
266
267 if all {
268 switch v := interface{}(m.GetCommonTlsContext()).(type) {
269 case interface{ ValidateAll() error }:
270 if err := v.ValidateAll(); err != nil {
271 errors = append(errors, DownstreamTlsContextValidationError{
272 field: "CommonTlsContext",
273 reason: "embedded message failed validation",
274 cause: err,
275 })
276 }
277 case interface{ Validate() error }:
278 if err := v.Validate(); err != nil {
279 errors = append(errors, DownstreamTlsContextValidationError{
280 field: "CommonTlsContext",
281 reason: "embedded message failed validation",
282 cause: err,
283 })
284 }
285 }
286 } else if v, ok := interface{}(m.GetCommonTlsContext()).(interface{ Validate() error }); ok {
287 if err := v.Validate(); err != nil {
288 return DownstreamTlsContextValidationError{
289 field: "CommonTlsContext",
290 reason: "embedded message failed validation",
291 cause: err,
292 }
293 }
294 }
295
296 if all {
297 switch v := interface{}(m.GetRequireClientCertificate()).(type) {
298 case interface{ ValidateAll() error }:
299 if err := v.ValidateAll(); err != nil {
300 errors = append(errors, DownstreamTlsContextValidationError{
301 field: "RequireClientCertificate",
302 reason: "embedded message failed validation",
303 cause: err,
304 })
305 }
306 case interface{ Validate() error }:
307 if err := v.Validate(); err != nil {
308 errors = append(errors, DownstreamTlsContextValidationError{
309 field: "RequireClientCertificate",
310 reason: "embedded message failed validation",
311 cause: err,
312 })
313 }
314 }
315 } else if v, ok := interface{}(m.GetRequireClientCertificate()).(interface{ Validate() error }); ok {
316 if err := v.Validate(); err != nil {
317 return DownstreamTlsContextValidationError{
318 field: "RequireClientCertificate",
319 reason: "embedded message failed validation",
320 cause: err,
321 }
322 }
323 }
324
325 if all {
326 switch v := interface{}(m.GetRequireSni()).(type) {
327 case interface{ ValidateAll() error }:
328 if err := v.ValidateAll(); err != nil {
329 errors = append(errors, DownstreamTlsContextValidationError{
330 field: "RequireSni",
331 reason: "embedded message failed validation",
332 cause: err,
333 })
334 }
335 case interface{ Validate() error }:
336 if err := v.Validate(); err != nil {
337 errors = append(errors, DownstreamTlsContextValidationError{
338 field: "RequireSni",
339 reason: "embedded message failed validation",
340 cause: err,
341 })
342 }
343 }
344 } else if v, ok := interface{}(m.GetRequireSni()).(interface{ Validate() error }); ok {
345 if err := v.Validate(); err != nil {
346 return DownstreamTlsContextValidationError{
347 field: "RequireSni",
348 reason: "embedded message failed validation",
349 cause: err,
350 }
351 }
352 }
353
354 // no validation rules for DisableStatefulSessionResumption
355
356 if d := m.GetSessionTimeout(); d != nil {
357 dur, err := d.AsDuration(), d.CheckValid()
358 if err != nil {
359 err = DownstreamTlsContextValidationError{
360 field: "SessionTimeout",
361 reason: "value is not a valid duration",
362 cause: err,
363 }
364 if !all {
365 return err
366 }
367 errors = append(errors, err)
368 } else {
369
370 lt := time.Duration(4294967296*time.Second + 0*time.Nanosecond)
371 gte := time.Duration(0*time.Second + 0*time.Nanosecond)
372
373 if dur < gte || dur >= lt {
374 err := DownstreamTlsContextValidationError{
375 field: "SessionTimeout",
376 reason: "value must be inside range [0s, 1193046h28m16s)",
377 }
378 if !all {
379 return err
380 }
381 errors = append(errors, err)
382 }
383
384 }
385 }
386
387 if _, ok := DownstreamTlsContext_OcspStaplePolicy_name[int32(m.GetOcspStaplePolicy())]; !ok {
388 err := DownstreamTlsContextValidationError{
389 field: "OcspStaplePolicy",
390 reason: "value must be one of the defined enum values",
391 }
392 if !all {
393 return err
394 }
395 errors = append(errors, err)
396 }
397
398 if all {
399 switch v := interface{}(m.GetFullScanCertsOnSniMismatch()).(type) {
400 case interface{ ValidateAll() error }:
401 if err := v.ValidateAll(); err != nil {
402 errors = append(errors, DownstreamTlsContextValidationError{
403 field: "FullScanCertsOnSniMismatch",
404 reason: "embedded message failed validation",
405 cause: err,
406 })
407 }
408 case interface{ Validate() error }:
409 if err := v.Validate(); err != nil {
410 errors = append(errors, DownstreamTlsContextValidationError{
411 field: "FullScanCertsOnSniMismatch",
412 reason: "embedded message failed validation",
413 cause: err,
414 })
415 }
416 }
417 } else if v, ok := interface{}(m.GetFullScanCertsOnSniMismatch()).(interface{ Validate() error }); ok {
418 if err := v.Validate(); err != nil {
419 return DownstreamTlsContextValidationError{
420 field: "FullScanCertsOnSniMismatch",
421 reason: "embedded message failed validation",
422 cause: err,
423 }
424 }
425 }
426
427 // no validation rules for PreferClientCiphers
428
429 switch v := m.SessionTicketKeysType.(type) {
430 case *DownstreamTlsContext_SessionTicketKeys:
431 if v == nil {
432 err := DownstreamTlsContextValidationError{
433 field: "SessionTicketKeysType",
434 reason: "oneof value cannot be a typed-nil",
435 }
436 if !all {
437 return err
438 }
439 errors = append(errors, err)
440 }
441
442 if all {
443 switch v := interface{}(m.GetSessionTicketKeys()).(type) {
444 case interface{ ValidateAll() error }:
445 if err := v.ValidateAll(); err != nil {
446 errors = append(errors, DownstreamTlsContextValidationError{
447 field: "SessionTicketKeys",
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, DownstreamTlsContextValidationError{
455 field: "SessionTicketKeys",
456 reason: "embedded message failed validation",
457 cause: err,
458 })
459 }
460 }
461 } else if v, ok := interface{}(m.GetSessionTicketKeys()).(interface{ Validate() error }); ok {
462 if err := v.Validate(); err != nil {
463 return DownstreamTlsContextValidationError{
464 field: "SessionTicketKeys",
465 reason: "embedded message failed validation",
466 cause: err,
467 }
468 }
469 }
470
471 case *DownstreamTlsContext_SessionTicketKeysSdsSecretConfig:
472 if v == nil {
473 err := DownstreamTlsContextValidationError{
474 field: "SessionTicketKeysType",
475 reason: "oneof value cannot be a typed-nil",
476 }
477 if !all {
478 return err
479 }
480 errors = append(errors, err)
481 }
482
483 if all {
484 switch v := interface{}(m.GetSessionTicketKeysSdsSecretConfig()).(type) {
485 case interface{ ValidateAll() error }:
486 if err := v.ValidateAll(); err != nil {
487 errors = append(errors, DownstreamTlsContextValidationError{
488 field: "SessionTicketKeysSdsSecretConfig",
489 reason: "embedded message failed validation",
490 cause: err,
491 })
492 }
493 case interface{ Validate() error }:
494 if err := v.Validate(); err != nil {
495 errors = append(errors, DownstreamTlsContextValidationError{
496 field: "SessionTicketKeysSdsSecretConfig",
497 reason: "embedded message failed validation",
498 cause: err,
499 })
500 }
501 }
502 } else if v, ok := interface{}(m.GetSessionTicketKeysSdsSecretConfig()).(interface{ Validate() error }); ok {
503 if err := v.Validate(); err != nil {
504 return DownstreamTlsContextValidationError{
505 field: "SessionTicketKeysSdsSecretConfig",
506 reason: "embedded message failed validation",
507 cause: err,
508 }
509 }
510 }
511
512 case *DownstreamTlsContext_DisableStatelessSessionResumption:
513 if v == nil {
514 err := DownstreamTlsContextValidationError{
515 field: "SessionTicketKeysType",
516 reason: "oneof value cannot be a typed-nil",
517 }
518 if !all {
519 return err
520 }
521 errors = append(errors, err)
522 }
523 // no validation rules for DisableStatelessSessionResumption
524 default:
525 _ = v // ensures v is used
526 }
527
528 if len(errors) > 0 {
529 return DownstreamTlsContextMultiError(errors)
530 }
531
532 return nil
533 }
534
535 // DownstreamTlsContextMultiError is an error wrapping multiple validation
536 // errors returned by DownstreamTlsContext.ValidateAll() if the designated
537 // constraints aren't met.
538 type DownstreamTlsContextMultiError []error
539
540 // Error returns a concatenation of all the error messages it wraps.
541 func (m DownstreamTlsContextMultiError) Error() string {
542 var msgs []string
543 for _, err := range m {
544 msgs = append(msgs, err.Error())
545 }
546 return strings.Join(msgs, "; ")
547 }
548
549 // AllErrors returns a list of validation violation errors.
550 func (m DownstreamTlsContextMultiError) AllErrors() []error { return m }
551
552 // DownstreamTlsContextValidationError is the validation error returned by
553 // DownstreamTlsContext.Validate if the designated constraints aren't met.
554 type DownstreamTlsContextValidationError struct {
555 field string
556 reason string
557 cause error
558 key bool
559 }
560
561 // Field function returns field value.
562 func (e DownstreamTlsContextValidationError) Field() string { return e.field }
563
564 // Reason function returns reason value.
565 func (e DownstreamTlsContextValidationError) Reason() string { return e.reason }
566
567 // Cause function returns cause value.
568 func (e DownstreamTlsContextValidationError) Cause() error { return e.cause }
569
570 // Key function returns key value.
571 func (e DownstreamTlsContextValidationError) Key() bool { return e.key }
572
573 // ErrorName returns error name.
574 func (e DownstreamTlsContextValidationError) ErrorName() string {
575 return "DownstreamTlsContextValidationError"
576 }
577
578 // Error satisfies the builtin error interface
579 func (e DownstreamTlsContextValidationError) Error() string {
580 cause := ""
581 if e.cause != nil {
582 cause = fmt.Sprintf(" | caused by: %v", e.cause)
583 }
584
585 key := ""
586 if e.key {
587 key = "key for "
588 }
589
590 return fmt.Sprintf(
591 "invalid %sDownstreamTlsContext.%s: %s%s",
592 key,
593 e.field,
594 e.reason,
595 cause)
596 }
597
598 var _ error = DownstreamTlsContextValidationError{}
599
600 var _ interface {
601 Field() string
602 Reason() string
603 Key() bool
604 Cause() error
605 ErrorName() string
606 } = DownstreamTlsContextValidationError{}
607
608 // Validate checks the field values on TlsKeyLog with the rules defined in the
609 // proto definition for this message. If any rules are violated, the first
610 // error encountered is returned, or nil if there are no violations.
611 func (m *TlsKeyLog) Validate() error {
612 return m.validate(false)
613 }
614
615 // ValidateAll checks the field values on TlsKeyLog with the rules defined in
616 // the proto definition for this message. If any rules are violated, the
617 // result is a list of violation errors wrapped in TlsKeyLogMultiError, or nil
618 // if none found.
619 func (m *TlsKeyLog) ValidateAll() error {
620 return m.validate(true)
621 }
622
623 func (m *TlsKeyLog) validate(all bool) error {
624 if m == nil {
625 return nil
626 }
627
628 var errors []error
629
630 if utf8.RuneCountInString(m.GetPath()) < 1 {
631 err := TlsKeyLogValidationError{
632 field: "Path",
633 reason: "value length must be at least 1 runes",
634 }
635 if !all {
636 return err
637 }
638 errors = append(errors, err)
639 }
640
641 for idx, item := range m.GetLocalAddressRange() {
642 _, _ = idx, item
643
644 if all {
645 switch v := interface{}(item).(type) {
646 case interface{ ValidateAll() error }:
647 if err := v.ValidateAll(); err != nil {
648 errors = append(errors, TlsKeyLogValidationError{
649 field: fmt.Sprintf("LocalAddressRange[%v]", idx),
650 reason: "embedded message failed validation",
651 cause: err,
652 })
653 }
654 case interface{ Validate() error }:
655 if err := v.Validate(); err != nil {
656 errors = append(errors, TlsKeyLogValidationError{
657 field: fmt.Sprintf("LocalAddressRange[%v]", idx),
658 reason: "embedded message failed validation",
659 cause: err,
660 })
661 }
662 }
663 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
664 if err := v.Validate(); err != nil {
665 return TlsKeyLogValidationError{
666 field: fmt.Sprintf("LocalAddressRange[%v]", idx),
667 reason: "embedded message failed validation",
668 cause: err,
669 }
670 }
671 }
672
673 }
674
675 for idx, item := range m.GetRemoteAddressRange() {
676 _, _ = idx, item
677
678 if all {
679 switch v := interface{}(item).(type) {
680 case interface{ ValidateAll() error }:
681 if err := v.ValidateAll(); err != nil {
682 errors = append(errors, TlsKeyLogValidationError{
683 field: fmt.Sprintf("RemoteAddressRange[%v]", idx),
684 reason: "embedded message failed validation",
685 cause: err,
686 })
687 }
688 case interface{ Validate() error }:
689 if err := v.Validate(); err != nil {
690 errors = append(errors, TlsKeyLogValidationError{
691 field: fmt.Sprintf("RemoteAddressRange[%v]", idx),
692 reason: "embedded message failed validation",
693 cause: err,
694 })
695 }
696 }
697 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
698 if err := v.Validate(); err != nil {
699 return TlsKeyLogValidationError{
700 field: fmt.Sprintf("RemoteAddressRange[%v]", idx),
701 reason: "embedded message failed validation",
702 cause: err,
703 }
704 }
705 }
706
707 }
708
709 if len(errors) > 0 {
710 return TlsKeyLogMultiError(errors)
711 }
712
713 return nil
714 }
715
716 // TlsKeyLogMultiError is an error wrapping multiple validation errors returned
717 // by TlsKeyLog.ValidateAll() if the designated constraints aren't met.
718 type TlsKeyLogMultiError []error
719
720 // Error returns a concatenation of all the error messages it wraps.
721 func (m TlsKeyLogMultiError) Error() string {
722 var msgs []string
723 for _, err := range m {
724 msgs = append(msgs, err.Error())
725 }
726 return strings.Join(msgs, "; ")
727 }
728
729 // AllErrors returns a list of validation violation errors.
730 func (m TlsKeyLogMultiError) AllErrors() []error { return m }
731
732 // TlsKeyLogValidationError is the validation error returned by
733 // TlsKeyLog.Validate if the designated constraints aren't met.
734 type TlsKeyLogValidationError struct {
735 field string
736 reason string
737 cause error
738 key bool
739 }
740
741 // Field function returns field value.
742 func (e TlsKeyLogValidationError) Field() string { return e.field }
743
744 // Reason function returns reason value.
745 func (e TlsKeyLogValidationError) Reason() string { return e.reason }
746
747 // Cause function returns cause value.
748 func (e TlsKeyLogValidationError) Cause() error { return e.cause }
749
750 // Key function returns key value.
751 func (e TlsKeyLogValidationError) Key() bool { return e.key }
752
753 // ErrorName returns error name.
754 func (e TlsKeyLogValidationError) ErrorName() string { return "TlsKeyLogValidationError" }
755
756 // Error satisfies the builtin error interface
757 func (e TlsKeyLogValidationError) Error() string {
758 cause := ""
759 if e.cause != nil {
760 cause = fmt.Sprintf(" | caused by: %v", e.cause)
761 }
762
763 key := ""
764 if e.key {
765 key = "key for "
766 }
767
768 return fmt.Sprintf(
769 "invalid %sTlsKeyLog.%s: %s%s",
770 key,
771 e.field,
772 e.reason,
773 cause)
774 }
775
776 var _ error = TlsKeyLogValidationError{}
777
778 var _ interface {
779 Field() string
780 Reason() string
781 Key() bool
782 Cause() error
783 ErrorName() string
784 } = TlsKeyLogValidationError{}
785
786 // Validate checks the field values on CommonTlsContext with the rules defined
787 // in the proto definition for this message. If any rules are violated, the
788 // first error encountered is returned, or nil if there are no violations.
789 func (m *CommonTlsContext) Validate() error {
790 return m.validate(false)
791 }
792
793 // ValidateAll checks the field values on CommonTlsContext with the rules
794 // defined in the proto definition for this message. If any rules are
795 // violated, the result is a list of violation errors wrapped in
796 // CommonTlsContextMultiError, or nil if none found.
797 func (m *CommonTlsContext) ValidateAll() error {
798 return m.validate(true)
799 }
800
801 func (m *CommonTlsContext) validate(all bool) error {
802 if m == nil {
803 return nil
804 }
805
806 var errors []error
807
808 if all {
809 switch v := interface{}(m.GetTlsParams()).(type) {
810 case interface{ ValidateAll() error }:
811 if err := v.ValidateAll(); err != nil {
812 errors = append(errors, CommonTlsContextValidationError{
813 field: "TlsParams",
814 reason: "embedded message failed validation",
815 cause: err,
816 })
817 }
818 case interface{ Validate() error }:
819 if err := v.Validate(); err != nil {
820 errors = append(errors, CommonTlsContextValidationError{
821 field: "TlsParams",
822 reason: "embedded message failed validation",
823 cause: err,
824 })
825 }
826 }
827 } else if v, ok := interface{}(m.GetTlsParams()).(interface{ Validate() error }); ok {
828 if err := v.Validate(); err != nil {
829 return CommonTlsContextValidationError{
830 field: "TlsParams",
831 reason: "embedded message failed validation",
832 cause: err,
833 }
834 }
835 }
836
837 for idx, item := range m.GetTlsCertificates() {
838 _, _ = idx, item
839
840 if all {
841 switch v := interface{}(item).(type) {
842 case interface{ ValidateAll() error }:
843 if err := v.ValidateAll(); err != nil {
844 errors = append(errors, CommonTlsContextValidationError{
845 field: fmt.Sprintf("TlsCertificates[%v]", idx),
846 reason: "embedded message failed validation",
847 cause: err,
848 })
849 }
850 case interface{ Validate() error }:
851 if err := v.Validate(); err != nil {
852 errors = append(errors, CommonTlsContextValidationError{
853 field: fmt.Sprintf("TlsCertificates[%v]", idx),
854 reason: "embedded message failed validation",
855 cause: err,
856 })
857 }
858 }
859 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
860 if err := v.Validate(); err != nil {
861 return CommonTlsContextValidationError{
862 field: fmt.Sprintf("TlsCertificates[%v]", idx),
863 reason: "embedded message failed validation",
864 cause: err,
865 }
866 }
867 }
868
869 }
870
871 for idx, item := range m.GetTlsCertificateSdsSecretConfigs() {
872 _, _ = idx, item
873
874 if all {
875 switch v := interface{}(item).(type) {
876 case interface{ ValidateAll() error }:
877 if err := v.ValidateAll(); err != nil {
878 errors = append(errors, CommonTlsContextValidationError{
879 field: fmt.Sprintf("TlsCertificateSdsSecretConfigs[%v]", idx),
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, CommonTlsContextValidationError{
887 field: fmt.Sprintf("TlsCertificateSdsSecretConfigs[%v]", idx),
888 reason: "embedded message failed validation",
889 cause: err,
890 })
891 }
892 }
893 } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
894 if err := v.Validate(); err != nil {
895 return CommonTlsContextValidationError{
896 field: fmt.Sprintf("TlsCertificateSdsSecretConfigs[%v]", idx),
897 reason: "embedded message failed validation",
898 cause: err,
899 }
900 }
901 }
902
903 }
904
905 if all {
906 switch v := interface{}(m.GetTlsCertificateProviderInstance()).(type) {
907 case interface{ ValidateAll() error }:
908 if err := v.ValidateAll(); err != nil {
909 errors = append(errors, CommonTlsContextValidationError{
910 field: "TlsCertificateProviderInstance",
911 reason: "embedded message failed validation",
912 cause: err,
913 })
914 }
915 case interface{ Validate() error }:
916 if err := v.Validate(); err != nil {
917 errors = append(errors, CommonTlsContextValidationError{
918 field: "TlsCertificateProviderInstance",
919 reason: "embedded message failed validation",
920 cause: err,
921 })
922 }
923 }
924 } else if v, ok := interface{}(m.GetTlsCertificateProviderInstance()).(interface{ Validate() error }); ok {
925 if err := v.Validate(); err != nil {
926 return CommonTlsContextValidationError{
927 field: "TlsCertificateProviderInstance",
928 reason: "embedded message failed validation",
929 cause: err,
930 }
931 }
932 }
933
934 if all {
935 switch v := interface{}(m.GetCustomTlsCertificateSelector()).(type) {
936 case interface{ ValidateAll() error }:
937 if err := v.ValidateAll(); err != nil {
938 errors = append(errors, CommonTlsContextValidationError{
939 field: "CustomTlsCertificateSelector",
940 reason: "embedded message failed validation",
941 cause: err,
942 })
943 }
944 case interface{ Validate() error }:
945 if err := v.Validate(); err != nil {
946 errors = append(errors, CommonTlsContextValidationError{
947 field: "CustomTlsCertificateSelector",
948 reason: "embedded message failed validation",
949 cause: err,
950 })
951 }
952 }
953 } else if v, ok := interface{}(m.GetCustomTlsCertificateSelector()).(interface{ Validate() error }); ok {
954 if err := v.Validate(); err != nil {
955 return CommonTlsContextValidationError{
956 field: "CustomTlsCertificateSelector",
957 reason: "embedded message failed validation",
958 cause: err,
959 }
960 }
961 }
962
963 if all {
964 switch v := interface{}(m.GetTlsCertificateCertificateProvider()).(type) {
965 case interface{ ValidateAll() error }:
966 if err := v.ValidateAll(); err != nil {
967 errors = append(errors, CommonTlsContextValidationError{
968 field: "TlsCertificateCertificateProvider",
969 reason: "embedded message failed validation",
970 cause: err,
971 })
972 }
973 case interface{ Validate() error }:
974 if err := v.Validate(); err != nil {
975 errors = append(errors, CommonTlsContextValidationError{
976 field: "TlsCertificateCertificateProvider",
977 reason: "embedded message failed validation",
978 cause: err,
979 })
980 }
981 }
982 } else if v, ok := interface{}(m.GetTlsCertificateCertificateProvider()).(interface{ Validate() error }); ok {
983 if err := v.Validate(); err != nil {
984 return CommonTlsContextValidationError{
985 field: "TlsCertificateCertificateProvider",
986 reason: "embedded message failed validation",
987 cause: err,
988 }
989 }
990 }
991
992 if all {
993 switch v := interface{}(m.GetTlsCertificateCertificateProviderInstance()).(type) {
994 case interface{ ValidateAll() error }:
995 if err := v.ValidateAll(); err != nil {
996 errors = append(errors, CommonTlsContextValidationError{
997 field: "TlsCertificateCertificateProviderInstance",
998 reason: "embedded message failed validation",
999 cause: err,
1000 })
1001 }
1002 case interface{ Validate() error }:
1003 if err := v.Validate(); err != nil {
1004 errors = append(errors, CommonTlsContextValidationError{
1005 field: "TlsCertificateCertificateProviderInstance",
1006 reason: "embedded message failed validation",
1007 cause: err,
1008 })
1009 }
1010 }
1011 } else if v, ok := interface{}(m.GetTlsCertificateCertificateProviderInstance()).(interface{ Validate() error }); ok {
1012 if err := v.Validate(); err != nil {
1013 return CommonTlsContextValidationError{
1014 field: "TlsCertificateCertificateProviderInstance",
1015 reason: "embedded message failed validation",
1016 cause: err,
1017 }
1018 }
1019 }
1020
1021 if all {
1022 switch v := interface{}(m.GetCustomHandshaker()).(type) {
1023 case interface{ ValidateAll() error }:
1024 if err := v.ValidateAll(); err != nil {
1025 errors = append(errors, CommonTlsContextValidationError{
1026 field: "CustomHandshaker",
1027 reason: "embedded message failed validation",
1028 cause: err,
1029 })
1030 }
1031 case interface{ Validate() error }:
1032 if err := v.Validate(); err != nil {
1033 errors = append(errors, CommonTlsContextValidationError{
1034 field: "CustomHandshaker",
1035 reason: "embedded message failed validation",
1036 cause: err,
1037 })
1038 }
1039 }
1040 } else if v, ok := interface{}(m.GetCustomHandshaker()).(interface{ Validate() error }); ok {
1041 if err := v.Validate(); err != nil {
1042 return CommonTlsContextValidationError{
1043 field: "CustomHandshaker",
1044 reason: "embedded message failed validation",
1045 cause: err,
1046 }
1047 }
1048 }
1049
1050 if all {
1051 switch v := interface{}(m.GetKeyLog()).(type) {
1052 case interface{ ValidateAll() error }:
1053 if err := v.ValidateAll(); err != nil {
1054 errors = append(errors, CommonTlsContextValidationError{
1055 field: "KeyLog",
1056 reason: "embedded message failed validation",
1057 cause: err,
1058 })
1059 }
1060 case interface{ Validate() error }:
1061 if err := v.Validate(); err != nil {
1062 errors = append(errors, CommonTlsContextValidationError{
1063 field: "KeyLog",
1064 reason: "embedded message failed validation",
1065 cause: err,
1066 })
1067 }
1068 }
1069 } else if v, ok := interface{}(m.GetKeyLog()).(interface{ Validate() error }); ok {
1070 if err := v.Validate(); err != nil {
1071 return CommonTlsContextValidationError{
1072 field: "KeyLog",
1073 reason: "embedded message failed validation",
1074 cause: err,
1075 }
1076 }
1077 }
1078
1079 switch v := m.ValidationContextType.(type) {
1080 case *CommonTlsContext_ValidationContext:
1081 if v == nil {
1082 err := CommonTlsContextValidationError{
1083 field: "ValidationContextType",
1084 reason: "oneof value cannot be a typed-nil",
1085 }
1086 if !all {
1087 return err
1088 }
1089 errors = append(errors, err)
1090 }
1091
1092 if all {
1093 switch v := interface{}(m.GetValidationContext()).(type) {
1094 case interface{ ValidateAll() error }:
1095 if err := v.ValidateAll(); err != nil {
1096 errors = append(errors, CommonTlsContextValidationError{
1097 field: "ValidationContext",
1098 reason: "embedded message failed validation",
1099 cause: err,
1100 })
1101 }
1102 case interface{ Validate() error }:
1103 if err := v.Validate(); err != nil {
1104 errors = append(errors, CommonTlsContextValidationError{
1105 field: "ValidationContext",
1106 reason: "embedded message failed validation",
1107 cause: err,
1108 })
1109 }
1110 }
1111 } else if v, ok := interface{}(m.GetValidationContext()).(interface{ Validate() error }); ok {
1112 if err := v.Validate(); err != nil {
1113 return CommonTlsContextValidationError{
1114 field: "ValidationContext",
1115 reason: "embedded message failed validation",
1116 cause: err,
1117 }
1118 }
1119 }
1120
1121 case *CommonTlsContext_ValidationContextSdsSecretConfig:
1122 if v == nil {
1123 err := CommonTlsContextValidationError{
1124 field: "ValidationContextType",
1125 reason: "oneof value cannot be a typed-nil",
1126 }
1127 if !all {
1128 return err
1129 }
1130 errors = append(errors, err)
1131 }
1132
1133 if all {
1134 switch v := interface{}(m.GetValidationContextSdsSecretConfig()).(type) {
1135 case interface{ ValidateAll() error }:
1136 if err := v.ValidateAll(); err != nil {
1137 errors = append(errors, CommonTlsContextValidationError{
1138 field: "ValidationContextSdsSecretConfig",
1139 reason: "embedded message failed validation",
1140 cause: err,
1141 })
1142 }
1143 case interface{ Validate() error }:
1144 if err := v.Validate(); err != nil {
1145 errors = append(errors, CommonTlsContextValidationError{
1146 field: "ValidationContextSdsSecretConfig",
1147 reason: "embedded message failed validation",
1148 cause: err,
1149 })
1150 }
1151 }
1152 } else if v, ok := interface{}(m.GetValidationContextSdsSecretConfig()).(interface{ Validate() error }); ok {
1153 if err := v.Validate(); err != nil {
1154 return CommonTlsContextValidationError{
1155 field: "ValidationContextSdsSecretConfig",
1156 reason: "embedded message failed validation",
1157 cause: err,
1158 }
1159 }
1160 }
1161
1162 case *CommonTlsContext_CombinedValidationContext:
1163 if v == nil {
1164 err := CommonTlsContextValidationError{
1165 field: "ValidationContextType",
1166 reason: "oneof value cannot be a typed-nil",
1167 }
1168 if !all {
1169 return err
1170 }
1171 errors = append(errors, err)
1172 }
1173
1174 if all {
1175 switch v := interface{}(m.GetCombinedValidationContext()).(type) {
1176 case interface{ ValidateAll() error }:
1177 if err := v.ValidateAll(); err != nil {
1178 errors = append(errors, CommonTlsContextValidationError{
1179 field: "CombinedValidationContext",
1180 reason: "embedded message failed validation",
1181 cause: err,
1182 })
1183 }
1184 case interface{ Validate() error }:
1185 if err := v.Validate(); err != nil {
1186 errors = append(errors, CommonTlsContextValidationError{
1187 field: "CombinedValidationContext",
1188 reason: "embedded message failed validation",
1189 cause: err,
1190 })
1191 }
1192 }
1193 } else if v, ok := interface{}(m.GetCombinedValidationContext()).(interface{ Validate() error }); ok {
1194 if err := v.Validate(); err != nil {
1195 return CommonTlsContextValidationError{
1196 field: "CombinedValidationContext",
1197 reason: "embedded message failed validation",
1198 cause: err,
1199 }
1200 }
1201 }
1202
1203 case *CommonTlsContext_ValidationContextCertificateProvider:
1204 if v == nil {
1205 err := CommonTlsContextValidationError{
1206 field: "ValidationContextType",
1207 reason: "oneof value cannot be a typed-nil",
1208 }
1209 if !all {
1210 return err
1211 }
1212 errors = append(errors, err)
1213 }
1214
1215 if all {
1216 switch v := interface{}(m.GetValidationContextCertificateProvider()).(type) {
1217 case interface{ ValidateAll() error }:
1218 if err := v.ValidateAll(); err != nil {
1219 errors = append(errors, CommonTlsContextValidationError{
1220 field: "ValidationContextCertificateProvider",
1221 reason: "embedded message failed validation",
1222 cause: err,
1223 })
1224 }
1225 case interface{ Validate() error }:
1226 if err := v.Validate(); err != nil {
1227 errors = append(errors, CommonTlsContextValidationError{
1228 field: "ValidationContextCertificateProvider",
1229 reason: "embedded message failed validation",
1230 cause: err,
1231 })
1232 }
1233 }
1234 } else if v, ok := interface{}(m.GetValidationContextCertificateProvider()).(interface{ Validate() error }); ok {
1235 if err := v.Validate(); err != nil {
1236 return CommonTlsContextValidationError{
1237 field: "ValidationContextCertificateProvider",
1238 reason: "embedded message failed validation",
1239 cause: err,
1240 }
1241 }
1242 }
1243
1244 case *CommonTlsContext_ValidationContextCertificateProviderInstance:
1245 if v == nil {
1246 err := CommonTlsContextValidationError{
1247 field: "ValidationContextType",
1248 reason: "oneof value cannot be a typed-nil",
1249 }
1250 if !all {
1251 return err
1252 }
1253 errors = append(errors, err)
1254 }
1255
1256 if all {
1257 switch v := interface{}(m.GetValidationContextCertificateProviderInstance()).(type) {
1258 case interface{ ValidateAll() error }:
1259 if err := v.ValidateAll(); err != nil {
1260 errors = append(errors, CommonTlsContextValidationError{
1261 field: "ValidationContextCertificateProviderInstance",
1262 reason: "embedded message failed validation",
1263 cause: err,
1264 })
1265 }
1266 case interface{ Validate() error }:
1267 if err := v.Validate(); err != nil {
1268 errors = append(errors, CommonTlsContextValidationError{
1269 field: "ValidationContextCertificateProviderInstance",
1270 reason: "embedded message failed validation",
1271 cause: err,
1272 })
1273 }
1274 }
1275 } else if v, ok := interface{}(m.GetValidationContextCertificateProviderInstance()).(interface{ Validate() error }); ok {
1276 if err := v.Validate(); err != nil {
1277 return CommonTlsContextValidationError{
1278 field: "ValidationContextCertificateProviderInstance",
1279 reason: "embedded message failed validation",
1280 cause: err,
1281 }
1282 }
1283 }
1284
1285 default:
1286 _ = v // ensures v is used
1287 }
1288
1289 if len(errors) > 0 {
1290 return CommonTlsContextMultiError(errors)
1291 }
1292
1293 return nil
1294 }
1295
1296 // CommonTlsContextMultiError is an error wrapping multiple validation errors
1297 // returned by CommonTlsContext.ValidateAll() if the designated constraints
1298 // aren't met.
1299 type CommonTlsContextMultiError []error
1300
1301 // Error returns a concatenation of all the error messages it wraps.
1302 func (m CommonTlsContextMultiError) Error() string {
1303 var msgs []string
1304 for _, err := range m {
1305 msgs = append(msgs, err.Error())
1306 }
1307 return strings.Join(msgs, "; ")
1308 }
1309
1310 // AllErrors returns a list of validation violation errors.
1311 func (m CommonTlsContextMultiError) AllErrors() []error { return m }
1312
1313 // CommonTlsContextValidationError is the validation error returned by
1314 // CommonTlsContext.Validate if the designated constraints aren't met.
1315 type CommonTlsContextValidationError struct {
1316 field string
1317 reason string
1318 cause error
1319 key bool
1320 }
1321
1322 // Field function returns field value.
1323 func (e CommonTlsContextValidationError) Field() string { return e.field }
1324
1325 // Reason function returns reason value.
1326 func (e CommonTlsContextValidationError) Reason() string { return e.reason }
1327
1328 // Cause function returns cause value.
1329 func (e CommonTlsContextValidationError) Cause() error { return e.cause }
1330
1331 // Key function returns key value.
1332 func (e CommonTlsContextValidationError) Key() bool { return e.key }
1333
1334 // ErrorName returns error name.
1335 func (e CommonTlsContextValidationError) ErrorName() string { return "CommonTlsContextValidationError" }
1336
1337 // Error satisfies the builtin error interface
1338 func (e CommonTlsContextValidationError) Error() string {
1339 cause := ""
1340 if e.cause != nil {
1341 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1342 }
1343
1344 key := ""
1345 if e.key {
1346 key = "key for "
1347 }
1348
1349 return fmt.Sprintf(
1350 "invalid %sCommonTlsContext.%s: %s%s",
1351 key,
1352 e.field,
1353 e.reason,
1354 cause)
1355 }
1356
1357 var _ error = CommonTlsContextValidationError{}
1358
1359 var _ interface {
1360 Field() string
1361 Reason() string
1362 Key() bool
1363 Cause() error
1364 ErrorName() string
1365 } = CommonTlsContextValidationError{}
1366
1367 // Validate checks the field values on CommonTlsContext_CertificateProvider
1368 // with the rules defined in the proto definition for this message. If any
1369 // rules are violated, the first error encountered is returned, or nil if
1370 // there are no violations.
1371 func (m *CommonTlsContext_CertificateProvider) Validate() error {
1372 return m.validate(false)
1373 }
1374
1375 // ValidateAll checks the field values on CommonTlsContext_CertificateProvider
1376 // with the rules defined in the proto definition for this message. If any
1377 // rules are violated, the result is a list of violation errors wrapped in
1378 // CommonTlsContext_CertificateProviderMultiError, or nil if none found.
1379 func (m *CommonTlsContext_CertificateProvider) ValidateAll() error {
1380 return m.validate(true)
1381 }
1382
1383 func (m *CommonTlsContext_CertificateProvider) validate(all bool) error {
1384 if m == nil {
1385 return nil
1386 }
1387
1388 var errors []error
1389
1390 if utf8.RuneCountInString(m.GetName()) < 1 {
1391 err := CommonTlsContext_CertificateProviderValidationError{
1392 field: "Name",
1393 reason: "value length must be at least 1 runes",
1394 }
1395 if !all {
1396 return err
1397 }
1398 errors = append(errors, err)
1399 }
1400
1401 oneofConfigPresent := false
1402 switch v := m.Config.(type) {
1403 case *CommonTlsContext_CertificateProvider_TypedConfig:
1404 if v == nil {
1405 err := CommonTlsContext_CertificateProviderValidationError{
1406 field: "Config",
1407 reason: "oneof value cannot be a typed-nil",
1408 }
1409 if !all {
1410 return err
1411 }
1412 errors = append(errors, err)
1413 }
1414 oneofConfigPresent = true
1415
1416 if all {
1417 switch v := interface{}(m.GetTypedConfig()).(type) {
1418 case interface{ ValidateAll() error }:
1419 if err := v.ValidateAll(); err != nil {
1420 errors = append(errors, CommonTlsContext_CertificateProviderValidationError{
1421 field: "TypedConfig",
1422 reason: "embedded message failed validation",
1423 cause: err,
1424 })
1425 }
1426 case interface{ Validate() error }:
1427 if err := v.Validate(); err != nil {
1428 errors = append(errors, CommonTlsContext_CertificateProviderValidationError{
1429 field: "TypedConfig",
1430 reason: "embedded message failed validation",
1431 cause: err,
1432 })
1433 }
1434 }
1435 } else if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
1436 if err := v.Validate(); err != nil {
1437 return CommonTlsContext_CertificateProviderValidationError{
1438 field: "TypedConfig",
1439 reason: "embedded message failed validation",
1440 cause: err,
1441 }
1442 }
1443 }
1444
1445 default:
1446 _ = v // ensures v is used
1447 }
1448 if !oneofConfigPresent {
1449 err := CommonTlsContext_CertificateProviderValidationError{
1450 field: "Config",
1451 reason: "value is required",
1452 }
1453 if !all {
1454 return err
1455 }
1456 errors = append(errors, err)
1457 }
1458
1459 if len(errors) > 0 {
1460 return CommonTlsContext_CertificateProviderMultiError(errors)
1461 }
1462
1463 return nil
1464 }
1465
1466 // CommonTlsContext_CertificateProviderMultiError is an error wrapping multiple
1467 // validation errors returned by
1468 // CommonTlsContext_CertificateProvider.ValidateAll() if the designated
1469 // constraints aren't met.
1470 type CommonTlsContext_CertificateProviderMultiError []error
1471
1472 // Error returns a concatenation of all the error messages it wraps.
1473 func (m CommonTlsContext_CertificateProviderMultiError) Error() string {
1474 var msgs []string
1475 for _, err := range m {
1476 msgs = append(msgs, err.Error())
1477 }
1478 return strings.Join(msgs, "; ")
1479 }
1480
1481 // AllErrors returns a list of validation violation errors.
1482 func (m CommonTlsContext_CertificateProviderMultiError) AllErrors() []error { return m }
1483
1484 // CommonTlsContext_CertificateProviderValidationError is the validation error
1485 // returned by CommonTlsContext_CertificateProvider.Validate if the designated
1486 // constraints aren't met.
1487 type CommonTlsContext_CertificateProviderValidationError struct {
1488 field string
1489 reason string
1490 cause error
1491 key bool
1492 }
1493
1494 // Field function returns field value.
1495 func (e CommonTlsContext_CertificateProviderValidationError) Field() string { return e.field }
1496
1497 // Reason function returns reason value.
1498 func (e CommonTlsContext_CertificateProviderValidationError) Reason() string { return e.reason }
1499
1500 // Cause function returns cause value.
1501 func (e CommonTlsContext_CertificateProviderValidationError) Cause() error { return e.cause }
1502
1503 // Key function returns key value.
1504 func (e CommonTlsContext_CertificateProviderValidationError) Key() bool { return e.key }
1505
1506 // ErrorName returns error name.
1507 func (e CommonTlsContext_CertificateProviderValidationError) ErrorName() string {
1508 return "CommonTlsContext_CertificateProviderValidationError"
1509 }
1510
1511 // Error satisfies the builtin error interface
1512 func (e CommonTlsContext_CertificateProviderValidationError) Error() string {
1513 cause := ""
1514 if e.cause != nil {
1515 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1516 }
1517
1518 key := ""
1519 if e.key {
1520 key = "key for "
1521 }
1522
1523 return fmt.Sprintf(
1524 "invalid %sCommonTlsContext_CertificateProvider.%s: %s%s",
1525 key,
1526 e.field,
1527 e.reason,
1528 cause)
1529 }
1530
1531 var _ error = CommonTlsContext_CertificateProviderValidationError{}
1532
1533 var _ interface {
1534 Field() string
1535 Reason() string
1536 Key() bool
1537 Cause() error
1538 ErrorName() string
1539 } = CommonTlsContext_CertificateProviderValidationError{}
1540
1541 // Validate checks the field values on
1542 // CommonTlsContext_CertificateProviderInstance with the rules defined in the
1543 // proto definition for this message. If any rules are violated, the first
1544 // error encountered is returned, or nil if there are no violations.
1545 func (m *CommonTlsContext_CertificateProviderInstance) Validate() error {
1546 return m.validate(false)
1547 }
1548
1549 // ValidateAll checks the field values on
1550 // CommonTlsContext_CertificateProviderInstance with the rules defined in the
1551 // proto definition for this message. If any rules are violated, the result is
1552 // a list of violation errors wrapped in
1553 // CommonTlsContext_CertificateProviderInstanceMultiError, or nil if none found.
1554 func (m *CommonTlsContext_CertificateProviderInstance) ValidateAll() error {
1555 return m.validate(true)
1556 }
1557
1558 func (m *CommonTlsContext_CertificateProviderInstance) validate(all bool) error {
1559 if m == nil {
1560 return nil
1561 }
1562
1563 var errors []error
1564
1565 // no validation rules for InstanceName
1566
1567 // no validation rules for CertificateName
1568
1569 if len(errors) > 0 {
1570 return CommonTlsContext_CertificateProviderInstanceMultiError(errors)
1571 }
1572
1573 return nil
1574 }
1575
1576 // CommonTlsContext_CertificateProviderInstanceMultiError is an error wrapping
1577 // multiple validation errors returned by
1578 // CommonTlsContext_CertificateProviderInstance.ValidateAll() if the
1579 // designated constraints aren't met.
1580 type CommonTlsContext_CertificateProviderInstanceMultiError []error
1581
1582 // Error returns a concatenation of all the error messages it wraps.
1583 func (m CommonTlsContext_CertificateProviderInstanceMultiError) Error() string {
1584 var msgs []string
1585 for _, err := range m {
1586 msgs = append(msgs, err.Error())
1587 }
1588 return strings.Join(msgs, "; ")
1589 }
1590
1591 // AllErrors returns a list of validation violation errors.
1592 func (m CommonTlsContext_CertificateProviderInstanceMultiError) AllErrors() []error { return m }
1593
1594 // CommonTlsContext_CertificateProviderInstanceValidationError is the
1595 // validation error returned by
1596 // CommonTlsContext_CertificateProviderInstance.Validate if the designated
1597 // constraints aren't met.
1598 type CommonTlsContext_CertificateProviderInstanceValidationError struct {
1599 field string
1600 reason string
1601 cause error
1602 key bool
1603 }
1604
1605 // Field function returns field value.
1606 func (e CommonTlsContext_CertificateProviderInstanceValidationError) Field() string { return e.field }
1607
1608 // Reason function returns reason value.
1609 func (e CommonTlsContext_CertificateProviderInstanceValidationError) Reason() string { return e.reason }
1610
1611 // Cause function returns cause value.
1612 func (e CommonTlsContext_CertificateProviderInstanceValidationError) Cause() error { return e.cause }
1613
1614 // Key function returns key value.
1615 func (e CommonTlsContext_CertificateProviderInstanceValidationError) Key() bool { return e.key }
1616
1617 // ErrorName returns error name.
1618 func (e CommonTlsContext_CertificateProviderInstanceValidationError) ErrorName() string {
1619 return "CommonTlsContext_CertificateProviderInstanceValidationError"
1620 }
1621
1622 // Error satisfies the builtin error interface
1623 func (e CommonTlsContext_CertificateProviderInstanceValidationError) Error() string {
1624 cause := ""
1625 if e.cause != nil {
1626 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1627 }
1628
1629 key := ""
1630 if e.key {
1631 key = "key for "
1632 }
1633
1634 return fmt.Sprintf(
1635 "invalid %sCommonTlsContext_CertificateProviderInstance.%s: %s%s",
1636 key,
1637 e.field,
1638 e.reason,
1639 cause)
1640 }
1641
1642 var _ error = CommonTlsContext_CertificateProviderInstanceValidationError{}
1643
1644 var _ interface {
1645 Field() string
1646 Reason() string
1647 Key() bool
1648 Cause() error
1649 ErrorName() string
1650 } = CommonTlsContext_CertificateProviderInstanceValidationError{}
1651
1652 // Validate checks the field values on
1653 // CommonTlsContext_CombinedCertificateValidationContext with the rules
1654 // defined in the proto definition for this message. If any rules are
1655 // violated, the first error encountered is returned, or nil if there are no violations.
1656 func (m *CommonTlsContext_CombinedCertificateValidationContext) Validate() error {
1657 return m.validate(false)
1658 }
1659
1660 // ValidateAll checks the field values on
1661 // CommonTlsContext_CombinedCertificateValidationContext with the rules
1662 // defined in the proto definition for this message. If any rules are
1663 // violated, the result is a list of violation errors wrapped in
1664 // CommonTlsContext_CombinedCertificateValidationContextMultiError, or nil if
1665 // none found.
1666 func (m *CommonTlsContext_CombinedCertificateValidationContext) ValidateAll() error {
1667 return m.validate(true)
1668 }
1669
1670 func (m *CommonTlsContext_CombinedCertificateValidationContext) validate(all bool) error {
1671 if m == nil {
1672 return nil
1673 }
1674
1675 var errors []error
1676
1677 if m.GetDefaultValidationContext() == nil {
1678 err := CommonTlsContext_CombinedCertificateValidationContextValidationError{
1679 field: "DefaultValidationContext",
1680 reason: "value is required",
1681 }
1682 if !all {
1683 return err
1684 }
1685 errors = append(errors, err)
1686 }
1687
1688 if all {
1689 switch v := interface{}(m.GetDefaultValidationContext()).(type) {
1690 case interface{ ValidateAll() error }:
1691 if err := v.ValidateAll(); err != nil {
1692 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1693 field: "DefaultValidationContext",
1694 reason: "embedded message failed validation",
1695 cause: err,
1696 })
1697 }
1698 case interface{ Validate() error }:
1699 if err := v.Validate(); err != nil {
1700 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1701 field: "DefaultValidationContext",
1702 reason: "embedded message failed validation",
1703 cause: err,
1704 })
1705 }
1706 }
1707 } else if v, ok := interface{}(m.GetDefaultValidationContext()).(interface{ Validate() error }); ok {
1708 if err := v.Validate(); err != nil {
1709 return CommonTlsContext_CombinedCertificateValidationContextValidationError{
1710 field: "DefaultValidationContext",
1711 reason: "embedded message failed validation",
1712 cause: err,
1713 }
1714 }
1715 }
1716
1717 if m.GetValidationContextSdsSecretConfig() == nil {
1718 err := CommonTlsContext_CombinedCertificateValidationContextValidationError{
1719 field: "ValidationContextSdsSecretConfig",
1720 reason: "value is required",
1721 }
1722 if !all {
1723 return err
1724 }
1725 errors = append(errors, err)
1726 }
1727
1728 if all {
1729 switch v := interface{}(m.GetValidationContextSdsSecretConfig()).(type) {
1730 case interface{ ValidateAll() error }:
1731 if err := v.ValidateAll(); err != nil {
1732 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1733 field: "ValidationContextSdsSecretConfig",
1734 reason: "embedded message failed validation",
1735 cause: err,
1736 })
1737 }
1738 case interface{ Validate() error }:
1739 if err := v.Validate(); err != nil {
1740 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1741 field: "ValidationContextSdsSecretConfig",
1742 reason: "embedded message failed validation",
1743 cause: err,
1744 })
1745 }
1746 }
1747 } else if v, ok := interface{}(m.GetValidationContextSdsSecretConfig()).(interface{ Validate() error }); ok {
1748 if err := v.Validate(); err != nil {
1749 return CommonTlsContext_CombinedCertificateValidationContextValidationError{
1750 field: "ValidationContextSdsSecretConfig",
1751 reason: "embedded message failed validation",
1752 cause: err,
1753 }
1754 }
1755 }
1756
1757 if all {
1758 switch v := interface{}(m.GetValidationContextCertificateProvider()).(type) {
1759 case interface{ ValidateAll() error }:
1760 if err := v.ValidateAll(); err != nil {
1761 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1762 field: "ValidationContextCertificateProvider",
1763 reason: "embedded message failed validation",
1764 cause: err,
1765 })
1766 }
1767 case interface{ Validate() error }:
1768 if err := v.Validate(); err != nil {
1769 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1770 field: "ValidationContextCertificateProvider",
1771 reason: "embedded message failed validation",
1772 cause: err,
1773 })
1774 }
1775 }
1776 } else if v, ok := interface{}(m.GetValidationContextCertificateProvider()).(interface{ Validate() error }); ok {
1777 if err := v.Validate(); err != nil {
1778 return CommonTlsContext_CombinedCertificateValidationContextValidationError{
1779 field: "ValidationContextCertificateProvider",
1780 reason: "embedded message failed validation",
1781 cause: err,
1782 }
1783 }
1784 }
1785
1786 if all {
1787 switch v := interface{}(m.GetValidationContextCertificateProviderInstance()).(type) {
1788 case interface{ ValidateAll() error }:
1789 if err := v.ValidateAll(); err != nil {
1790 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1791 field: "ValidationContextCertificateProviderInstance",
1792 reason: "embedded message failed validation",
1793 cause: err,
1794 })
1795 }
1796 case interface{ Validate() error }:
1797 if err := v.Validate(); err != nil {
1798 errors = append(errors, CommonTlsContext_CombinedCertificateValidationContextValidationError{
1799 field: "ValidationContextCertificateProviderInstance",
1800 reason: "embedded message failed validation",
1801 cause: err,
1802 })
1803 }
1804 }
1805 } else if v, ok := interface{}(m.GetValidationContextCertificateProviderInstance()).(interface{ Validate() error }); ok {
1806 if err := v.Validate(); err != nil {
1807 return CommonTlsContext_CombinedCertificateValidationContextValidationError{
1808 field: "ValidationContextCertificateProviderInstance",
1809 reason: "embedded message failed validation",
1810 cause: err,
1811 }
1812 }
1813 }
1814
1815 if len(errors) > 0 {
1816 return CommonTlsContext_CombinedCertificateValidationContextMultiError(errors)
1817 }
1818
1819 return nil
1820 }
1821
1822 // CommonTlsContext_CombinedCertificateValidationContextMultiError is an error
1823 // wrapping multiple validation errors returned by
1824 // CommonTlsContext_CombinedCertificateValidationContext.ValidateAll() if the
1825 // designated constraints aren't met.
1826 type CommonTlsContext_CombinedCertificateValidationContextMultiError []error
1827
1828 // Error returns a concatenation of all the error messages it wraps.
1829 func (m CommonTlsContext_CombinedCertificateValidationContextMultiError) Error() string {
1830 var msgs []string
1831 for _, err := range m {
1832 msgs = append(msgs, err.Error())
1833 }
1834 return strings.Join(msgs, "; ")
1835 }
1836
1837 // AllErrors returns a list of validation violation errors.
1838 func (m CommonTlsContext_CombinedCertificateValidationContextMultiError) AllErrors() []error {
1839 return m
1840 }
1841
1842 // CommonTlsContext_CombinedCertificateValidationContextValidationError is the
1843 // validation error returned by
1844 // CommonTlsContext_CombinedCertificateValidationContext.Validate if the
1845 // designated constraints aren't met.
1846 type CommonTlsContext_CombinedCertificateValidationContextValidationError struct {
1847 field string
1848 reason string
1849 cause error
1850 key bool
1851 }
1852
1853 // Field function returns field value.
1854 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Field() string {
1855 return e.field
1856 }
1857
1858 // Reason function returns reason value.
1859 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Reason() string {
1860 return e.reason
1861 }
1862
1863 // Cause function returns cause value.
1864 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Cause() error {
1865 return e.cause
1866 }
1867
1868 // Key function returns key value.
1869 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Key() bool {
1870 return e.key
1871 }
1872
1873 // ErrorName returns error name.
1874 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) ErrorName() string {
1875 return "CommonTlsContext_CombinedCertificateValidationContextValidationError"
1876 }
1877
1878 // Error satisfies the builtin error interface
1879 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Error() string {
1880 cause := ""
1881 if e.cause != nil {
1882 cause = fmt.Sprintf(" | caused by: %v", e.cause)
1883 }
1884
1885 key := ""
1886 if e.key {
1887 key = "key for "
1888 }
1889
1890 return fmt.Sprintf(
1891 "invalid %sCommonTlsContext_CombinedCertificateValidationContext.%s: %s%s",
1892 key,
1893 e.field,
1894 e.reason,
1895 cause)
1896 }
1897
1898 var _ error = CommonTlsContext_CombinedCertificateValidationContextValidationError{}
1899
1900 var _ interface {
1901 Field() string
1902 Reason() string
1903 Key() bool
1904 Cause() error
1905 ErrorName() string
1906 } = CommonTlsContext_CombinedCertificateValidationContextValidationError{}