Debian Codegraph @

envoy/config/endpoint/v3/endpoint.pb.validate.go

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