Debian Codegraph @

envoy/extensions/transport_sockets/tls/v3/secret.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/secret.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 GenericSecret with the rules defined in
40 // the proto definition for this message. If any rules are violated, the first
41 // error encountered is returned, or nil if there are no violations.
42 func (m *GenericSecret) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on GenericSecret with the rules defined
47 // in the proto definition for this message. If any rules are violated, the
48 // result is a list of violation errors wrapped in GenericSecretMultiError, or
49 // nil if none found.
50 func (m *GenericSecret) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *GenericSecret) 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.GetSecret()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, GenericSecretValidationError{
66 field: "Secret",
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, GenericSecretValidationError{
74 field: "Secret",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetSecret()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return GenericSecretValidationError{
83 field: "Secret",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if len(errors) > 0 {
91 return GenericSecretMultiError(errors)
92 }
93
94 return nil
95 }
96
97 // GenericSecretMultiError is an error wrapping multiple validation errors
98 // returned by GenericSecret.ValidateAll() if the designated constraints
99 // aren't met.
100 type GenericSecretMultiError []error
101
102 // Error returns a concatenation of all the error messages it wraps.
103 func (m GenericSecretMultiError) Error() string {
104 var msgs []string
105 for _, err := range m {
106 msgs = append(msgs, err.Error())
107 }
108 return strings.Join(msgs, "; ")
109 }
110
111 // AllErrors returns a list of validation violation errors.
112 func (m GenericSecretMultiError) AllErrors() []error { return m }
113
114 // GenericSecretValidationError is the validation error returned by
115 // GenericSecret.Validate if the designated constraints aren't met.
116 type GenericSecretValidationError struct {
117 field string
118 reason string
119 cause error
120 key bool
121 }
122
123 // Field function returns field value.
124 func (e GenericSecretValidationError) Field() string { return e.field }
125
126 // Reason function returns reason value.
127 func (e GenericSecretValidationError) Reason() string { return e.reason }
128
129 // Cause function returns cause value.
130 func (e GenericSecretValidationError) Cause() error { return e.cause }
131
132 // Key function returns key value.
133 func (e GenericSecretValidationError) Key() bool { return e.key }
134
135 // ErrorName returns error name.
136 func (e GenericSecretValidationError) ErrorName() string { return "GenericSecretValidationError" }
137
138 // Error satisfies the builtin error interface
139 func (e GenericSecretValidationError) Error() string {
140 cause := ""
141 if e.cause != nil {
142 cause = fmt.Sprintf(" | caused by: %v", e.cause)
143 }
144
145 key := ""
146 if e.key {
147 key = "key for "
148 }
149
150 return fmt.Sprintf(
151 "invalid %sGenericSecret.%s: %s%s",
152 key,
153 e.field,
154 e.reason,
155 cause)
156 }
157
158 var _ error = GenericSecretValidationError{}
159
160 var _ interface {
161 Field() string
162 Reason() string
163 Key() bool
164 Cause() error
165 ErrorName() string
166 } = GenericSecretValidationError{}
167
168 // Validate checks the field values on SdsSecretConfig with the rules defined
169 // in the proto definition for this message. If any rules are violated, the
170 // first error encountered is returned, or nil if there are no violations.
171 func (m *SdsSecretConfig) Validate() error {
172 return m.validate(false)
173 }
174
175 // ValidateAll checks the field values on SdsSecretConfig with the rules
176 // defined in the proto definition for this message. If any rules are
177 // violated, the result is a list of violation errors wrapped in
178 // SdsSecretConfigMultiError, or nil if none found.
179 func (m *SdsSecretConfig) ValidateAll() error {
180 return m.validate(true)
181 }
182
183 func (m *SdsSecretConfig) validate(all bool) error {
184 if m == nil {
185 return nil
186 }
187
188 var errors []error
189
190 if utf8.RuneCountInString(m.GetName()) < 1 {
191 err := SdsSecretConfigValidationError{
192 field: "Name",
193 reason: "value length must be at least 1 runes",
194 }
195 if !all {
196 return err
197 }
198 errors = append(errors, err)
199 }
200
201 if all {
202 switch v := interface{}(m.GetSdsConfig()).(type) {
203 case interface{ ValidateAll() error }:
204 if err := v.ValidateAll(); err != nil {
205 errors = append(errors, SdsSecretConfigValidationError{
206 field: "SdsConfig",
207 reason: "embedded message failed validation",
208 cause: err,
209 })
210 }
211 case interface{ Validate() error }:
212 if err := v.Validate(); err != nil {
213 errors = append(errors, SdsSecretConfigValidationError{
214 field: "SdsConfig",
215 reason: "embedded message failed validation",
216 cause: err,
217 })
218 }
219 }
220 } else if v, ok := interface{}(m.GetSdsConfig()).(interface{ Validate() error }); ok {
221 if err := v.Validate(); err != nil {
222 return SdsSecretConfigValidationError{
223 field: "SdsConfig",
224 reason: "embedded message failed validation",
225 cause: err,
226 }
227 }
228 }
229
230 if len(errors) > 0 {
231 return SdsSecretConfigMultiError(errors)
232 }
233
234 return nil
235 }
236
237 // SdsSecretConfigMultiError is an error wrapping multiple validation errors
238 // returned by SdsSecretConfig.ValidateAll() if the designated constraints
239 // aren't met.
240 type SdsSecretConfigMultiError []error
241
242 // Error returns a concatenation of all the error messages it wraps.
243 func (m SdsSecretConfigMultiError) Error() string {
244 var msgs []string
245 for _, err := range m {
246 msgs = append(msgs, err.Error())
247 }
248 return strings.Join(msgs, "; ")
249 }
250
251 // AllErrors returns a list of validation violation errors.
252 func (m SdsSecretConfigMultiError) AllErrors() []error { return m }
253
254 // SdsSecretConfigValidationError is the validation error returned by
255 // SdsSecretConfig.Validate if the designated constraints aren't met.
256 type SdsSecretConfigValidationError struct {
257 field string
258 reason string
259 cause error
260 key bool
261 }
262
263 // Field function returns field value.
264 func (e SdsSecretConfigValidationError) Field() string { return e.field }
265
266 // Reason function returns reason value.
267 func (e SdsSecretConfigValidationError) Reason() string { return e.reason }
268
269 // Cause function returns cause value.
270 func (e SdsSecretConfigValidationError) Cause() error { return e.cause }
271
272 // Key function returns key value.
273 func (e SdsSecretConfigValidationError) Key() bool { return e.key }
274
275 // ErrorName returns error name.
276 func (e SdsSecretConfigValidationError) ErrorName() string { return "SdsSecretConfigValidationError" }
277
278 // Error satisfies the builtin error interface
279 func (e SdsSecretConfigValidationError) Error() string {
280 cause := ""
281 if e.cause != nil {
282 cause = fmt.Sprintf(" | caused by: %v", e.cause)
283 }
284
285 key := ""
286 if e.key {
287 key = "key for "
288 }
289
290 return fmt.Sprintf(
291 "invalid %sSdsSecretConfig.%s: %s%s",
292 key,
293 e.field,
294 e.reason,
295 cause)
296 }
297
298 var _ error = SdsSecretConfigValidationError{}
299
300 var _ interface {
301 Field() string
302 Reason() string
303 Key() bool
304 Cause() error
305 ErrorName() string
306 } = SdsSecretConfigValidationError{}
307
308 // Validate checks the field values on Secret with the rules defined in the
309 // proto definition for this message. If any rules are violated, the first
310 // error encountered is returned, or nil if there are no violations.
311 func (m *Secret) Validate() error {
312 return m.validate(false)
313 }
314
315 // ValidateAll checks the field values on Secret with the rules defined in the
316 // proto definition for this message. If any rules are violated, the result is
317 // a list of violation errors wrapped in SecretMultiError, or nil if none found.
318 func (m *Secret) ValidateAll() error {
319 return m.validate(true)
320 }
321
322 func (m *Secret) validate(all bool) error {
323 if m == nil {
324 return nil
325 }
326
327 var errors []error
328
329 // no validation rules for Name
330
331 switch v := m.Type.(type) {
332 case *Secret_TlsCertificate:
333 if v == nil {
334 err := SecretValidationError{
335 field: "Type",
336 reason: "oneof value cannot be a typed-nil",
337 }
338 if !all {
339 return err
340 }
341 errors = append(errors, err)
342 }
343
344 if all {
345 switch v := interface{}(m.GetTlsCertificate()).(type) {
346 case interface{ ValidateAll() error }:
347 if err := v.ValidateAll(); err != nil {
348 errors = append(errors, SecretValidationError{
349 field: "TlsCertificate",
350 reason: "embedded message failed validation",
351 cause: err,
352 })
353 }
354 case interface{ Validate() error }:
355 if err := v.Validate(); err != nil {
356 errors = append(errors, SecretValidationError{
357 field: "TlsCertificate",
358 reason: "embedded message failed validation",
359 cause: err,
360 })
361 }
362 }
363 } else if v, ok := interface{}(m.GetTlsCertificate()).(interface{ Validate() error }); ok {
364 if err := v.Validate(); err != nil {
365 return SecretValidationError{
366 field: "TlsCertificate",
367 reason: "embedded message failed validation",
368 cause: err,
369 }
370 }
371 }
372
373 case *Secret_SessionTicketKeys:
374 if v == nil {
375 err := SecretValidationError{
376 field: "Type",
377 reason: "oneof value cannot be a typed-nil",
378 }
379 if !all {
380 return err
381 }
382 errors = append(errors, err)
383 }
384
385 if all {
386 switch v := interface{}(m.GetSessionTicketKeys()).(type) {
387 case interface{ ValidateAll() error }:
388 if err := v.ValidateAll(); err != nil {
389 errors = append(errors, SecretValidationError{
390 field: "SessionTicketKeys",
391 reason: "embedded message failed validation",
392 cause: err,
393 })
394 }
395 case interface{ Validate() error }:
396 if err := v.Validate(); err != nil {
397 errors = append(errors, SecretValidationError{
398 field: "SessionTicketKeys",
399 reason: "embedded message failed validation",
400 cause: err,
401 })
402 }
403 }
404 } else if v, ok := interface{}(m.GetSessionTicketKeys()).(interface{ Validate() error }); ok {
405 if err := v.Validate(); err != nil {
406 return SecretValidationError{
407 field: "SessionTicketKeys",
408 reason: "embedded message failed validation",
409 cause: err,
410 }
411 }
412 }
413
414 case *Secret_ValidationContext:
415 if v == nil {
416 err := SecretValidationError{
417 field: "Type",
418 reason: "oneof value cannot be a typed-nil",
419 }
420 if !all {
421 return err
422 }
423 errors = append(errors, err)
424 }
425
426 if all {
427 switch v := interface{}(m.GetValidationContext()).(type) {
428 case interface{ ValidateAll() error }:
429 if err := v.ValidateAll(); err != nil {
430 errors = append(errors, SecretValidationError{
431 field: "ValidationContext",
432 reason: "embedded message failed validation",
433 cause: err,
434 })
435 }
436 case interface{ Validate() error }:
437 if err := v.Validate(); err != nil {
438 errors = append(errors, SecretValidationError{
439 field: "ValidationContext",
440 reason: "embedded message failed validation",
441 cause: err,
442 })
443 }
444 }
445 } else if v, ok := interface{}(m.GetValidationContext()).(interface{ Validate() error }); ok {
446 if err := v.Validate(); err != nil {
447 return SecretValidationError{
448 field: "ValidationContext",
449 reason: "embedded message failed validation",
450 cause: err,
451 }
452 }
453 }
454
455 case *Secret_GenericSecret:
456 if v == nil {
457 err := SecretValidationError{
458 field: "Type",
459 reason: "oneof value cannot be a typed-nil",
460 }
461 if !all {
462 return err
463 }
464 errors = append(errors, err)
465 }
466
467 if all {
468 switch v := interface{}(m.GetGenericSecret()).(type) {
469 case interface{ ValidateAll() error }:
470 if err := v.ValidateAll(); err != nil {
471 errors = append(errors, SecretValidationError{
472 field: "GenericSecret",
473 reason: "embedded message failed validation",
474 cause: err,
475 })
476 }
477 case interface{ Validate() error }:
478 if err := v.Validate(); err != nil {
479 errors = append(errors, SecretValidationError{
480 field: "GenericSecret",
481 reason: "embedded message failed validation",
482 cause: err,
483 })
484 }
485 }
486 } else if v, ok := interface{}(m.GetGenericSecret()).(interface{ Validate() error }); ok {
487 if err := v.Validate(); err != nil {
488 return SecretValidationError{
489 field: "GenericSecret",
490 reason: "embedded message failed validation",
491 cause: err,
492 }
493 }
494 }
495
496 default:
497 _ = v // ensures v is used
498 }
499
500 if len(errors) > 0 {
501 return SecretMultiError(errors)
502 }
503
504 return nil
505 }
506
507 // SecretMultiError is an error wrapping multiple validation errors returned by
508 // Secret.ValidateAll() if the designated constraints aren't met.
509 type SecretMultiError []error
510
511 // Error returns a concatenation of all the error messages it wraps.
512 func (m SecretMultiError) Error() string {
513 var msgs []string
514 for _, err := range m {
515 msgs = append(msgs, err.Error())
516 }
517 return strings.Join(msgs, "; ")
518 }
519
520 // AllErrors returns a list of validation violation errors.
521 func (m SecretMultiError) AllErrors() []error { return m }
522
523 // SecretValidationError is the validation error returned by Secret.Validate if
524 // the designated constraints aren't met.
525 type SecretValidationError struct {
526 field string
527 reason string
528 cause error
529 key bool
530 }
531
532 // Field function returns field value.
533 func (e SecretValidationError) Field() string { return e.field }
534
535 // Reason function returns reason value.
536 func (e SecretValidationError) Reason() string { return e.reason }
537
538 // Cause function returns cause value.
539 func (e SecretValidationError) Cause() error { return e.cause }
540
541 // Key function returns key value.
542 func (e SecretValidationError) Key() bool { return e.key }
543
544 // ErrorName returns error name.
545 func (e SecretValidationError) ErrorName() string { return "SecretValidationError" }
546
547 // Error satisfies the builtin error interface
548 func (e SecretValidationError) Error() string {
549 cause := ""
550 if e.cause != nil {
551 cause = fmt.Sprintf(" | caused by: %v", e.cause)
552 }
553
554 key := ""
555 if e.key {
556 key = "key for "
557 }
558
559 return fmt.Sprintf(
560 "invalid %sSecret.%s: %s%s",
561 key,
562 e.field,
563 e.reason,
564 cause)
565 }
566
567 var _ error = SecretValidationError{}
568
569 var _ interface {
570 Field() string
571 Reason() string
572 Key() bool
573 Cause() error
574 ErrorName() string
575 } = SecretValidationError{}