| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/service/discovery/v2/hds.proto |
| 4 |
|
| 5 |
package discoveryv2 |
| 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 |
core "github.com/envoyproxy/go-control-plane/envoy/api/v2/core" |
| 23 |
) |
| 24 |
|
| 25 |
// ensure the imports are used |
| 26 |
var ( |
| 27 |
_ = bytes.MinRead |
| 28 |
_ = errors.New("") |
| 29 |
_ = fmt.Print |
| 30 |
_ = utf8.UTFMax |
| 31 |
_ = (*regexp.Regexp)(nil) |
| 32 |
_ = (*strings.Reader)(nil) |
| 33 |
_ = net.IPv4len |
| 34 |
_ = time.Duration(0) |
| 35 |
_ = (*url.URL)(nil) |
| 36 |
_ = (*mail.Address)(nil) |
| 37 |
_ = anypb.Any{} |
| 38 |
_ = sort.Sort |
| 39 |
|
| 40 |
_ = core.HealthStatus(0) |
| 41 |
) |
| 42 |
|
| 43 |
// Validate checks the field values on Capability with the rules defined in the |
| 44 |
// proto definition for this message. If any rules are violated, the first |
| 45 |
// error encountered is returned, or nil if there are no violations. |
| 46 |
func (m *Capability) Validate() error { |
| 47 |
return m.validate(false) |
| 48 |
} |
| 49 |
|
| 50 |
// ValidateAll checks the field values on Capability with the rules defined in |
| 51 |
// the proto definition for this message. If any rules are violated, the |
| 52 |
// result is a list of violation errors wrapped in CapabilityMultiError, or |
| 53 |
// nil if none found. |
| 54 |
func (m *Capability) ValidateAll() error { |
| 55 |
return m.validate(true) |
| 56 |
} |
| 57 |
|
| 58 |
func (m *Capability) validate(all bool) error { |
| 59 |
if m == nil { |
| 60 |
return nil |
| 61 |
} |
| 62 |
|
| 63 |
var errors []error |
| 64 |
|
| 65 |
if len(errors) > 0 { |
| 66 |
return CapabilityMultiError(errors) |
| 67 |
} |
| 68 |
|
| 69 |
return nil |
| 70 |
} |
| 71 |
|
| 72 |
// CapabilityMultiError is an error wrapping multiple validation errors |
| 73 |
// returned by Capability.ValidateAll() if the designated constraints aren't met. |
| 74 |
type CapabilityMultiError []error |
| 75 |
|
| 76 |
// Error returns a concatenation of all the error messages it wraps. |
| 77 |
func (m CapabilityMultiError) Error() string { |
| 78 |
var msgs []string |
| 79 |
for _, err := range m { |
| 80 |
msgs = append(msgs, err.Error()) |
| 81 |
} |
| 82 |
return strings.Join(msgs, "; ") |
| 83 |
} |
| 84 |
|
| 85 |
// AllErrors returns a list of validation violation errors. |
| 86 |
func (m CapabilityMultiError) AllErrors() []error { return m } |
| 87 |
|
| 88 |
// CapabilityValidationError is the validation error returned by |
| 89 |
// Capability.Validate if the designated constraints aren't met. |
| 90 |
type CapabilityValidationError struct { |
| 91 |
field string |
| 92 |
reason string |
| 93 |
cause error |
| 94 |
key bool |
| 95 |
} |
| 96 |
|
| 97 |
// Field function returns field value. |
| 98 |
func (e CapabilityValidationError) Field() string { return e.field } |
| 99 |
|
| 100 |
// Reason function returns reason value. |
| 101 |
func (e CapabilityValidationError) Reason() string { return e.reason } |
| 102 |
|
| 103 |
// Cause function returns cause value. |
| 104 |
func (e CapabilityValidationError) Cause() error { return e.cause } |
| 105 |
|
| 106 |
// Key function returns key value. |
| 107 |
func (e CapabilityValidationError) Key() bool { return e.key } |
| 108 |
|
| 109 |
// ErrorName returns error name. |
| 110 |
func (e CapabilityValidationError) ErrorName() string { return "CapabilityValidationError" } |
| 111 |
|
| 112 |
// Error satisfies the builtin error interface |
| 113 |
func (e CapabilityValidationError) Error() string { |
| 114 |
cause := "" |
| 115 |
if e.cause != nil { |
| 116 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 117 |
} |
| 118 |
|
| 119 |
key := "" |
| 120 |
if e.key { |
| 121 |
key = "key for " |
| 122 |
} |
| 123 |
|
| 124 |
return fmt.Sprintf( |
| 125 |
"invalid %sCapability.%s: %s%s", |
| 126 |
key, |
| 127 |
e.field, |
| 128 |
e.reason, |
| 129 |
cause) |
| 130 |
} |
| 131 |
|
| 132 |
var _ error = CapabilityValidationError{} |
| 133 |
|
| 134 |
var _ interface { |
| 135 |
Field() string |
| 136 |
Reason() string |
| 137 |
Key() bool |
| 138 |
Cause() error |
| 139 |
ErrorName() string |
| 140 |
} = CapabilityValidationError{} |
| 141 |
|
| 142 |
// Validate checks the field values on HealthCheckRequest with the rules |
| 143 |
// defined in the proto definition for this message. If any rules are |
| 144 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 145 |
func (m *HealthCheckRequest) Validate() error { |
| 146 |
return m.validate(false) |
| 147 |
} |
| 148 |
|
| 149 |
// ValidateAll checks the field values on HealthCheckRequest with the rules |
| 150 |
// defined in the proto definition for this message. If any rules are |
| 151 |
// violated, the result is a list of violation errors wrapped in |
| 152 |
// HealthCheckRequestMultiError, or nil if none found. |
| 153 |
func (m *HealthCheckRequest) ValidateAll() error { |
| 154 |
return m.validate(true) |
| 155 |
} |
| 156 |
|
| 157 |
func (m *HealthCheckRequest) validate(all bool) error { |
| 158 |
if m == nil { |
| 159 |
return nil |
| 160 |
} |
| 161 |
|
| 162 |
var errors []error |
| 163 |
|
| 164 |
if all { |
| 165 |
switch v := interface{}(m.GetNode()).(type) { |
| 166 |
case interface{ ValidateAll() error }: |
| 167 |
if err := v.ValidateAll(); err != nil { |
| 168 |
errors = append(errors, HealthCheckRequestValidationError{ |
| 169 |
field: "Node", |
| 170 |
reason: "embedded message failed validation", |
| 171 |
cause: err, |
| 172 |
}) |
| 173 |
} |
| 174 |
case interface{ Validate() error }: |
| 175 |
if err := v.Validate(); err != nil { |
| 176 |
errors = append(errors, HealthCheckRequestValidationError{ |
| 177 |
field: "Node", |
| 178 |
reason: "embedded message failed validation", |
| 179 |
cause: err, |
| 180 |
}) |
| 181 |
} |
| 182 |
} |
| 183 |
} else if v, ok := interface{}(m.GetNode()).(interface{ Validate() error }); ok { |
| 184 |
if err := v.Validate(); err != nil { |
| 185 |
return HealthCheckRequestValidationError{ |
| 186 |
field: "Node", |
| 187 |
reason: "embedded message failed validation", |
| 188 |
cause: err, |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
if all { |
| 194 |
switch v := interface{}(m.GetCapability()).(type) { |
| 195 |
case interface{ ValidateAll() error }: |
| 196 |
if err := v.ValidateAll(); err != nil { |
| 197 |
errors = append(errors, HealthCheckRequestValidationError{ |
| 198 |
field: "Capability", |
| 199 |
reason: "embedded message failed validation", |
| 200 |
cause: err, |
| 201 |
}) |
| 202 |
} |
| 203 |
case interface{ Validate() error }: |
| 204 |
if err := v.Validate(); err != nil { |
| 205 |
errors = append(errors, HealthCheckRequestValidationError{ |
| 206 |
field: "Capability", |
| 207 |
reason: "embedded message failed validation", |
| 208 |
cause: err, |
| 209 |
}) |
| 210 |
} |
| 211 |
} |
| 212 |
} else if v, ok := interface{}(m.GetCapability()).(interface{ Validate() error }); ok { |
| 213 |
if err := v.Validate(); err != nil { |
| 214 |
return HealthCheckRequestValidationError{ |
| 215 |
field: "Capability", |
| 216 |
reason: "embedded message failed validation", |
| 217 |
cause: err, |
| 218 |
} |
| 219 |
} |
| 220 |
} |
| 221 |
|
| 222 |
if len(errors) > 0 { |
| 223 |
return HealthCheckRequestMultiError(errors) |
| 224 |
} |
| 225 |
|
| 226 |
return nil |
| 227 |
} |
| 228 |
|
| 229 |
// HealthCheckRequestMultiError is an error wrapping multiple validation errors |
| 230 |
// returned by HealthCheckRequest.ValidateAll() if the designated constraints |
| 231 |
// aren't met. |
| 232 |
type HealthCheckRequestMultiError []error |
| 233 |
|
| 234 |
// Error returns a concatenation of all the error messages it wraps. |
| 235 |
func (m HealthCheckRequestMultiError) Error() string { |
| 236 |
var msgs []string |
| 237 |
for _, err := range m { |
| 238 |
msgs = append(msgs, err.Error()) |
| 239 |
} |
| 240 |
return strings.Join(msgs, "; ") |
| 241 |
} |
| 242 |
|
| 243 |
// AllErrors returns a list of validation violation errors. |
| 244 |
func (m HealthCheckRequestMultiError) AllErrors() []error { return m } |
| 245 |
|
| 246 |
// HealthCheckRequestValidationError is the validation error returned by |
| 247 |
// HealthCheckRequest.Validate if the designated constraints aren't met. |
| 248 |
type HealthCheckRequestValidationError struct { |
| 249 |
field string |
| 250 |
reason string |
| 251 |
cause error |
| 252 |
key bool |
| 253 |
} |
| 254 |
|
| 255 |
// Field function returns field value. |
| 256 |
func (e HealthCheckRequestValidationError) Field() string { return e.field } |
| 257 |
|
| 258 |
// Reason function returns reason value. |
| 259 |
func (e HealthCheckRequestValidationError) Reason() string { return e.reason } |
| 260 |
|
| 261 |
// Cause function returns cause value. |
| 262 |
func (e HealthCheckRequestValidationError) Cause() error { return e.cause } |
| 263 |
|
| 264 |
// Key function returns key value. |
| 265 |
func (e HealthCheckRequestValidationError) Key() bool { return e.key } |
| 266 |
|
| 267 |
// ErrorName returns error name. |
| 268 |
func (e HealthCheckRequestValidationError) ErrorName() string { |
| 269 |
return "HealthCheckRequestValidationError" |
| 270 |
} |
| 271 |
|
| 272 |
// Error satisfies the builtin error interface |
| 273 |
func (e HealthCheckRequestValidationError) Error() string { |
| 274 |
cause := "" |
| 275 |
if e.cause != nil { |
| 276 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 277 |
} |
| 278 |
|
| 279 |
key := "" |
| 280 |
if e.key { |
| 281 |
key = "key for " |
| 282 |
} |
| 283 |
|
| 284 |
return fmt.Sprintf( |
| 285 |
"invalid %sHealthCheckRequest.%s: %s%s", |
| 286 |
key, |
| 287 |
e.field, |
| 288 |
e.reason, |
| 289 |
cause) |
| 290 |
} |
| 291 |
|
| 292 |
var _ error = HealthCheckRequestValidationError{} |
| 293 |
|
| 294 |
var _ interface { |
| 295 |
Field() string |
| 296 |
Reason() string |
| 297 |
Key() bool |
| 298 |
Cause() error |
| 299 |
ErrorName() string |
| 300 |
} = HealthCheckRequestValidationError{} |
| 301 |
|
| 302 |
// Validate checks the field values on EndpointHealth with the rules defined in |
| 303 |
// the proto definition for this message. If any rules are violated, the first |
| 304 |
// error encountered is returned, or nil if there are no violations. |
| 305 |
func (m *EndpointHealth) Validate() error { |
| 306 |
return m.validate(false) |
| 307 |
} |
| 308 |
|
| 309 |
// ValidateAll checks the field values on EndpointHealth with the rules defined |
| 310 |
// in the proto definition for this message. If any rules are violated, the |
| 311 |
// result is a list of violation errors wrapped in EndpointHealthMultiError, |
| 312 |
// or nil if none found. |
| 313 |
func (m *EndpointHealth) ValidateAll() error { |
| 314 |
return m.validate(true) |
| 315 |
} |
| 316 |
|
| 317 |
func (m *EndpointHealth) validate(all bool) error { |
| 318 |
if m == nil { |
| 319 |
return nil |
| 320 |
} |
| 321 |
|
| 322 |
var errors []error |
| 323 |
|
| 324 |
if all { |
| 325 |
switch v := interface{}(m.GetEndpoint()).(type) { |
| 326 |
case interface{ ValidateAll() error }: |
| 327 |
if err := v.ValidateAll(); err != nil { |
| 328 |
errors = append(errors, EndpointHealthValidationError{ |
| 329 |
field: "Endpoint", |
| 330 |
reason: "embedded message failed validation", |
| 331 |
cause: err, |
| 332 |
}) |
| 333 |
} |
| 334 |
case interface{ Validate() error }: |
| 335 |
if err := v.Validate(); err != nil { |
| 336 |
errors = append(errors, EndpointHealthValidationError{ |
| 337 |
field: "Endpoint", |
| 338 |
reason: "embedded message failed validation", |
| 339 |
cause: err, |
| 340 |
}) |
| 341 |
} |
| 342 |
} |
| 343 |
} else if v, ok := interface{}(m.GetEndpoint()).(interface{ Validate() error }); ok { |
| 344 |
if err := v.Validate(); err != nil { |
| 345 |
return EndpointHealthValidationError{ |
| 346 |
field: "Endpoint", |
| 347 |
reason: "embedded message failed validation", |
| 348 |
cause: err, |
| 349 |
} |
| 350 |
} |
| 351 |
} |
| 352 |
|
| 353 |
// no validation rules for HealthStatus |
| 354 |
|
| 355 |
if len(errors) > 0 { |
| 356 |
return EndpointHealthMultiError(errors) |
| 357 |
} |
| 358 |
|
| 359 |
return nil |
| 360 |
} |
| 361 |
|
| 362 |
// EndpointHealthMultiError is an error wrapping multiple validation errors |
| 363 |
// returned by EndpointHealth.ValidateAll() if the designated constraints |
| 364 |
// aren't met. |
| 365 |
type EndpointHealthMultiError []error |
| 366 |
|
| 367 |
// Error returns a concatenation of all the error messages it wraps. |
| 368 |
func (m EndpointHealthMultiError) Error() string { |
| 369 |
var msgs []string |
| 370 |
for _, err := range m { |
| 371 |
msgs = append(msgs, err.Error()) |
| 372 |
} |
| 373 |
return strings.Join(msgs, "; ") |
| 374 |
} |
| 375 |
|
| 376 |
// AllErrors returns a list of validation violation errors. |
| 377 |
func (m EndpointHealthMultiError) AllErrors() []error { return m } |
| 378 |
|
| 379 |
// EndpointHealthValidationError is the validation error returned by |
| 380 |
// EndpointHealth.Validate if the designated constraints aren't met. |
| 381 |
type EndpointHealthValidationError struct { |
| 382 |
field string |
| 383 |
reason string |
| 384 |
cause error |
| 385 |
key bool |
| 386 |
} |
| 387 |
|
| 388 |
// Field function returns field value. |
| 389 |
func (e EndpointHealthValidationError) Field() string { return e.field } |
| 390 |
|
| 391 |
// Reason function returns reason value. |
| 392 |
func (e EndpointHealthValidationError) Reason() string { return e.reason } |
| 393 |
|
| 394 |
// Cause function returns cause value. |
| 395 |
func (e EndpointHealthValidationError) Cause() error { return e.cause } |
| 396 |
|
| 397 |
// Key function returns key value. |
| 398 |
func (e EndpointHealthValidationError) Key() bool { return e.key } |
| 399 |
|
| 400 |
// ErrorName returns error name. |
| 401 |
func (e EndpointHealthValidationError) ErrorName() string { return "EndpointHealthValidationError" } |
| 402 |
|
| 403 |
// Error satisfies the builtin error interface |
| 404 |
func (e EndpointHealthValidationError) Error() string { |
| 405 |
cause := "" |
| 406 |
if e.cause != nil { |
| 407 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 408 |
} |
| 409 |
|
| 410 |
key := "" |
| 411 |
if e.key { |
| 412 |
key = "key for " |
| 413 |
} |
| 414 |
|
| 415 |
return fmt.Sprintf( |
| 416 |
"invalid %sEndpointHealth.%s: %s%s", |
| 417 |
key, |
| 418 |
e.field, |
| 419 |
e.reason, |
| 420 |
cause) |
| 421 |
} |
| 422 |
|
| 423 |
var _ error = EndpointHealthValidationError{} |
| 424 |
|
| 425 |
var _ interface { |
| 426 |
Field() string |
| 427 |
Reason() string |
| 428 |
Key() bool |
| 429 |
Cause() error |
| 430 |
ErrorName() string |
| 431 |
} = EndpointHealthValidationError{} |
| 432 |
|
| 433 |
// Validate checks the field values on EndpointHealthResponse with the rules |
| 434 |
// defined in the proto definition for this message. If any rules are |
| 435 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 436 |
func (m *EndpointHealthResponse) Validate() error { |
| 437 |
return m.validate(false) |
| 438 |
} |
| 439 |
|
| 440 |
// ValidateAll checks the field values on EndpointHealthResponse with the rules |
| 441 |
// defined in the proto definition for this message. If any rules are |
| 442 |
// violated, the result is a list of violation errors wrapped in |
| 443 |
// EndpointHealthResponseMultiError, or nil if none found. |
| 444 |
func (m *EndpointHealthResponse) ValidateAll() error { |
| 445 |
return m.validate(true) |
| 446 |
} |
| 447 |
|
| 448 |
func (m *EndpointHealthResponse) validate(all bool) error { |
| 449 |
if m == nil { |
| 450 |
return nil |
| 451 |
} |
| 452 |
|
| 453 |
var errors []error |
| 454 |
|
| 455 |
for idx, item := range m.GetEndpointsHealth() { |
| 456 |
_, _ = idx, item |
| 457 |
|
| 458 |
if all { |
| 459 |
switch v := interface{}(item).(type) { |
| 460 |
case interface{ ValidateAll() error }: |
| 461 |
if err := v.ValidateAll(); err != nil { |
| 462 |
errors = append(errors, EndpointHealthResponseValidationError{ |
| 463 |
field: fmt.Sprintf("EndpointsHealth[%v]", idx), |
| 464 |
reason: "embedded message failed validation", |
| 465 |
cause: err, |
| 466 |
}) |
| 467 |
} |
| 468 |
case interface{ Validate() error }: |
| 469 |
if err := v.Validate(); err != nil { |
| 470 |
errors = append(errors, EndpointHealthResponseValidationError{ |
| 471 |
field: fmt.Sprintf("EndpointsHealth[%v]", idx), |
| 472 |
reason: "embedded message failed validation", |
| 473 |
cause: err, |
| 474 |
}) |
| 475 |
} |
| 476 |
} |
| 477 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 478 |
if err := v.Validate(); err != nil { |
| 479 |
return EndpointHealthResponseValidationError{ |
| 480 |
field: fmt.Sprintf("EndpointsHealth[%v]", idx), |
| 481 |
reason: "embedded message failed validation", |
| 482 |
cause: err, |
| 483 |
} |
| 484 |
} |
| 485 |
} |
| 486 |
|
| 487 |
} |
| 488 |
|
| 489 |
if len(errors) > 0 { |
| 490 |
return EndpointHealthResponseMultiError(errors) |
| 491 |
} |
| 492 |
|
| 493 |
return nil |
| 494 |
} |
| 495 |
|
| 496 |
// EndpointHealthResponseMultiError is an error wrapping multiple validation |
| 497 |
// errors returned by EndpointHealthResponse.ValidateAll() if the designated |
| 498 |
// constraints aren't met. |
| 499 |
type EndpointHealthResponseMultiError []error |
| 500 |
|
| 501 |
// Error returns a concatenation of all the error messages it wraps. |
| 502 |
func (m EndpointHealthResponseMultiError) Error() string { |
| 503 |
var msgs []string |
| 504 |
for _, err := range m { |
| 505 |
msgs = append(msgs, err.Error()) |
| 506 |
} |
| 507 |
return strings.Join(msgs, "; ") |
| 508 |
} |
| 509 |
|
| 510 |
// AllErrors returns a list of validation violation errors. |
| 511 |
func (m EndpointHealthResponseMultiError) AllErrors() []error { return m } |
| 512 |
|
| 513 |
// EndpointHealthResponseValidationError is the validation error returned by |
| 514 |
// EndpointHealthResponse.Validate if the designated constraints aren't met. |
| 515 |
type EndpointHealthResponseValidationError struct { |
| 516 |
field string |
| 517 |
reason string |
| 518 |
cause error |
| 519 |
key bool |
| 520 |
} |
| 521 |
|
| 522 |
// Field function returns field value. |
| 523 |
func (e EndpointHealthResponseValidationError) Field() string { return e.field } |
| 524 |
|
| 525 |
// Reason function returns reason value. |
| 526 |
func (e EndpointHealthResponseValidationError) Reason() string { return e.reason } |
| 527 |
|
| 528 |
// Cause function returns cause value. |
| 529 |
func (e EndpointHealthResponseValidationError) Cause() error { return e.cause } |
| 530 |
|
| 531 |
// Key function returns key value. |
| 532 |
func (e EndpointHealthResponseValidationError) Key() bool { return e.key } |
| 533 |
|
| 534 |
// ErrorName returns error name. |
| 535 |
func (e EndpointHealthResponseValidationError) ErrorName() string { |
| 536 |
return "EndpointHealthResponseValidationError" |
| 537 |
} |
| 538 |
|
| 539 |
// Error satisfies the builtin error interface |
| 540 |
func (e EndpointHealthResponseValidationError) Error() string { |
| 541 |
cause := "" |
| 542 |
if e.cause != nil { |
| 543 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 544 |
} |
| 545 |
|
| 546 |
key := "" |
| 547 |
if e.key { |
| 548 |
key = "key for " |
| 549 |
} |
| 550 |
|
| 551 |
return fmt.Sprintf( |
| 552 |
"invalid %sEndpointHealthResponse.%s: %s%s", |
| 553 |
key, |
| 554 |
e.field, |
| 555 |
e.reason, |
| 556 |
cause) |
| 557 |
} |
| 558 |
|
| 559 |
var _ error = EndpointHealthResponseValidationError{} |
| 560 |
|
| 561 |
var _ interface { |
| 562 |
Field() string |
| 563 |
Reason() string |
| 564 |
Key() bool |
| 565 |
Cause() error |
| 566 |
ErrorName() string |
| 567 |
} = EndpointHealthResponseValidationError{} |
| 568 |
|
| 569 |
// Validate checks the field values on |
| 570 |
// HealthCheckRequestOrEndpointHealthResponse with the rules defined in the |
| 571 |
// proto definition for this message. If any rules are violated, the first |
| 572 |
// error encountered is returned, or nil if there are no violations. |
| 573 |
func (m *HealthCheckRequestOrEndpointHealthResponse) Validate() error { |
| 574 |
return m.validate(false) |
| 575 |
} |
| 576 |
|
| 577 |
// ValidateAll checks the field values on |
| 578 |
// HealthCheckRequestOrEndpointHealthResponse with the rules defined in the |
| 579 |
// proto definition for this message. If any rules are violated, the result is |
| 580 |
// a list of violation errors wrapped in |
| 581 |
// HealthCheckRequestOrEndpointHealthResponseMultiError, or nil if none found. |
| 582 |
func (m *HealthCheckRequestOrEndpointHealthResponse) ValidateAll() error { |
| 583 |
return m.validate(true) |
| 584 |
} |
| 585 |
|
| 586 |
func (m *HealthCheckRequestOrEndpointHealthResponse) validate(all bool) error { |
| 587 |
if m == nil { |
| 588 |
return nil |
| 589 |
} |
| 590 |
|
| 591 |
var errors []error |
| 592 |
|
| 593 |
switch v := m.RequestType.(type) { |
| 594 |
case *HealthCheckRequestOrEndpointHealthResponse_HealthCheckRequest: |
| 595 |
if v == nil { |
| 596 |
err := HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 597 |
field: "RequestType", |
| 598 |
reason: "oneof value cannot be a typed-nil", |
| 599 |
} |
| 600 |
if !all { |
| 601 |
return err |
| 602 |
} |
| 603 |
errors = append(errors, err) |
| 604 |
} |
| 605 |
|
| 606 |
if all { |
| 607 |
switch v := interface{}(m.GetHealthCheckRequest()).(type) { |
| 608 |
case interface{ ValidateAll() error }: |
| 609 |
if err := v.ValidateAll(); err != nil { |
| 610 |
errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 611 |
field: "HealthCheckRequest", |
| 612 |
reason: "embedded message failed validation", |
| 613 |
cause: err, |
| 614 |
}) |
| 615 |
} |
| 616 |
case interface{ Validate() error }: |
| 617 |
if err := v.Validate(); err != nil { |
| 618 |
errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 619 |
field: "HealthCheckRequest", |
| 620 |
reason: "embedded message failed validation", |
| 621 |
cause: err, |
| 622 |
}) |
| 623 |
} |
| 624 |
} |
| 625 |
} else if v, ok := interface{}(m.GetHealthCheckRequest()).(interface{ Validate() error }); ok { |
| 626 |
if err := v.Validate(); err != nil { |
| 627 |
return HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 628 |
field: "HealthCheckRequest", |
| 629 |
reason: "embedded message failed validation", |
| 630 |
cause: err, |
| 631 |
} |
| 632 |
} |
| 633 |
} |
| 634 |
|
| 635 |
case *HealthCheckRequestOrEndpointHealthResponse_EndpointHealthResponse: |
| 636 |
if v == nil { |
| 637 |
err := HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 638 |
field: "RequestType", |
| 639 |
reason: "oneof value cannot be a typed-nil", |
| 640 |
} |
| 641 |
if !all { |
| 642 |
return err |
| 643 |
} |
| 644 |
errors = append(errors, err) |
| 645 |
} |
| 646 |
|
| 647 |
if all { |
| 648 |
switch v := interface{}(m.GetEndpointHealthResponse()).(type) { |
| 649 |
case interface{ ValidateAll() error }: |
| 650 |
if err := v.ValidateAll(); err != nil { |
| 651 |
errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 652 |
field: "EndpointHealthResponse", |
| 653 |
reason: "embedded message failed validation", |
| 654 |
cause: err, |
| 655 |
}) |
| 656 |
} |
| 657 |
case interface{ Validate() error }: |
| 658 |
if err := v.Validate(); err != nil { |
| 659 |
errors = append(errors, HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 660 |
field: "EndpointHealthResponse", |
| 661 |
reason: "embedded message failed validation", |
| 662 |
cause: err, |
| 663 |
}) |
| 664 |
} |
| 665 |
} |
| 666 |
} else if v, ok := interface{}(m.GetEndpointHealthResponse()).(interface{ Validate() error }); ok { |
| 667 |
if err := v.Validate(); err != nil { |
| 668 |
return HealthCheckRequestOrEndpointHealthResponseValidationError{ |
| 669 |
field: "EndpointHealthResponse", |
| 670 |
reason: "embedded message failed validation", |
| 671 |
cause: err, |
| 672 |
} |
| 673 |
} |
| 674 |
} |
| 675 |
|
| 676 |
default: |
| 677 |
_ = v // ensures v is used |
| 678 |
} |
| 679 |
|
| 680 |
if len(errors) > 0 { |
| 681 |
return HealthCheckRequestOrEndpointHealthResponseMultiError(errors) |
| 682 |
} |
| 683 |
|
| 684 |
return nil |
| 685 |
} |
| 686 |
|
| 687 |
// HealthCheckRequestOrEndpointHealthResponseMultiError is an error wrapping |
| 688 |
// multiple validation errors returned by |
| 689 |
// HealthCheckRequestOrEndpointHealthResponse.ValidateAll() if the designated |
| 690 |
// constraints aren't met. |
| 691 |
type HealthCheckRequestOrEndpointHealthResponseMultiError []error |
| 692 |
|
| 693 |
// Error returns a concatenation of all the error messages it wraps. |
| 694 |
func (m HealthCheckRequestOrEndpointHealthResponseMultiError) Error() string { |
| 695 |
var msgs []string |
| 696 |
for _, err := range m { |
| 697 |
msgs = append(msgs, err.Error()) |
| 698 |
} |
| 699 |
return strings.Join(msgs, "; ") |
| 700 |
} |
| 701 |
|
| 702 |
// AllErrors returns a list of validation violation errors. |
| 703 |
func (m HealthCheckRequestOrEndpointHealthResponseMultiError) AllErrors() []error { return m } |
| 704 |
|
| 705 |
// HealthCheckRequestOrEndpointHealthResponseValidationError is the validation |
| 706 |
// error returned by HealthCheckRequestOrEndpointHealthResponse.Validate if |
| 707 |
// the designated constraints aren't met. |
| 708 |
type HealthCheckRequestOrEndpointHealthResponseValidationError struct { |
| 709 |
field string |
| 710 |
reason string |
| 711 |
cause error |
| 712 |
key bool |
| 713 |
} |
| 714 |
|
| 715 |
// Field function returns field value. |
| 716 |
func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Field() string { return e.field } |
| 717 |
|
| 718 |
// Reason function returns reason value. |
| 719 |
func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Reason() string { return e.reason } |
| 720 |
|
| 721 |
// Cause function returns cause value. |
| 722 |
func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Cause() error { return e.cause } |
| 723 |
|
| 724 |
// Key function returns key value. |
| 725 |
func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Key() bool { return e.key } |
| 726 |
|
| 727 |
// ErrorName returns error name. |
| 728 |
func (e HealthCheckRequestOrEndpointHealthResponseValidationError) ErrorName() string { |
| 729 |
return "HealthCheckRequestOrEndpointHealthResponseValidationError" |
| 730 |
} |
| 731 |
|
| 732 |
// Error satisfies the builtin error interface |
| 733 |
func (e HealthCheckRequestOrEndpointHealthResponseValidationError) Error() string { |
| 734 |
cause := "" |
| 735 |
if e.cause != nil { |
| 736 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 737 |
} |
| 738 |
|
| 739 |
key := "" |
| 740 |
if e.key { |
| 741 |
key = "key for " |
| 742 |
} |
| 743 |
|
| 744 |
return fmt.Sprintf( |
| 745 |
"invalid %sHealthCheckRequestOrEndpointHealthResponse.%s: %s%s", |
| 746 |
key, |
| 747 |
e.field, |
| 748 |
e.reason, |
| 749 |
cause) |
| 750 |
} |
| 751 |
|
| 752 |
var _ error = HealthCheckRequestOrEndpointHealthResponseValidationError{} |
| 753 |
|
| 754 |
var _ interface { |
| 755 |
Field() string |
| 756 |
Reason() string |
| 757 |
Key() bool |
| 758 |
Cause() error |
| 759 |
ErrorName() string |
| 760 |
} = HealthCheckRequestOrEndpointHealthResponseValidationError{} |
| 761 |
|
| 762 |
// Validate checks the field values on LocalityEndpoints with the rules defined |
| 763 |
// in the proto definition for this message. If any rules are violated, the |
| 764 |
// first error encountered is returned, or nil if there are no violations. |
| 765 |
func (m *LocalityEndpoints) Validate() error { |
| 766 |
return m.validate(false) |
| 767 |
} |
| 768 |
|
| 769 |
// ValidateAll checks the field values on LocalityEndpoints with the rules |
| 770 |
// defined in the proto definition for this message. If any rules are |
| 771 |
// violated, the result is a list of violation errors wrapped in |
| 772 |
// LocalityEndpointsMultiError, or nil if none found. |
| 773 |
func (m *LocalityEndpoints) ValidateAll() error { |
| 774 |
return m.validate(true) |
| 775 |
} |
| 776 |
|
| 777 |
func (m *LocalityEndpoints) validate(all bool) error { |
| 778 |
if m == nil { |
| 779 |
return nil |
| 780 |
} |
| 781 |
|
| 782 |
var errors []error |
| 783 |
|
| 784 |
if all { |
| 785 |
switch v := interface{}(m.GetLocality()).(type) { |
| 786 |
case interface{ ValidateAll() error }: |
| 787 |
if err := v.ValidateAll(); err != nil { |
| 788 |
errors = append(errors, LocalityEndpointsValidationError{ |
| 789 |
field: "Locality", |
| 790 |
reason: "embedded message failed validation", |
| 791 |
cause: err, |
| 792 |
}) |
| 793 |
} |
| 794 |
case interface{ Validate() error }: |
| 795 |
if err := v.Validate(); err != nil { |
| 796 |
errors = append(errors, LocalityEndpointsValidationError{ |
| 797 |
field: "Locality", |
| 798 |
reason: "embedded message failed validation", |
| 799 |
cause: err, |
| 800 |
}) |
| 801 |
} |
| 802 |
} |
| 803 |
} else if v, ok := interface{}(m.GetLocality()).(interface{ Validate() error }); ok { |
| 804 |
if err := v.Validate(); err != nil { |
| 805 |
return LocalityEndpointsValidationError{ |
| 806 |
field: "Locality", |
| 807 |
reason: "embedded message failed validation", |
| 808 |
cause: err, |
| 809 |
} |
| 810 |
} |
| 811 |
} |
| 812 |
|
| 813 |
for idx, item := range m.GetEndpoints() { |
| 814 |
_, _ = idx, item |
| 815 |
|
| 816 |
if all { |
| 817 |
switch v := interface{}(item).(type) { |
| 818 |
case interface{ ValidateAll() error }: |
| 819 |
if err := v.ValidateAll(); err != nil { |
| 820 |
errors = append(errors, LocalityEndpointsValidationError{ |
| 821 |
field: fmt.Sprintf("Endpoints[%v]", idx), |
| 822 |
reason: "embedded message failed validation", |
| 823 |
cause: err, |
| 824 |
}) |
| 825 |
} |
| 826 |
case interface{ Validate() error }: |
| 827 |
if err := v.Validate(); err != nil { |
| 828 |
errors = append(errors, LocalityEndpointsValidationError{ |
| 829 |
field: fmt.Sprintf("Endpoints[%v]", idx), |
| 830 |
reason: "embedded message failed validation", |
| 831 |
cause: err, |
| 832 |
}) |
| 833 |
} |
| 834 |
} |
| 835 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 836 |
if err := v.Validate(); err != nil { |
| 837 |
return LocalityEndpointsValidationError{ |
| 838 |
field: fmt.Sprintf("Endpoints[%v]", idx), |
| 839 |
reason: "embedded message failed validation", |
| 840 |
cause: err, |
| 841 |
} |
| 842 |
} |
| 843 |
} |
| 844 |
|
| 845 |
} |
| 846 |
|
| 847 |
if len(errors) > 0 { |
| 848 |
return LocalityEndpointsMultiError(errors) |
| 849 |
} |
| 850 |
|
| 851 |
return nil |
| 852 |
} |
| 853 |
|
| 854 |
// LocalityEndpointsMultiError is an error wrapping multiple validation errors |
| 855 |
// returned by LocalityEndpoints.ValidateAll() if the designated constraints |
| 856 |
// aren't met. |
| 857 |
type LocalityEndpointsMultiError []error |
| 858 |
|
| 859 |
// Error returns a concatenation of all the error messages it wraps. |
| 860 |
func (m LocalityEndpointsMultiError) Error() string { |
| 861 |
var msgs []string |
| 862 |
for _, err := range m { |
| 863 |
msgs = append(msgs, err.Error()) |
| 864 |
} |
| 865 |
return strings.Join(msgs, "; ") |
| 866 |
} |
| 867 |
|
| 868 |
// AllErrors returns a list of validation violation errors. |
| 869 |
func (m LocalityEndpointsMultiError) AllErrors() []error { return m } |
| 870 |
|
| 871 |
// LocalityEndpointsValidationError is the validation error returned by |
| 872 |
// LocalityEndpoints.Validate if the designated constraints aren't met. |
| 873 |
type LocalityEndpointsValidationError struct { |
| 874 |
field string |
| 875 |
reason string |
| 876 |
cause error |
| 877 |
key bool |
| 878 |
} |
| 879 |
|
| 880 |
// Field function returns field value. |
| 881 |
func (e LocalityEndpointsValidationError) Field() string { return e.field } |
| 882 |
|
| 883 |
// Reason function returns reason value. |
| 884 |
func (e LocalityEndpointsValidationError) Reason() string { return e.reason } |
| 885 |
|
| 886 |
// Cause function returns cause value. |
| 887 |
func (e LocalityEndpointsValidationError) Cause() error { return e.cause } |
| 888 |
|
| 889 |
// Key function returns key value. |
| 890 |
func (e LocalityEndpointsValidationError) Key() bool { return e.key } |
| 891 |
|
| 892 |
// ErrorName returns error name. |
| 893 |
func (e LocalityEndpointsValidationError) ErrorName() string { |
| 894 |
return "LocalityEndpointsValidationError" |
| 895 |
} |
| 896 |
|
| 897 |
// Error satisfies the builtin error interface |
| 898 |
func (e LocalityEndpointsValidationError) Error() string { |
| 899 |
cause := "" |
| 900 |
if e.cause != nil { |
| 901 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 902 |
} |
| 903 |
|
| 904 |
key := "" |
| 905 |
if e.key { |
| 906 |
key = "key for " |
| 907 |
} |
| 908 |
|
| 909 |
return fmt.Sprintf( |
| 910 |
"invalid %sLocalityEndpoints.%s: %s%s", |
| 911 |
key, |
| 912 |
e.field, |
| 913 |
e.reason, |
| 914 |
cause) |
| 915 |
} |
| 916 |
|
| 917 |
var _ error = LocalityEndpointsValidationError{} |
| 918 |
|
| 919 |
var _ interface { |
| 920 |
Field() string |
| 921 |
Reason() string |
| 922 |
Key() bool |
| 923 |
Cause() error |
| 924 |
ErrorName() string |
| 925 |
} = LocalityEndpointsValidationError{} |
| 926 |
|
| 927 |
// Validate checks the field values on ClusterHealthCheck with the rules |
| 928 |
// defined in the proto definition for this message. If any rules are |
| 929 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 930 |
func (m *ClusterHealthCheck) Validate() error { |
| 931 |
return m.validate(false) |
| 932 |
} |
| 933 |
|
| 934 |
// ValidateAll checks the field values on ClusterHealthCheck with the rules |
| 935 |
// defined in the proto definition for this message. If any rules are |
| 936 |
// violated, the result is a list of violation errors wrapped in |
| 937 |
// ClusterHealthCheckMultiError, or nil if none found. |
| 938 |
func (m *ClusterHealthCheck) ValidateAll() error { |
| 939 |
return m.validate(true) |
| 940 |
} |
| 941 |
|
| 942 |
func (m *ClusterHealthCheck) validate(all bool) error { |
| 943 |
if m == nil { |
| 944 |
return nil |
| 945 |
} |
| 946 |
|
| 947 |
var errors []error |
| 948 |
|
| 949 |
// no validation rules for ClusterName |
| 950 |
|
| 951 |
for idx, item := range m.GetHealthChecks() { |
| 952 |
_, _ = idx, item |
| 953 |
|
| 954 |
if all { |
| 955 |
switch v := interface{}(item).(type) { |
| 956 |
case interface{ ValidateAll() error }: |
| 957 |
if err := v.ValidateAll(); err != nil { |
| 958 |
errors = append(errors, ClusterHealthCheckValidationError{ |
| 959 |
field: fmt.Sprintf("HealthChecks[%v]", idx), |
| 960 |
reason: "embedded message failed validation", |
| 961 |
cause: err, |
| 962 |
}) |
| 963 |
} |
| 964 |
case interface{ Validate() error }: |
| 965 |
if err := v.Validate(); err != nil { |
| 966 |
errors = append(errors, ClusterHealthCheckValidationError{ |
| 967 |
field: fmt.Sprintf("HealthChecks[%v]", idx), |
| 968 |
reason: "embedded message failed validation", |
| 969 |
cause: err, |
| 970 |
}) |
| 971 |
} |
| 972 |
} |
| 973 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 974 |
if err := v.Validate(); err != nil { |
| 975 |
return ClusterHealthCheckValidationError{ |
| 976 |
field: fmt.Sprintf("HealthChecks[%v]", idx), |
| 977 |
reason: "embedded message failed validation", |
| 978 |
cause: err, |
| 979 |
} |
| 980 |
} |
| 981 |
} |
| 982 |
|
| 983 |
} |
| 984 |
|
| 985 |
for idx, item := range m.GetLocalityEndpoints() { |
| 986 |
_, _ = idx, item |
| 987 |
|
| 988 |
if all { |
| 989 |
switch v := interface{}(item).(type) { |
| 990 |
case interface{ ValidateAll() error }: |
| 991 |
if err := v.ValidateAll(); err != nil { |
| 992 |
errors = append(errors, ClusterHealthCheckValidationError{ |
| 993 |
field: fmt.Sprintf("LocalityEndpoints[%v]", idx), |
| 994 |
reason: "embedded message failed validation", |
| 995 |
cause: err, |
| 996 |
}) |
| 997 |
} |
| 998 |
case interface{ Validate() error }: |
| 999 |
if err := v.Validate(); err != nil { |
| 1000 |
errors = append(errors, ClusterHealthCheckValidationError{ |
| 1001 |
field: fmt.Sprintf("LocalityEndpoints[%v]", idx), |
| 1002 |
reason: "embedded message failed validation", |
| 1003 |
cause: err, |
| 1004 |
}) |
| 1005 |
} |
| 1006 |
} |
| 1007 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 1008 |
if err := v.Validate(); err != nil { |
| 1009 |
return ClusterHealthCheckValidationError{ |
| 1010 |
field: fmt.Sprintf("LocalityEndpoints[%v]", idx), |
| 1011 |
reason: "embedded message failed validation", |
| 1012 |
cause: err, |
| 1013 |
} |
| 1014 |
} |
| 1015 |
} |
| 1016 |
|
| 1017 |
} |
| 1018 |
|
| 1019 |
if len(errors) > 0 { |
| 1020 |
return ClusterHealthCheckMultiError(errors) |
| 1021 |
} |
| 1022 |
|
| 1023 |
return nil |
| 1024 |
} |
| 1025 |
|
| 1026 |
// ClusterHealthCheckMultiError is an error wrapping multiple validation errors |
| 1027 |
// returned by ClusterHealthCheck.ValidateAll() if the designated constraints |
| 1028 |
// aren't met. |
| 1029 |
type ClusterHealthCheckMultiError []error |
| 1030 |
|
| 1031 |
// Error returns a concatenation of all the error messages it wraps. |
| 1032 |
func (m ClusterHealthCheckMultiError) Error() string { |
| 1033 |
var msgs []string |
| 1034 |
for _, err := range m { |
| 1035 |
msgs = append(msgs, err.Error()) |
| 1036 |
} |
| 1037 |
return strings.Join(msgs, "; ") |
| 1038 |
} |
| 1039 |
|
| 1040 |
// AllErrors returns a list of validation violation errors. |
| 1041 |
func (m ClusterHealthCheckMultiError) AllErrors() []error { return m } |
| 1042 |
|
| 1043 |
// ClusterHealthCheckValidationError is the validation error returned by |
| 1044 |
// ClusterHealthCheck.Validate if the designated constraints aren't met. |
| 1045 |
type ClusterHealthCheckValidationError struct { |
| 1046 |
field string |
| 1047 |
reason string |
| 1048 |
cause error |
| 1049 |
key bool |
| 1050 |
} |
| 1051 |
|
| 1052 |
// Field function returns field value. |
| 1053 |
func (e ClusterHealthCheckValidationError) Field() string { return e.field } |
| 1054 |
|
| 1055 |
// Reason function returns reason value. |
| 1056 |
func (e ClusterHealthCheckValidationError) Reason() string { return e.reason } |
| 1057 |
|
| 1058 |
// Cause function returns cause value. |
| 1059 |
func (e ClusterHealthCheckValidationError) Cause() error { return e.cause } |
| 1060 |
|
| 1061 |
// Key function returns key value. |
| 1062 |
func (e ClusterHealthCheckValidationError) Key() bool { return e.key } |
| 1063 |
|
| 1064 |
// ErrorName returns error name. |
| 1065 |
func (e ClusterHealthCheckValidationError) ErrorName() string { |
| 1066 |
return "ClusterHealthCheckValidationError" |
| 1067 |
} |
| 1068 |
|
| 1069 |
// Error satisfies the builtin error interface |
| 1070 |
func (e ClusterHealthCheckValidationError) Error() string { |
| 1071 |
cause := "" |
| 1072 |
if e.cause != nil { |
| 1073 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 1074 |
} |
| 1075 |
|
| 1076 |
key := "" |
| 1077 |
if e.key { |
| 1078 |
key = "key for " |
| 1079 |
} |
| 1080 |
|
| 1081 |
return fmt.Sprintf( |
| 1082 |
"invalid %sClusterHealthCheck.%s: %s%s", |
| 1083 |
key, |
| 1084 |
e.field, |
| 1085 |
e.reason, |
| 1086 |
cause) |
| 1087 |
} |
| 1088 |
|
| 1089 |
var _ error = ClusterHealthCheckValidationError{} |
| 1090 |
|
| 1091 |
var _ interface { |
| 1092 |
Field() string |
| 1093 |
Reason() string |
| 1094 |
Key() bool |
| 1095 |
Cause() error |
| 1096 |
ErrorName() string |
| 1097 |
} = ClusterHealthCheckValidationError{} |
| 1098 |
|
| 1099 |
// Validate checks the field values on HealthCheckSpecifier with the rules |
| 1100 |
// defined in the proto definition for this message. If any rules are |
| 1101 |
// violated, the first error encountered is returned, or nil if there are no violations. |
| 1102 |
func (m *HealthCheckSpecifier) Validate() error { |
| 1103 |
return m.validate(false) |
| 1104 |
} |
| 1105 |
|
| 1106 |
// ValidateAll checks the field values on HealthCheckSpecifier with the rules |
| 1107 |
// defined in the proto definition for this message. If any rules are |
| 1108 |
// violated, the result is a list of violation errors wrapped in |
| 1109 |
// HealthCheckSpecifierMultiError, or nil if none found. |
| 1110 |
func (m *HealthCheckSpecifier) ValidateAll() error { |
| 1111 |
return m.validate(true) |
| 1112 |
} |
| 1113 |
|
| 1114 |
func (m *HealthCheckSpecifier) validate(all bool) error { |
| 1115 |
if m == nil { |
| 1116 |
return nil |
| 1117 |
} |
| 1118 |
|
| 1119 |
var errors []error |
| 1120 |
|
| 1121 |
for idx, item := range m.GetClusterHealthChecks() { |
| 1122 |
_, _ = idx, item |
| 1123 |
|
| 1124 |
if all { |
| 1125 |
switch v := interface{}(item).(type) { |
| 1126 |
case interface{ ValidateAll() error }: |
| 1127 |
if err := v.ValidateAll(); err != nil { |
| 1128 |
errors = append(errors, HealthCheckSpecifierValidationError{ |
| 1129 |
field: fmt.Sprintf("ClusterHealthChecks[%v]", idx), |
| 1130 |
reason: "embedded message failed validation", |
| 1131 |
cause: err, |
| 1132 |
}) |
| 1133 |
} |
| 1134 |
case interface{ Validate() error }: |
| 1135 |
if err := v.Validate(); err != nil { |
| 1136 |
errors = append(errors, HealthCheckSpecifierValidationError{ |
| 1137 |
field: fmt.Sprintf("ClusterHealthChecks[%v]", idx), |
| 1138 |
reason: "embedded message failed validation", |
| 1139 |
cause: err, |
| 1140 |
}) |
| 1141 |
} |
| 1142 |
} |
| 1143 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 1144 |
if err := v.Validate(); err != nil { |
| 1145 |
return HealthCheckSpecifierValidationError{ |
| 1146 |
field: fmt.Sprintf("ClusterHealthChecks[%v]", idx), |
| 1147 |
reason: "embedded message failed validation", |
| 1148 |
cause: err, |
| 1149 |
} |
| 1150 |
} |
| 1151 |
} |
| 1152 |
|
| 1153 |
} |
| 1154 |
|
| 1155 |
if all { |
| 1156 |
switch v := interface{}(m.GetInterval()).(type) { |
| 1157 |
case interface{ ValidateAll() error }: |
| 1158 |
if err := v.ValidateAll(); err != nil { |
| 1159 |
errors = append(errors, HealthCheckSpecifierValidationError{ |
| 1160 |
field: "Interval", |
| 1161 |
reason: "embedded message failed validation", |
| 1162 |
cause: err, |
| 1163 |
}) |
| 1164 |
} |
| 1165 |
case interface{ Validate() error }: |
| 1166 |
if err := v.Validate(); err != nil { |
| 1167 |
errors = append(errors, HealthCheckSpecifierValidationError{ |
| 1168 |
field: "Interval", |
| 1169 |
reason: "embedded message failed validation", |
| 1170 |
cause: err, |
| 1171 |
}) |
| 1172 |
} |
| 1173 |
} |
| 1174 |
} else if v, ok := interface{}(m.GetInterval()).(interface{ Validate() error }); ok { |
| 1175 |
if err := v.Validate(); err != nil { |
| 1176 |
return HealthCheckSpecifierValidationError{ |
| 1177 |
field: "Interval", |
| 1178 |
reason: "embedded message failed validation", |
| 1179 |
cause: err, |
| 1180 |
} |
| 1181 |
} |
| 1182 |
} |
| 1183 |
|
| 1184 |
if len(errors) > 0 { |
| 1185 |
return HealthCheckSpecifierMultiError(errors) |
| 1186 |
} |
| 1187 |
|
| 1188 |
return nil |
| 1189 |
} |
| 1190 |
|
| 1191 |
// HealthCheckSpecifierMultiError is an error wrapping multiple validation |
| 1192 |
// errors returned by HealthCheckSpecifier.ValidateAll() if the designated |
| 1193 |
// constraints aren't met. |
| 1194 |
type HealthCheckSpecifierMultiError []error |
| 1195 |
|
| 1196 |
// Error returns a concatenation of all the error messages it wraps. |
| 1197 |
func (m HealthCheckSpecifierMultiError) Error() string { |
| 1198 |
var msgs []string |
| 1199 |
for _, err := range m { |
| 1200 |
msgs = append(msgs, err.Error()) |
| 1201 |
} |
| 1202 |
return strings.Join(msgs, "; ") |
| 1203 |
} |
| 1204 |
|
| 1205 |
// AllErrors returns a list of validation violation errors. |
| 1206 |
func (m HealthCheckSpecifierMultiError) AllErrors() []error { return m } |
| 1207 |
|
| 1208 |
// HealthCheckSpecifierValidationError is the validation error returned by |
| 1209 |
// HealthCheckSpecifier.Validate if the designated constraints aren't met. |
| 1210 |
type HealthCheckSpecifierValidationError struct { |
| 1211 |
field string |
| 1212 |
reason string |
| 1213 |
cause error |
| 1214 |
key bool |
| 1215 |
} |
| 1216 |
|
| 1217 |
// Field function returns field value. |
| 1218 |
func (e HealthCheckSpecifierValidationError) Field() string { return e.field } |
| 1219 |
|
| 1220 |
// Reason function returns reason value. |
| 1221 |
func (e HealthCheckSpecifierValidationError) Reason() string { return e.reason } |
| 1222 |
|
| 1223 |
// Cause function returns cause value. |
| 1224 |
func (e HealthCheckSpecifierValidationError) Cause() error { return e.cause } |
| 1225 |
|
| 1226 |
// Key function returns key value. |
| 1227 |
func (e HealthCheckSpecifierValidationError) Key() bool { return e.key } |
| 1228 |
|
| 1229 |
// ErrorName returns error name. |
| 1230 |
func (e HealthCheckSpecifierValidationError) ErrorName() string { |
| 1231 |
return "HealthCheckSpecifierValidationError" |
| 1232 |
} |
| 1233 |
|
| 1234 |
// Error satisfies the builtin error interface |
| 1235 |
func (e HealthCheckSpecifierValidationError) Error() string { |
| 1236 |
cause := "" |
| 1237 |
if e.cause != nil { |
| 1238 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 1239 |
} |
| 1240 |
|
| 1241 |
key := "" |
| 1242 |
if e.key { |
| 1243 |
key = "key for " |
| 1244 |
} |
| 1245 |
|
| 1246 |
return fmt.Sprintf( |
| 1247 |
"invalid %sHealthCheckSpecifier.%s: %s%s", |
| 1248 |
key, |
| 1249 |
e.field, |
| 1250 |
e.reason, |
| 1251 |
cause) |
| 1252 |
} |
| 1253 |
|
| 1254 |
var _ error = HealthCheckSpecifierValidationError{} |
| 1255 |
|
| 1256 |
var _ interface { |
| 1257 |
Field() string |
| 1258 |
Reason() string |
| 1259 |
Key() bool |
| 1260 |
Cause() error |
| 1261 |
ErrorName() string |
| 1262 |
} = HealthCheckSpecifierValidationError{} |