| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/config/cluster/v3/outlier_detection.proto |
| 4 |
|
| 5 |
package clusterv3 |
| 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 OutlierDetection with the rules defined |
| 40 |
// in the proto definition for this message. If any rules are violated, the |
| 41 |
// first error encountered is returned, or nil if there are no violations. |
| 42 |
func (m *OutlierDetection) Validate() error { |
| 43 |
return m.validate(false) |
| 44 |
} |
| 45 |
|
| 46 |
// ValidateAll checks the field values on OutlierDetection 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 |
// OutlierDetectionMultiError, or nil if none found. |
| 50 |
func (m *OutlierDetection) ValidateAll() error { |
| 51 |
return m.validate(true) |
| 52 |
} |
| 53 |
|
| 54 |
func (m *OutlierDetection) 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.GetConsecutive_5Xx()).(type) { |
| 63 |
case interface{ ValidateAll() error }: |
| 64 |
if err := v.ValidateAll(); err != nil { |
| 65 |
errors = append(errors, OutlierDetectionValidationError{ |
| 66 |
field: "Consecutive_5Xx", |
| 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, OutlierDetectionValidationError{ |
| 74 |
field: "Consecutive_5Xx", |
| 75 |
reason: "embedded message failed validation", |
| 76 |
cause: err, |
| 77 |
}) |
| 78 |
} |
| 79 |
} |
| 80 |
} else if v, ok := interface{}(m.GetConsecutive_5Xx()).(interface{ Validate() error }); ok { |
| 81 |
if err := v.Validate(); err != nil { |
| 82 |
return OutlierDetectionValidationError{ |
| 83 |
field: "Consecutive_5Xx", |
| 84 |
reason: "embedded message failed validation", |
| 85 |
cause: err, |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
if d := m.GetInterval(); d != nil { |
| 91 |
dur, err := d.AsDuration(), d.CheckValid() |
| 92 |
if err != nil { |
| 93 |
err = OutlierDetectionValidationError{ |
| 94 |
field: "Interval", |
| 95 |
reason: "value is not a valid duration", |
| 96 |
cause: err, |
| 97 |
} |
| 98 |
if !all { |
| 99 |
return err |
| 100 |
} |
| 101 |
errors = append(errors, err) |
| 102 |
} else { |
| 103 |
|
| 104 |
gt := time.Duration(0*time.Second + 0*time.Nanosecond) |
| 105 |
|
| 106 |
if dur <= gt { |
| 107 |
err := OutlierDetectionValidationError{ |
| 108 |
field: "Interval", |
| 109 |
reason: "value must be greater than 0s", |
| 110 |
} |
| 111 |
if !all { |
| 112 |
return err |
| 113 |
} |
| 114 |
errors = append(errors, err) |
| 115 |
} |
| 116 |
|
| 117 |
} |
| 118 |
} |
| 119 |
|
| 120 |
if d := m.GetBaseEjectionTime(); d != nil { |
| 121 |
dur, err := d.AsDuration(), d.CheckValid() |
| 122 |
if err != nil { |
| 123 |
err = OutlierDetectionValidationError{ |
| 124 |
field: "BaseEjectionTime", |
| 125 |
reason: "value is not a valid duration", |
| 126 |
cause: err, |
| 127 |
} |
| 128 |
if !all { |
| 129 |
return err |
| 130 |
} |
| 131 |
errors = append(errors, err) |
| 132 |
} else { |
| 133 |
|
| 134 |
gt := time.Duration(0*time.Second + 0*time.Nanosecond) |
| 135 |
|
| 136 |
if dur <= gt { |
| 137 |
err := OutlierDetectionValidationError{ |
| 138 |
field: "BaseEjectionTime", |
| 139 |
reason: "value must be greater than 0s", |
| 140 |
} |
| 141 |
if !all { |
| 142 |
return err |
| 143 |
} |
| 144 |
errors = append(errors, err) |
| 145 |
} |
| 146 |
|
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
if wrapper := m.GetMaxEjectionPercent(); wrapper != nil { |
| 151 |
|
| 152 |
if wrapper.GetValue() > 100 { |
| 153 |
err := OutlierDetectionValidationError{ |
| 154 |
field: "MaxEjectionPercent", |
| 155 |
reason: "value must be less than or equal to 100", |
| 156 |
} |
| 157 |
if !all { |
| 158 |
return err |
| 159 |
} |
| 160 |
errors = append(errors, err) |
| 161 |
} |
| 162 |
|
| 163 |
} |
| 164 |
|
| 165 |
if wrapper := m.GetEnforcingConsecutive_5Xx(); wrapper != nil { |
| 166 |
|
| 167 |
if wrapper.GetValue() > 100 { |
| 168 |
err := OutlierDetectionValidationError{ |
| 169 |
field: "EnforcingConsecutive_5Xx", |
| 170 |
reason: "value must be less than or equal to 100", |
| 171 |
} |
| 172 |
if !all { |
| 173 |
return err |
| 174 |
} |
| 175 |
errors = append(errors, err) |
| 176 |
} |
| 177 |
|
| 178 |
} |
| 179 |
|
| 180 |
if wrapper := m.GetEnforcingSuccessRate(); wrapper != nil { |
| 181 |
|
| 182 |
if wrapper.GetValue() > 100 { |
| 183 |
err := OutlierDetectionValidationError{ |
| 184 |
field: "EnforcingSuccessRate", |
| 185 |
reason: "value must be less than or equal to 100", |
| 186 |
} |
| 187 |
if !all { |
| 188 |
return err |
| 189 |
} |
| 190 |
errors = append(errors, err) |
| 191 |
} |
| 192 |
|
| 193 |
} |
| 194 |
|
| 195 |
if all { |
| 196 |
switch v := interface{}(m.GetSuccessRateMinimumHosts()).(type) { |
| 197 |
case interface{ ValidateAll() error }: |
| 198 |
if err := v.ValidateAll(); err != nil { |
| 199 |
errors = append(errors, OutlierDetectionValidationError{ |
| 200 |
field: "SuccessRateMinimumHosts", |
| 201 |
reason: "embedded message failed validation", |
| 202 |
cause: err, |
| 203 |
}) |
| 204 |
} |
| 205 |
case interface{ Validate() error }: |
| 206 |
if err := v.Validate(); err != nil { |
| 207 |
errors = append(errors, OutlierDetectionValidationError{ |
| 208 |
field: "SuccessRateMinimumHosts", |
| 209 |
reason: "embedded message failed validation", |
| 210 |
cause: err, |
| 211 |
}) |
| 212 |
} |
| 213 |
} |
| 214 |
} else if v, ok := interface{}(m.GetSuccessRateMinimumHosts()).(interface{ Validate() error }); ok { |
| 215 |
if err := v.Validate(); err != nil { |
| 216 |
return OutlierDetectionValidationError{ |
| 217 |
field: "SuccessRateMinimumHosts", |
| 218 |
reason: "embedded message failed validation", |
| 219 |
cause: err, |
| 220 |
} |
| 221 |
} |
| 222 |
} |
| 223 |
|
| 224 |
if all { |
| 225 |
switch v := interface{}(m.GetSuccessRateRequestVolume()).(type) { |
| 226 |
case interface{ ValidateAll() error }: |
| 227 |
if err := v.ValidateAll(); err != nil { |
| 228 |
errors = append(errors, OutlierDetectionValidationError{ |
| 229 |
field: "SuccessRateRequestVolume", |
| 230 |
reason: "embedded message failed validation", |
| 231 |
cause: err, |
| 232 |
}) |
| 233 |
} |
| 234 |
case interface{ Validate() error }: |
| 235 |
if err := v.Validate(); err != nil { |
| 236 |
errors = append(errors, OutlierDetectionValidationError{ |
| 237 |
field: "SuccessRateRequestVolume", |
| 238 |
reason: "embedded message failed validation", |
| 239 |
cause: err, |
| 240 |
}) |
| 241 |
} |
| 242 |
} |
| 243 |
} else if v, ok := interface{}(m.GetSuccessRateRequestVolume()).(interface{ Validate() error }); ok { |
| 244 |
if err := v.Validate(); err != nil { |
| 245 |
return OutlierDetectionValidationError{ |
| 246 |
field: "SuccessRateRequestVolume", |
| 247 |
reason: "embedded message failed validation", |
| 248 |
cause: err, |
| 249 |
} |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
if all { |
| 254 |
switch v := interface{}(m.GetSuccessRateStdevFactor()).(type) { |
| 255 |
case interface{ ValidateAll() error }: |
| 256 |
if err := v.ValidateAll(); err != nil { |
| 257 |
errors = append(errors, OutlierDetectionValidationError{ |
| 258 |
field: "SuccessRateStdevFactor", |
| 259 |
reason: "embedded message failed validation", |
| 260 |
cause: err, |
| 261 |
}) |
| 262 |
} |
| 263 |
case interface{ Validate() error }: |
| 264 |
if err := v.Validate(); err != nil { |
| 265 |
errors = append(errors, OutlierDetectionValidationError{ |
| 266 |
field: "SuccessRateStdevFactor", |
| 267 |
reason: "embedded message failed validation", |
| 268 |
cause: err, |
| 269 |
}) |
| 270 |
} |
| 271 |
} |
| 272 |
} else if v, ok := interface{}(m.GetSuccessRateStdevFactor()).(interface{ Validate() error }); ok { |
| 273 |
if err := v.Validate(); err != nil { |
| 274 |
return OutlierDetectionValidationError{ |
| 275 |
field: "SuccessRateStdevFactor", |
| 276 |
reason: "embedded message failed validation", |
| 277 |
cause: err, |
| 278 |
} |
| 279 |
} |
| 280 |
} |
| 281 |
|
| 282 |
if all { |
| 283 |
switch v := interface{}(m.GetConsecutiveGatewayFailure()).(type) { |
| 284 |
case interface{ ValidateAll() error }: |
| 285 |
if err := v.ValidateAll(); err != nil { |
| 286 |
errors = append(errors, OutlierDetectionValidationError{ |
| 287 |
field: "ConsecutiveGatewayFailure", |
| 288 |
reason: "embedded message failed validation", |
| 289 |
cause: err, |
| 290 |
}) |
| 291 |
} |
| 292 |
case interface{ Validate() error }: |
| 293 |
if err := v.Validate(); err != nil { |
| 294 |
errors = append(errors, OutlierDetectionValidationError{ |
| 295 |
field: "ConsecutiveGatewayFailure", |
| 296 |
reason: "embedded message failed validation", |
| 297 |
cause: err, |
| 298 |
}) |
| 299 |
} |
| 300 |
} |
| 301 |
} else if v, ok := interface{}(m.GetConsecutiveGatewayFailure()).(interface{ Validate() error }); ok { |
| 302 |
if err := v.Validate(); err != nil { |
| 303 |
return OutlierDetectionValidationError{ |
| 304 |
field: "ConsecutiveGatewayFailure", |
| 305 |
reason: "embedded message failed validation", |
| 306 |
cause: err, |
| 307 |
} |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
if wrapper := m.GetEnforcingConsecutiveGatewayFailure(); wrapper != nil { |
| 312 |
|
| 313 |
if wrapper.GetValue() > 100 { |
| 314 |
err := OutlierDetectionValidationError{ |
| 315 |
field: "EnforcingConsecutiveGatewayFailure", |
| 316 |
reason: "value must be less than or equal to 100", |
| 317 |
} |
| 318 |
if !all { |
| 319 |
return err |
| 320 |
} |
| 321 |
errors = append(errors, err) |
| 322 |
} |
| 323 |
|
| 324 |
} |
| 325 |
|
| 326 |
// no validation rules for SplitExternalLocalOriginErrors |
| 327 |
|
| 328 |
if all { |
| 329 |
switch v := interface{}(m.GetConsecutiveLocalOriginFailure()).(type) { |
| 330 |
case interface{ ValidateAll() error }: |
| 331 |
if err := v.ValidateAll(); err != nil { |
| 332 |
errors = append(errors, OutlierDetectionValidationError{ |
| 333 |
field: "ConsecutiveLocalOriginFailure", |
| 334 |
reason: "embedded message failed validation", |
| 335 |
cause: err, |
| 336 |
}) |
| 337 |
} |
| 338 |
case interface{ Validate() error }: |
| 339 |
if err := v.Validate(); err != nil { |
| 340 |
errors = append(errors, OutlierDetectionValidationError{ |
| 341 |
field: "ConsecutiveLocalOriginFailure", |
| 342 |
reason: "embedded message failed validation", |
| 343 |
cause: err, |
| 344 |
}) |
| 345 |
} |
| 346 |
} |
| 347 |
} else if v, ok := interface{}(m.GetConsecutiveLocalOriginFailure()).(interface{ Validate() error }); ok { |
| 348 |
if err := v.Validate(); err != nil { |
| 349 |
return OutlierDetectionValidationError{ |
| 350 |
field: "ConsecutiveLocalOriginFailure", |
| 351 |
reason: "embedded message failed validation", |
| 352 |
cause: err, |
| 353 |
} |
| 354 |
} |
| 355 |
} |
| 356 |
|
| 357 |
if wrapper := m.GetEnforcingConsecutiveLocalOriginFailure(); wrapper != nil { |
| 358 |
|
| 359 |
if wrapper.GetValue() > 100 { |
| 360 |
err := OutlierDetectionValidationError{ |
| 361 |
field: "EnforcingConsecutiveLocalOriginFailure", |
| 362 |
reason: "value must be less than or equal to 100", |
| 363 |
} |
| 364 |
if !all { |
| 365 |
return err |
| 366 |
} |
| 367 |
errors = append(errors, err) |
| 368 |
} |
| 369 |
|
| 370 |
} |
| 371 |
|
| 372 |
if wrapper := m.GetEnforcingLocalOriginSuccessRate(); wrapper != nil { |
| 373 |
|
| 374 |
if wrapper.GetValue() > 100 { |
| 375 |
err := OutlierDetectionValidationError{ |
| 376 |
field: "EnforcingLocalOriginSuccessRate", |
| 377 |
reason: "value must be less than or equal to 100", |
| 378 |
} |
| 379 |
if !all { |
| 380 |
return err |
| 381 |
} |
| 382 |
errors = append(errors, err) |
| 383 |
} |
| 384 |
|
| 385 |
} |
| 386 |
|
| 387 |
if wrapper := m.GetFailurePercentageThreshold(); wrapper != nil { |
| 388 |
|
| 389 |
if wrapper.GetValue() > 100 { |
| 390 |
err := OutlierDetectionValidationError{ |
| 391 |
field: "FailurePercentageThreshold", |
| 392 |
reason: "value must be less than or equal to 100", |
| 393 |
} |
| 394 |
if !all { |
| 395 |
return err |
| 396 |
} |
| 397 |
errors = append(errors, err) |
| 398 |
} |
| 399 |
|
| 400 |
} |
| 401 |
|
| 402 |
if wrapper := m.GetEnforcingFailurePercentage(); wrapper != nil { |
| 403 |
|
| 404 |
if wrapper.GetValue() > 100 { |
| 405 |
err := OutlierDetectionValidationError{ |
| 406 |
field: "EnforcingFailurePercentage", |
| 407 |
reason: "value must be less than or equal to 100", |
| 408 |
} |
| 409 |
if !all { |
| 410 |
return err |
| 411 |
} |
| 412 |
errors = append(errors, err) |
| 413 |
} |
| 414 |
|
| 415 |
} |
| 416 |
|
| 417 |
if wrapper := m.GetEnforcingFailurePercentageLocalOrigin(); wrapper != nil { |
| 418 |
|
| 419 |
if wrapper.GetValue() > 100 { |
| 420 |
err := OutlierDetectionValidationError{ |
| 421 |
field: "EnforcingFailurePercentageLocalOrigin", |
| 422 |
reason: "value must be less than or equal to 100", |
| 423 |
} |
| 424 |
if !all { |
| 425 |
return err |
| 426 |
} |
| 427 |
errors = append(errors, err) |
| 428 |
} |
| 429 |
|
| 430 |
} |
| 431 |
|
| 432 |
if all { |
| 433 |
switch v := interface{}(m.GetFailurePercentageMinimumHosts()).(type) { |
| 434 |
case interface{ ValidateAll() error }: |
| 435 |
if err := v.ValidateAll(); err != nil { |
| 436 |
errors = append(errors, OutlierDetectionValidationError{ |
| 437 |
field: "FailurePercentageMinimumHosts", |
| 438 |
reason: "embedded message failed validation", |
| 439 |
cause: err, |
| 440 |
}) |
| 441 |
} |
| 442 |
case interface{ Validate() error }: |
| 443 |
if err := v.Validate(); err != nil { |
| 444 |
errors = append(errors, OutlierDetectionValidationError{ |
| 445 |
field: "FailurePercentageMinimumHosts", |
| 446 |
reason: "embedded message failed validation", |
| 447 |
cause: err, |
| 448 |
}) |
| 449 |
} |
| 450 |
} |
| 451 |
} else if v, ok := interface{}(m.GetFailurePercentageMinimumHosts()).(interface{ Validate() error }); ok { |
| 452 |
if err := v.Validate(); err != nil { |
| 453 |
return OutlierDetectionValidationError{ |
| 454 |
field: "FailurePercentageMinimumHosts", |
| 455 |
reason: "embedded message failed validation", |
| 456 |
cause: err, |
| 457 |
} |
| 458 |
} |
| 459 |
} |
| 460 |
|
| 461 |
if all { |
| 462 |
switch v := interface{}(m.GetFailurePercentageRequestVolume()).(type) { |
| 463 |
case interface{ ValidateAll() error }: |
| 464 |
if err := v.ValidateAll(); err != nil { |
| 465 |
errors = append(errors, OutlierDetectionValidationError{ |
| 466 |
field: "FailurePercentageRequestVolume", |
| 467 |
reason: "embedded message failed validation", |
| 468 |
cause: err, |
| 469 |
}) |
| 470 |
} |
| 471 |
case interface{ Validate() error }: |
| 472 |
if err := v.Validate(); err != nil { |
| 473 |
errors = append(errors, OutlierDetectionValidationError{ |
| 474 |
field: "FailurePercentageRequestVolume", |
| 475 |
reason: "embedded message failed validation", |
| 476 |
cause: err, |
| 477 |
}) |
| 478 |
} |
| 479 |
} |
| 480 |
} else if v, ok := interface{}(m.GetFailurePercentageRequestVolume()).(interface{ Validate() error }); ok { |
| 481 |
if err := v.Validate(); err != nil { |
| 482 |
return OutlierDetectionValidationError{ |
| 483 |
field: "FailurePercentageRequestVolume", |
| 484 |
reason: "embedded message failed validation", |
| 485 |
cause: err, |
| 486 |
} |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
if d := m.GetMaxEjectionTime(); d != nil { |
| 491 |
dur, err := d.AsDuration(), d.CheckValid() |
| 492 |
if err != nil { |
| 493 |
err = OutlierDetectionValidationError{ |
| 494 |
field: "MaxEjectionTime", |
| 495 |
reason: "value is not a valid duration", |
| 496 |
cause: err, |
| 497 |
} |
| 498 |
if !all { |
| 499 |
return err |
| 500 |
} |
| 501 |
errors = append(errors, err) |
| 502 |
} else { |
| 503 |
|
| 504 |
gt := time.Duration(0*time.Second + 0*time.Nanosecond) |
| 505 |
|
| 506 |
if dur <= gt { |
| 507 |
err := OutlierDetectionValidationError{ |
| 508 |
field: "MaxEjectionTime", |
| 509 |
reason: "value must be greater than 0s", |
| 510 |
} |
| 511 |
if !all { |
| 512 |
return err |
| 513 |
} |
| 514 |
errors = append(errors, err) |
| 515 |
} |
| 516 |
|
| 517 |
} |
| 518 |
} |
| 519 |
|
| 520 |
if all { |
| 521 |
switch v := interface{}(m.GetMaxEjectionTimeJitter()).(type) { |
| 522 |
case interface{ ValidateAll() error }: |
| 523 |
if err := v.ValidateAll(); err != nil { |
| 524 |
errors = append(errors, OutlierDetectionValidationError{ |
| 525 |
field: "MaxEjectionTimeJitter", |
| 526 |
reason: "embedded message failed validation", |
| 527 |
cause: err, |
| 528 |
}) |
| 529 |
} |
| 530 |
case interface{ Validate() error }: |
| 531 |
if err := v.Validate(); err != nil { |
| 532 |
errors = append(errors, OutlierDetectionValidationError{ |
| 533 |
field: "MaxEjectionTimeJitter", |
| 534 |
reason: "embedded message failed validation", |
| 535 |
cause: err, |
| 536 |
}) |
| 537 |
} |
| 538 |
} |
| 539 |
} else if v, ok := interface{}(m.GetMaxEjectionTimeJitter()).(interface{ Validate() error }); ok { |
| 540 |
if err := v.Validate(); err != nil { |
| 541 |
return OutlierDetectionValidationError{ |
| 542 |
field: "MaxEjectionTimeJitter", |
| 543 |
reason: "embedded message failed validation", |
| 544 |
cause: err, |
| 545 |
} |
| 546 |
} |
| 547 |
} |
| 548 |
|
| 549 |
if all { |
| 550 |
switch v := interface{}(m.GetSuccessfulActiveHealthCheckUnejectHost()).(type) { |
| 551 |
case interface{ ValidateAll() error }: |
| 552 |
if err := v.ValidateAll(); err != nil { |
| 553 |
errors = append(errors, OutlierDetectionValidationError{ |
| 554 |
field: "SuccessfulActiveHealthCheckUnejectHost", |
| 555 |
reason: "embedded message failed validation", |
| 556 |
cause: err, |
| 557 |
}) |
| 558 |
} |
| 559 |
case interface{ Validate() error }: |
| 560 |
if err := v.Validate(); err != nil { |
| 561 |
errors = append(errors, OutlierDetectionValidationError{ |
| 562 |
field: "SuccessfulActiveHealthCheckUnejectHost", |
| 563 |
reason: "embedded message failed validation", |
| 564 |
cause: err, |
| 565 |
}) |
| 566 |
} |
| 567 |
} |
| 568 |
} else if v, ok := interface{}(m.GetSuccessfulActiveHealthCheckUnejectHost()).(interface{ Validate() error }); ok { |
| 569 |
if err := v.Validate(); err != nil { |
| 570 |
return OutlierDetectionValidationError{ |
| 571 |
field: "SuccessfulActiveHealthCheckUnejectHost", |
| 572 |
reason: "embedded message failed validation", |
| 573 |
cause: err, |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
for idx, item := range m.GetMonitors() { |
| 579 |
_, _ = idx, item |
| 580 |
|
| 581 |
if all { |
| 582 |
switch v := interface{}(item).(type) { |
| 583 |
case interface{ ValidateAll() error }: |
| 584 |
if err := v.ValidateAll(); err != nil { |
| 585 |
errors = append(errors, OutlierDetectionValidationError{ |
| 586 |
field: fmt.Sprintf("Monitors[%v]", idx), |
| 587 |
reason: "embedded message failed validation", |
| 588 |
cause: err, |
| 589 |
}) |
| 590 |
} |
| 591 |
case interface{ Validate() error }: |
| 592 |
if err := v.Validate(); err != nil { |
| 593 |
errors = append(errors, OutlierDetectionValidationError{ |
| 594 |
field: fmt.Sprintf("Monitors[%v]", idx), |
| 595 |
reason: "embedded message failed validation", |
| 596 |
cause: err, |
| 597 |
}) |
| 598 |
} |
| 599 |
} |
| 600 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 601 |
if err := v.Validate(); err != nil { |
| 602 |
return OutlierDetectionValidationError{ |
| 603 |
field: fmt.Sprintf("Monitors[%v]", idx), |
| 604 |
reason: "embedded message failed validation", |
| 605 |
cause: err, |
| 606 |
} |
| 607 |
} |
| 608 |
} |
| 609 |
|
| 610 |
} |
| 611 |
|
| 612 |
if all { |
| 613 |
switch v := interface{}(m.GetAlwaysEjectOneHost()).(type) { |
| 614 |
case interface{ ValidateAll() error }: |
| 615 |
if err := v.ValidateAll(); err != nil { |
| 616 |
errors = append(errors, OutlierDetectionValidationError{ |
| 617 |
field: "AlwaysEjectOneHost", |
| 618 |
reason: "embedded message failed validation", |
| 619 |
cause: err, |
| 620 |
}) |
| 621 |
} |
| 622 |
case interface{ Validate() error }: |
| 623 |
if err := v.Validate(); err != nil { |
| 624 |
errors = append(errors, OutlierDetectionValidationError{ |
| 625 |
field: "AlwaysEjectOneHost", |
| 626 |
reason: "embedded message failed validation", |
| 627 |
cause: err, |
| 628 |
}) |
| 629 |
} |
| 630 |
} |
| 631 |
} else if v, ok := interface{}(m.GetAlwaysEjectOneHost()).(interface{ Validate() error }); ok { |
| 632 |
if err := v.Validate(); err != nil { |
| 633 |
return OutlierDetectionValidationError{ |
| 634 |
field: "AlwaysEjectOneHost", |
| 635 |
reason: "embedded message failed validation", |
| 636 |
cause: err, |
| 637 |
} |
| 638 |
} |
| 639 |
} |
| 640 |
|
| 641 |
if len(errors) > 0 { |
| 642 |
return OutlierDetectionMultiError(errors) |
| 643 |
} |
| 644 |
|
| 645 |
return nil |
| 646 |
} |
| 647 |
|
| 648 |
// OutlierDetectionMultiError is an error wrapping multiple validation errors |
| 649 |
// returned by OutlierDetection.ValidateAll() if the designated constraints |
| 650 |
// aren't met. |
| 651 |
type OutlierDetectionMultiError []error |
| 652 |
|
| 653 |
// Error returns a concatenation of all the error messages it wraps. |
| 654 |
func (m OutlierDetectionMultiError) Error() string { |
| 655 |
var msgs []string |
| 656 |
for _, err := range m { |
| 657 |
msgs = append(msgs, err.Error()) |
| 658 |
} |
| 659 |
return strings.Join(msgs, "; ") |
| 660 |
} |
| 661 |
|
| 662 |
// AllErrors returns a list of validation violation errors. |
| 663 |
func (m OutlierDetectionMultiError) AllErrors() []error { return m } |
| 664 |
|
| 665 |
// OutlierDetectionValidationError is the validation error returned by |
| 666 |
// OutlierDetection.Validate if the designated constraints aren't met. |
| 667 |
type OutlierDetectionValidationError struct { |
| 668 |
field string |
| 669 |
reason string |
| 670 |
cause error |
| 671 |
key bool |
| 672 |
} |
| 673 |
|
| 674 |
// Field function returns field value. |
| 675 |
func (e OutlierDetectionValidationError) Field() string { return e.field } |
| 676 |
|
| 677 |
// Reason function returns reason value. |
| 678 |
func (e OutlierDetectionValidationError) Reason() string { return e.reason } |
| 679 |
|
| 680 |
// Cause function returns cause value. |
| 681 |
func (e OutlierDetectionValidationError) Cause() error { return e.cause } |
| 682 |
|
| 683 |
// Key function returns key value. |
| 684 |
func (e OutlierDetectionValidationError) Key() bool { return e.key } |
| 685 |
|
| 686 |
// ErrorName returns error name. |
| 687 |
func (e OutlierDetectionValidationError) ErrorName() string { return "OutlierDetectionValidationError" } |
| 688 |
|
| 689 |
// Error satisfies the builtin error interface |
| 690 |
func (e OutlierDetectionValidationError) Error() string { |
| 691 |
cause := "" |
| 692 |
if e.cause != nil { |
| 693 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 694 |
} |
| 695 |
|
| 696 |
key := "" |
| 697 |
if e.key { |
| 698 |
key = "key for " |
| 699 |
} |
| 700 |
|
| 701 |
return fmt.Sprintf( |
| 702 |
"invalid %sOutlierDetection.%s: %s%s", |
| 703 |
key, |
| 704 |
e.field, |
| 705 |
e.reason, |
| 706 |
cause) |
| 707 |
} |
| 708 |
|
| 709 |
var _ error = OutlierDetectionValidationError{} |
| 710 |
|
| 711 |
var _ interface { |
| 712 |
Field() string |
| 713 |
Reason() string |
| 714 |
Key() bool |
| 715 |
Cause() error |
| 716 |
ErrorName() string |
| 717 |
} = OutlierDetectionValidationError{} |