| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/config/overload/v2alpha/overload.proto |
| 4 |
|
| 5 |
package v2alpha |
| 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 ResourceMonitor 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 *ResourceMonitor) Validate() error { |
| 43 |
return m.validate(false) |
| 44 |
} |
| 45 |
|
| 46 |
// ValidateAll checks the field values on ResourceMonitor 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 |
// ResourceMonitorMultiError, or nil if none found. |
| 50 |
func (m *ResourceMonitor) ValidateAll() error { |
| 51 |
return m.validate(true) |
| 52 |
} |
| 53 |
|
| 54 |
func (m *ResourceMonitor) validate(all bool) error { |
| 55 |
if m == nil { |
| 56 |
return nil |
| 57 |
} |
| 58 |
|
| 59 |
var errors []error |
| 60 |
|
| 61 |
if len(m.GetName()) < 1 { |
| 62 |
err := ResourceMonitorValidationError{ |
| 63 |
field: "Name", |
| 64 |
reason: "value length must be at least 1 bytes", |
| 65 |
} |
| 66 |
if !all { |
| 67 |
return err |
| 68 |
} |
| 69 |
errors = append(errors, err) |
| 70 |
} |
| 71 |
|
| 72 |
switch v := m.ConfigType.(type) { |
| 73 |
case *ResourceMonitor_Config: |
| 74 |
if v == nil { |
| 75 |
err := ResourceMonitorValidationError{ |
| 76 |
field: "ConfigType", |
| 77 |
reason: "oneof value cannot be a typed-nil", |
| 78 |
} |
| 79 |
if !all { |
| 80 |
return err |
| 81 |
} |
| 82 |
errors = append(errors, err) |
| 83 |
} |
| 84 |
|
| 85 |
if all { |
| 86 |
switch v := interface{}(m.GetConfig()).(type) { |
| 87 |
case interface{ ValidateAll() error }: |
| 88 |
if err := v.ValidateAll(); err != nil { |
| 89 |
errors = append(errors, ResourceMonitorValidationError{ |
| 90 |
field: "Config", |
| 91 |
reason: "embedded message failed validation", |
| 92 |
cause: err, |
| 93 |
}) |
| 94 |
} |
| 95 |
case interface{ Validate() error }: |
| 96 |
if err := v.Validate(); err != nil { |
| 97 |
errors = append(errors, ResourceMonitorValidationError{ |
| 98 |
field: "Config", |
| 99 |
reason: "embedded message failed validation", |
| 100 |
cause: err, |
| 101 |
}) |
| 102 |
} |
| 103 |
} |
| 104 |
} else if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok { |
| 105 |
if err := v.Validate(); err != nil { |
| 106 |
return ResourceMonitorValidationError{ |
| 107 |
field: "Config", |
| 108 |
reason: "embedded message failed validation", |
| 109 |
cause: err, |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
case *ResourceMonitor_TypedConfig: |
| 115 |
if v == nil { |
| 116 |
err := ResourceMonitorValidationError{ |
| 117 |
field: "ConfigType", |
| 118 |
reason: "oneof value cannot be a typed-nil", |
| 119 |
} |
| 120 |
if !all { |
| 121 |
return err |
| 122 |
} |
| 123 |
errors = append(errors, err) |
| 124 |
} |
| 125 |
|
| 126 |
if all { |
| 127 |
switch v := interface{}(m.GetTypedConfig()).(type) { |
| 128 |
case interface{ ValidateAll() error }: |
| 129 |
if err := v.ValidateAll(); err != nil { |
| 130 |
errors = append(errors, ResourceMonitorValidationError{ |
| 131 |
field: "TypedConfig", |
| 132 |
reason: "embedded message failed validation", |
| 133 |
cause: err, |
| 134 |
}) |
| 135 |
} |
| 136 |
case interface{ Validate() error }: |
| 137 |
if err := v.Validate(); err != nil { |
| 138 |
errors = append(errors, ResourceMonitorValidationError{ |
| 139 |
field: "TypedConfig", |
| 140 |
reason: "embedded message failed validation", |
| 141 |
cause: err, |
| 142 |
}) |
| 143 |
} |
| 144 |
} |
| 145 |
} else if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok { |
| 146 |
if err := v.Validate(); err != nil { |
| 147 |
return ResourceMonitorValidationError{ |
| 148 |
field: "TypedConfig", |
| 149 |
reason: "embedded message failed validation", |
| 150 |
cause: err, |
| 151 |
} |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
default: |
| 156 |
_ = v // ensures v is used |
| 157 |
} |
| 158 |
|
| 159 |
if len(errors) > 0 { |
| 160 |
return ResourceMonitorMultiError(errors) |
| 161 |
} |
| 162 |
|
| 163 |
return nil |
| 164 |
} |
| 165 |
|
| 166 |
// ResourceMonitorMultiError is an error wrapping multiple validation errors |
| 167 |
// returned by ResourceMonitor.ValidateAll() if the designated constraints |
| 168 |
// aren't met. |
| 169 |
type ResourceMonitorMultiError []error |
| 170 |
|
| 171 |
// Error returns a concatenation of all the error messages it wraps. |
| 172 |
func (m ResourceMonitorMultiError) Error() string { |
| 173 |
var msgs []string |
| 174 |
for _, err := range m { |
| 175 |
msgs = append(msgs, err.Error()) |
| 176 |
} |
| 177 |
return strings.Join(msgs, "; ") |
| 178 |
} |
| 179 |
|
| 180 |
// AllErrors returns a list of validation violation errors. |
| 181 |
func (m ResourceMonitorMultiError) AllErrors() []error { return m } |
| 182 |
|
| 183 |
// ResourceMonitorValidationError is the validation error returned by |
| 184 |
// ResourceMonitor.Validate if the designated constraints aren't met. |
| 185 |
type ResourceMonitorValidationError struct { |
| 186 |
field string |
| 187 |
reason string |
| 188 |
cause error |
| 189 |
key bool |
| 190 |
} |
| 191 |
|
| 192 |
// Field function returns field value. |
| 193 |
func (e ResourceMonitorValidationError) Field() string { return e.field } |
| 194 |
|
| 195 |
// Reason function returns reason value. |
| 196 |
func (e ResourceMonitorValidationError) Reason() string { return e.reason } |
| 197 |
|
| 198 |
// Cause function returns cause value. |
| 199 |
func (e ResourceMonitorValidationError) Cause() error { return e.cause } |
| 200 |
|
| 201 |
// Key function returns key value. |
| 202 |
func (e ResourceMonitorValidationError) Key() bool { return e.key } |
| 203 |
|
| 204 |
// ErrorName returns error name. |
| 205 |
func (e ResourceMonitorValidationError) ErrorName() string { return "ResourceMonitorValidationError" } |
| 206 |
|
| 207 |
// Error satisfies the builtin error interface |
| 208 |
func (e ResourceMonitorValidationError) Error() string { |
| 209 |
cause := "" |
| 210 |
if e.cause != nil { |
| 211 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 212 |
} |
| 213 |
|
| 214 |
key := "" |
| 215 |
if e.key { |
| 216 |
key = "key for " |
| 217 |
} |
| 218 |
|
| 219 |
return fmt.Sprintf( |
| 220 |
"invalid %sResourceMonitor.%s: %s%s", |
| 221 |
key, |
| 222 |
e.field, |
| 223 |
e.reason, |
| 224 |
cause) |
| 225 |
} |
| 226 |
|
| 227 |
var _ error = ResourceMonitorValidationError{} |
| 228 |
|
| 229 |
var _ interface { |
| 230 |
Field() string |
| 231 |
Reason() string |
| 232 |
Key() bool |
| 233 |
Cause() error |
| 234 |
ErrorName() string |
| 235 |
} = ResourceMonitorValidationError{} |
| 236 |
|
| 237 |
// Validate checks the field values on ThresholdTrigger with the rules defined |
| 238 |
// in the proto definition for this message. If any rules are violated, the |
| 239 |
// first error encountered is returned, or nil if there are no violations. |
| 240 |
func (m *ThresholdTrigger) Validate() error { |
| 241 |
return m.validate(false) |
| 242 |
} |
| 243 |
|
| 244 |
// ValidateAll checks the field values on ThresholdTrigger with the rules |
| 245 |
// defined in the proto definition for this message. If any rules are |
| 246 |
// violated, the result is a list of violation errors wrapped in |
| 247 |
// ThresholdTriggerMultiError, or nil if none found. |
| 248 |
func (m *ThresholdTrigger) ValidateAll() error { |
| 249 |
return m.validate(true) |
| 250 |
} |
| 251 |
|
| 252 |
func (m *ThresholdTrigger) validate(all bool) error { |
| 253 |
if m == nil { |
| 254 |
return nil |
| 255 |
} |
| 256 |
|
| 257 |
var errors []error |
| 258 |
|
| 259 |
if val := m.GetValue(); val < 0 || val > 1 { |
| 260 |
err := ThresholdTriggerValidationError{ |
| 261 |
field: "Value", |
| 262 |
reason: "value must be inside range [0, 1]", |
| 263 |
} |
| 264 |
if !all { |
| 265 |
return err |
| 266 |
} |
| 267 |
errors = append(errors, err) |
| 268 |
} |
| 269 |
|
| 270 |
if len(errors) > 0 { |
| 271 |
return ThresholdTriggerMultiError(errors) |
| 272 |
} |
| 273 |
|
| 274 |
return nil |
| 275 |
} |
| 276 |
|
| 277 |
// ThresholdTriggerMultiError is an error wrapping multiple validation errors |
| 278 |
// returned by ThresholdTrigger.ValidateAll() if the designated constraints |
| 279 |
// aren't met. |
| 280 |
type ThresholdTriggerMultiError []error |
| 281 |
|
| 282 |
// Error returns a concatenation of all the error messages it wraps. |
| 283 |
func (m ThresholdTriggerMultiError) Error() string { |
| 284 |
var msgs []string |
| 285 |
for _, err := range m { |
| 286 |
msgs = append(msgs, err.Error()) |
| 287 |
} |
| 288 |
return strings.Join(msgs, "; ") |
| 289 |
} |
| 290 |
|
| 291 |
// AllErrors returns a list of validation violation errors. |
| 292 |
func (m ThresholdTriggerMultiError) AllErrors() []error { return m } |
| 293 |
|
| 294 |
// ThresholdTriggerValidationError is the validation error returned by |
| 295 |
// ThresholdTrigger.Validate if the designated constraints aren't met. |
| 296 |
type ThresholdTriggerValidationError struct { |
| 297 |
field string |
| 298 |
reason string |
| 299 |
cause error |
| 300 |
key bool |
| 301 |
} |
| 302 |
|
| 303 |
// Field function returns field value. |
| 304 |
func (e ThresholdTriggerValidationError) Field() string { return e.field } |
| 305 |
|
| 306 |
// Reason function returns reason value. |
| 307 |
func (e ThresholdTriggerValidationError) Reason() string { return e.reason } |
| 308 |
|
| 309 |
// Cause function returns cause value. |
| 310 |
func (e ThresholdTriggerValidationError) Cause() error { return e.cause } |
| 311 |
|
| 312 |
// Key function returns key value. |
| 313 |
func (e ThresholdTriggerValidationError) Key() bool { return e.key } |
| 314 |
|
| 315 |
// ErrorName returns error name. |
| 316 |
func (e ThresholdTriggerValidationError) ErrorName() string { return "ThresholdTriggerValidationError" } |
| 317 |
|
| 318 |
// Error satisfies the builtin error interface |
| 319 |
func (e ThresholdTriggerValidationError) Error() string { |
| 320 |
cause := "" |
| 321 |
if e.cause != nil { |
| 322 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 323 |
} |
| 324 |
|
| 325 |
key := "" |
| 326 |
if e.key { |
| 327 |
key = "key for " |
| 328 |
} |
| 329 |
|
| 330 |
return fmt.Sprintf( |
| 331 |
"invalid %sThresholdTrigger.%s: %s%s", |
| 332 |
key, |
| 333 |
e.field, |
| 334 |
e.reason, |
| 335 |
cause) |
| 336 |
} |
| 337 |
|
| 338 |
var _ error = ThresholdTriggerValidationError{} |
| 339 |
|
| 340 |
var _ interface { |
| 341 |
Field() string |
| 342 |
Reason() string |
| 343 |
Key() bool |
| 344 |
Cause() error |
| 345 |
ErrorName() string |
| 346 |
} = ThresholdTriggerValidationError{} |
| 347 |
|
| 348 |
// Validate checks the field values on Trigger with the rules defined in the |
| 349 |
// proto definition for this message. If any rules are violated, the first |
| 350 |
// error encountered is returned, or nil if there are no violations. |
| 351 |
func (m *Trigger) Validate() error { |
| 352 |
return m.validate(false) |
| 353 |
} |
| 354 |
|
| 355 |
// ValidateAll checks the field values on Trigger with the rules defined in the |
| 356 |
// proto definition for this message. If any rules are violated, the result is |
| 357 |
// a list of violation errors wrapped in TriggerMultiError, or nil if none found. |
| 358 |
func (m *Trigger) ValidateAll() error { |
| 359 |
return m.validate(true) |
| 360 |
} |
| 361 |
|
| 362 |
func (m *Trigger) validate(all bool) error { |
| 363 |
if m == nil { |
| 364 |
return nil |
| 365 |
} |
| 366 |
|
| 367 |
var errors []error |
| 368 |
|
| 369 |
if len(m.GetName()) < 1 { |
| 370 |
err := TriggerValidationError{ |
| 371 |
field: "Name", |
| 372 |
reason: "value length must be at least 1 bytes", |
| 373 |
} |
| 374 |
if !all { |
| 375 |
return err |
| 376 |
} |
| 377 |
errors = append(errors, err) |
| 378 |
} |
| 379 |
|
| 380 |
oneofTriggerOneofPresent := false |
| 381 |
switch v := m.TriggerOneof.(type) { |
| 382 |
case *Trigger_Threshold: |
| 383 |
if v == nil { |
| 384 |
err := TriggerValidationError{ |
| 385 |
field: "TriggerOneof", |
| 386 |
reason: "oneof value cannot be a typed-nil", |
| 387 |
} |
| 388 |
if !all { |
| 389 |
return err |
| 390 |
} |
| 391 |
errors = append(errors, err) |
| 392 |
} |
| 393 |
oneofTriggerOneofPresent = true |
| 394 |
|
| 395 |
if all { |
| 396 |
switch v := interface{}(m.GetThreshold()).(type) { |
| 397 |
case interface{ ValidateAll() error }: |
| 398 |
if err := v.ValidateAll(); err != nil { |
| 399 |
errors = append(errors, TriggerValidationError{ |
| 400 |
field: "Threshold", |
| 401 |
reason: "embedded message failed validation", |
| 402 |
cause: err, |
| 403 |
}) |
| 404 |
} |
| 405 |
case interface{ Validate() error }: |
| 406 |
if err := v.Validate(); err != nil { |
| 407 |
errors = append(errors, TriggerValidationError{ |
| 408 |
field: "Threshold", |
| 409 |
reason: "embedded message failed validation", |
| 410 |
cause: err, |
| 411 |
}) |
| 412 |
} |
| 413 |
} |
| 414 |
} else if v, ok := interface{}(m.GetThreshold()).(interface{ Validate() error }); ok { |
| 415 |
if err := v.Validate(); err != nil { |
| 416 |
return TriggerValidationError{ |
| 417 |
field: "Threshold", |
| 418 |
reason: "embedded message failed validation", |
| 419 |
cause: err, |
| 420 |
} |
| 421 |
} |
| 422 |
} |
| 423 |
|
| 424 |
default: |
| 425 |
_ = v // ensures v is used |
| 426 |
} |
| 427 |
if !oneofTriggerOneofPresent { |
| 428 |
err := TriggerValidationError{ |
| 429 |
field: "TriggerOneof", |
| 430 |
reason: "value is required", |
| 431 |
} |
| 432 |
if !all { |
| 433 |
return err |
| 434 |
} |
| 435 |
errors = append(errors, err) |
| 436 |
} |
| 437 |
|
| 438 |
if len(errors) > 0 { |
| 439 |
return TriggerMultiError(errors) |
| 440 |
} |
| 441 |
|
| 442 |
return nil |
| 443 |
} |
| 444 |
|
| 445 |
// TriggerMultiError is an error wrapping multiple validation errors returned |
| 446 |
// by Trigger.ValidateAll() if the designated constraints aren't met. |
| 447 |
type TriggerMultiError []error |
| 448 |
|
| 449 |
// Error returns a concatenation of all the error messages it wraps. |
| 450 |
func (m TriggerMultiError) Error() string { |
| 451 |
var msgs []string |
| 452 |
for _, err := range m { |
| 453 |
msgs = append(msgs, err.Error()) |
| 454 |
} |
| 455 |
return strings.Join(msgs, "; ") |
| 456 |
} |
| 457 |
|
| 458 |
// AllErrors returns a list of validation violation errors. |
| 459 |
func (m TriggerMultiError) AllErrors() []error { return m } |
| 460 |
|
| 461 |
// TriggerValidationError is the validation error returned by Trigger.Validate |
| 462 |
// if the designated constraints aren't met. |
| 463 |
type TriggerValidationError struct { |
| 464 |
field string |
| 465 |
reason string |
| 466 |
cause error |
| 467 |
key bool |
| 468 |
} |
| 469 |
|
| 470 |
// Field function returns field value. |
| 471 |
func (e TriggerValidationError) Field() string { return e.field } |
| 472 |
|
| 473 |
// Reason function returns reason value. |
| 474 |
func (e TriggerValidationError) Reason() string { return e.reason } |
| 475 |
|
| 476 |
// Cause function returns cause value. |
| 477 |
func (e TriggerValidationError) Cause() error { return e.cause } |
| 478 |
|
| 479 |
// Key function returns key value. |
| 480 |
func (e TriggerValidationError) Key() bool { return e.key } |
| 481 |
|
| 482 |
// ErrorName returns error name. |
| 483 |
func (e TriggerValidationError) ErrorName() string { return "TriggerValidationError" } |
| 484 |
|
| 485 |
// Error satisfies the builtin error interface |
| 486 |
func (e TriggerValidationError) Error() string { |
| 487 |
cause := "" |
| 488 |
if e.cause != nil { |
| 489 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 490 |
} |
| 491 |
|
| 492 |
key := "" |
| 493 |
if e.key { |
| 494 |
key = "key for " |
| 495 |
} |
| 496 |
|
| 497 |
return fmt.Sprintf( |
| 498 |
"invalid %sTrigger.%s: %s%s", |
| 499 |
key, |
| 500 |
e.field, |
| 501 |
e.reason, |
| 502 |
cause) |
| 503 |
} |
| 504 |
|
| 505 |
var _ error = TriggerValidationError{} |
| 506 |
|
| 507 |
var _ interface { |
| 508 |
Field() string |
| 509 |
Reason() string |
| 510 |
Key() bool |
| 511 |
Cause() error |
| 512 |
ErrorName() string |
| 513 |
} = TriggerValidationError{} |
| 514 |
|
| 515 |
// Validate checks the field values on OverloadAction with the rules defined in |
| 516 |
// the proto definition for this message. If any rules are violated, the first |
| 517 |
// error encountered is returned, or nil if there are no violations. |
| 518 |
func (m *OverloadAction) Validate() error { |
| 519 |
return m.validate(false) |
| 520 |
} |
| 521 |
|
| 522 |
// ValidateAll checks the field values on OverloadAction with the rules defined |
| 523 |
// in the proto definition for this message. If any rules are violated, the |
| 524 |
// result is a list of violation errors wrapped in OverloadActionMultiError, |
| 525 |
// or nil if none found. |
| 526 |
func (m *OverloadAction) ValidateAll() error { |
| 527 |
return m.validate(true) |
| 528 |
} |
| 529 |
|
| 530 |
func (m *OverloadAction) validate(all bool) error { |
| 531 |
if m == nil { |
| 532 |
return nil |
| 533 |
} |
| 534 |
|
| 535 |
var errors []error |
| 536 |
|
| 537 |
if len(m.GetName()) < 1 { |
| 538 |
err := OverloadActionValidationError{ |
| 539 |
field: "Name", |
| 540 |
reason: "value length must be at least 1 bytes", |
| 541 |
} |
| 542 |
if !all { |
| 543 |
return err |
| 544 |
} |
| 545 |
errors = append(errors, err) |
| 546 |
} |
| 547 |
|
| 548 |
if len(m.GetTriggers()) < 1 { |
| 549 |
err := OverloadActionValidationError{ |
| 550 |
field: "Triggers", |
| 551 |
reason: "value must contain at least 1 item(s)", |
| 552 |
} |
| 553 |
if !all { |
| 554 |
return err |
| 555 |
} |
| 556 |
errors = append(errors, err) |
| 557 |
} |
| 558 |
|
| 559 |
for idx, item := range m.GetTriggers() { |
| 560 |
_, _ = idx, item |
| 561 |
|
| 562 |
if all { |
| 563 |
switch v := interface{}(item).(type) { |
| 564 |
case interface{ ValidateAll() error }: |
| 565 |
if err := v.ValidateAll(); err != nil { |
| 566 |
errors = append(errors, OverloadActionValidationError{ |
| 567 |
field: fmt.Sprintf("Triggers[%v]", idx), |
| 568 |
reason: "embedded message failed validation", |
| 569 |
cause: err, |
| 570 |
}) |
| 571 |
} |
| 572 |
case interface{ Validate() error }: |
| 573 |
if err := v.Validate(); err != nil { |
| 574 |
errors = append(errors, OverloadActionValidationError{ |
| 575 |
field: fmt.Sprintf("Triggers[%v]", idx), |
| 576 |
reason: "embedded message failed validation", |
| 577 |
cause: err, |
| 578 |
}) |
| 579 |
} |
| 580 |
} |
| 581 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 582 |
if err := v.Validate(); err != nil { |
| 583 |
return OverloadActionValidationError{ |
| 584 |
field: fmt.Sprintf("Triggers[%v]", idx), |
| 585 |
reason: "embedded message failed validation", |
| 586 |
cause: err, |
| 587 |
} |
| 588 |
} |
| 589 |
} |
| 590 |
|
| 591 |
} |
| 592 |
|
| 593 |
if len(errors) > 0 { |
| 594 |
return OverloadActionMultiError(errors) |
| 595 |
} |
| 596 |
|
| 597 |
return nil |
| 598 |
} |
| 599 |
|
| 600 |
// OverloadActionMultiError is an error wrapping multiple validation errors |
| 601 |
// returned by OverloadAction.ValidateAll() if the designated constraints |
| 602 |
// aren't met. |
| 603 |
type OverloadActionMultiError []error |
| 604 |
|
| 605 |
// Error returns a concatenation of all the error messages it wraps. |
| 606 |
func (m OverloadActionMultiError) Error() string { |
| 607 |
var msgs []string |
| 608 |
for _, err := range m { |
| 609 |
msgs = append(msgs, err.Error()) |
| 610 |
} |
| 611 |
return strings.Join(msgs, "; ") |
| 612 |
} |
| 613 |
|
| 614 |
// AllErrors returns a list of validation violation errors. |
| 615 |
func (m OverloadActionMultiError) AllErrors() []error { return m } |
| 616 |
|
| 617 |
// OverloadActionValidationError is the validation error returned by |
| 618 |
// OverloadAction.Validate if the designated constraints aren't met. |
| 619 |
type OverloadActionValidationError struct { |
| 620 |
field string |
| 621 |
reason string |
| 622 |
cause error |
| 623 |
key bool |
| 624 |
} |
| 625 |
|
| 626 |
// Field function returns field value. |
| 627 |
func (e OverloadActionValidationError) Field() string { return e.field } |
| 628 |
|
| 629 |
// Reason function returns reason value. |
| 630 |
func (e OverloadActionValidationError) Reason() string { return e.reason } |
| 631 |
|
| 632 |
// Cause function returns cause value. |
| 633 |
func (e OverloadActionValidationError) Cause() error { return e.cause } |
| 634 |
|
| 635 |
// Key function returns key value. |
| 636 |
func (e OverloadActionValidationError) Key() bool { return e.key } |
| 637 |
|
| 638 |
// ErrorName returns error name. |
| 639 |
func (e OverloadActionValidationError) ErrorName() string { return "OverloadActionValidationError" } |
| 640 |
|
| 641 |
// Error satisfies the builtin error interface |
| 642 |
func (e OverloadActionValidationError) Error() string { |
| 643 |
cause := "" |
| 644 |
if e.cause != nil { |
| 645 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 646 |
} |
| 647 |
|
| 648 |
key := "" |
| 649 |
if e.key { |
| 650 |
key = "key for " |
| 651 |
} |
| 652 |
|
| 653 |
return fmt.Sprintf( |
| 654 |
"invalid %sOverloadAction.%s: %s%s", |
| 655 |
key, |
| 656 |
e.field, |
| 657 |
e.reason, |
| 658 |
cause) |
| 659 |
} |
| 660 |
|
| 661 |
var _ error = OverloadActionValidationError{} |
| 662 |
|
| 663 |
var _ interface { |
| 664 |
Field() string |
| 665 |
Reason() string |
| 666 |
Key() bool |
| 667 |
Cause() error |
| 668 |
ErrorName() string |
| 669 |
} = OverloadActionValidationError{} |
| 670 |
|
| 671 |
// Validate checks the field values on OverloadManager with the rules defined |
| 672 |
// in the proto definition for this message. If any rules are violated, the |
| 673 |
// first error encountered is returned, or nil if there are no violations. |
| 674 |
func (m *OverloadManager) Validate() error { |
| 675 |
return m.validate(false) |
| 676 |
} |
| 677 |
|
| 678 |
// ValidateAll checks the field values on OverloadManager with the rules |
| 679 |
// defined in the proto definition for this message. If any rules are |
| 680 |
// violated, the result is a list of violation errors wrapped in |
| 681 |
// OverloadManagerMultiError, or nil if none found. |
| 682 |
func (m *OverloadManager) ValidateAll() error { |
| 683 |
return m.validate(true) |
| 684 |
} |
| 685 |
|
| 686 |
func (m *OverloadManager) validate(all bool) error { |
| 687 |
if m == nil { |
| 688 |
return nil |
| 689 |
} |
| 690 |
|
| 691 |
var errors []error |
| 692 |
|
| 693 |
if all { |
| 694 |
switch v := interface{}(m.GetRefreshInterval()).(type) { |
| 695 |
case interface{ ValidateAll() error }: |
| 696 |
if err := v.ValidateAll(); err != nil { |
| 697 |
errors = append(errors, OverloadManagerValidationError{ |
| 698 |
field: "RefreshInterval", |
| 699 |
reason: "embedded message failed validation", |
| 700 |
cause: err, |
| 701 |
}) |
| 702 |
} |
| 703 |
case interface{ Validate() error }: |
| 704 |
if err := v.Validate(); err != nil { |
| 705 |
errors = append(errors, OverloadManagerValidationError{ |
| 706 |
field: "RefreshInterval", |
| 707 |
reason: "embedded message failed validation", |
| 708 |
cause: err, |
| 709 |
}) |
| 710 |
} |
| 711 |
} |
| 712 |
} else if v, ok := interface{}(m.GetRefreshInterval()).(interface{ Validate() error }); ok { |
| 713 |
if err := v.Validate(); err != nil { |
| 714 |
return OverloadManagerValidationError{ |
| 715 |
field: "RefreshInterval", |
| 716 |
reason: "embedded message failed validation", |
| 717 |
cause: err, |
| 718 |
} |
| 719 |
} |
| 720 |
} |
| 721 |
|
| 722 |
if len(m.GetResourceMonitors()) < 1 { |
| 723 |
err := OverloadManagerValidationError{ |
| 724 |
field: "ResourceMonitors", |
| 725 |
reason: "value must contain at least 1 item(s)", |
| 726 |
} |
| 727 |
if !all { |
| 728 |
return err |
| 729 |
} |
| 730 |
errors = append(errors, err) |
| 731 |
} |
| 732 |
|
| 733 |
for idx, item := range m.GetResourceMonitors() { |
| 734 |
_, _ = idx, item |
| 735 |
|
| 736 |
if all { |
| 737 |
switch v := interface{}(item).(type) { |
| 738 |
case interface{ ValidateAll() error }: |
| 739 |
if err := v.ValidateAll(); err != nil { |
| 740 |
errors = append(errors, OverloadManagerValidationError{ |
| 741 |
field: fmt.Sprintf("ResourceMonitors[%v]", idx), |
| 742 |
reason: "embedded message failed validation", |
| 743 |
cause: err, |
| 744 |
}) |
| 745 |
} |
| 746 |
case interface{ Validate() error }: |
| 747 |
if err := v.Validate(); err != nil { |
| 748 |
errors = append(errors, OverloadManagerValidationError{ |
| 749 |
field: fmt.Sprintf("ResourceMonitors[%v]", idx), |
| 750 |
reason: "embedded message failed validation", |
| 751 |
cause: err, |
| 752 |
}) |
| 753 |
} |
| 754 |
} |
| 755 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 756 |
if err := v.Validate(); err != nil { |
| 757 |
return OverloadManagerValidationError{ |
| 758 |
field: fmt.Sprintf("ResourceMonitors[%v]", idx), |
| 759 |
reason: "embedded message failed validation", |
| 760 |
cause: err, |
| 761 |
} |
| 762 |
} |
| 763 |
} |
| 764 |
|
| 765 |
} |
| 766 |
|
| 767 |
for idx, item := range m.GetActions() { |
| 768 |
_, _ = idx, item |
| 769 |
|
| 770 |
if all { |
| 771 |
switch v := interface{}(item).(type) { |
| 772 |
case interface{ ValidateAll() error }: |
| 773 |
if err := v.ValidateAll(); err != nil { |
| 774 |
errors = append(errors, OverloadManagerValidationError{ |
| 775 |
field: fmt.Sprintf("Actions[%v]", idx), |
| 776 |
reason: "embedded message failed validation", |
| 777 |
cause: err, |
| 778 |
}) |
| 779 |
} |
| 780 |
case interface{ Validate() error }: |
| 781 |
if err := v.Validate(); err != nil { |
| 782 |
errors = append(errors, OverloadManagerValidationError{ |
| 783 |
field: fmt.Sprintf("Actions[%v]", idx), |
| 784 |
reason: "embedded message failed validation", |
| 785 |
cause: err, |
| 786 |
}) |
| 787 |
} |
| 788 |
} |
| 789 |
} else if v, ok := interface{}(item).(interface{ Validate() error }); ok { |
| 790 |
if err := v.Validate(); err != nil { |
| 791 |
return OverloadManagerValidationError{ |
| 792 |
field: fmt.Sprintf("Actions[%v]", idx), |
| 793 |
reason: "embedded message failed validation", |
| 794 |
cause: err, |
| 795 |
} |
| 796 |
} |
| 797 |
} |
| 798 |
|
| 799 |
} |
| 800 |
|
| 801 |
if len(errors) > 0 { |
| 802 |
return OverloadManagerMultiError(errors) |
| 803 |
} |
| 804 |
|
| 805 |
return nil |
| 806 |
} |
| 807 |
|
| 808 |
// OverloadManagerMultiError is an error wrapping multiple validation errors |
| 809 |
// returned by OverloadManager.ValidateAll() if the designated constraints |
| 810 |
// aren't met. |
| 811 |
type OverloadManagerMultiError []error |
| 812 |
|
| 813 |
// Error returns a concatenation of all the error messages it wraps. |
| 814 |
func (m OverloadManagerMultiError) Error() string { |
| 815 |
var msgs []string |
| 816 |
for _, err := range m { |
| 817 |
msgs = append(msgs, err.Error()) |
| 818 |
} |
| 819 |
return strings.Join(msgs, "; ") |
| 820 |
} |
| 821 |
|
| 822 |
// AllErrors returns a list of validation violation errors. |
| 823 |
func (m OverloadManagerMultiError) AllErrors() []error { return m } |
| 824 |
|
| 825 |
// OverloadManagerValidationError is the validation error returned by |
| 826 |
// OverloadManager.Validate if the designated constraints aren't met. |
| 827 |
type OverloadManagerValidationError struct { |
| 828 |
field string |
| 829 |
reason string |
| 830 |
cause error |
| 831 |
key bool |
| 832 |
} |
| 833 |
|
| 834 |
// Field function returns field value. |
| 835 |
func (e OverloadManagerValidationError) Field() string { return e.field } |
| 836 |
|
| 837 |
// Reason function returns reason value. |
| 838 |
func (e OverloadManagerValidationError) Reason() string { return e.reason } |
| 839 |
|
| 840 |
// Cause function returns cause value. |
| 841 |
func (e OverloadManagerValidationError) Cause() error { return e.cause } |
| 842 |
|
| 843 |
// Key function returns key value. |
| 844 |
func (e OverloadManagerValidationError) Key() bool { return e.key } |
| 845 |
|
| 846 |
// ErrorName returns error name. |
| 847 |
func (e OverloadManagerValidationError) ErrorName() string { return "OverloadManagerValidationError" } |
| 848 |
|
| 849 |
// Error satisfies the builtin error interface |
| 850 |
func (e OverloadManagerValidationError) Error() string { |
| 851 |
cause := "" |
| 852 |
if e.cause != nil { |
| 853 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 854 |
} |
| 855 |
|
| 856 |
key := "" |
| 857 |
if e.key { |
| 858 |
key = "key for " |
| 859 |
} |
| 860 |
|
| 861 |
return fmt.Sprintf( |
| 862 |
"invalid %sOverloadManager.%s: %s%s", |
| 863 |
key, |
| 864 |
e.field, |
| 865 |
e.reason, |
| 866 |
cause) |
| 867 |
} |
| 868 |
|
| 869 |
var _ error = OverloadManagerValidationError{} |
| 870 |
|
| 871 |
var _ interface { |
| 872 |
Field() string |
| 873 |
Reason() string |
| 874 |
Key() bool |
| 875 |
Cause() error |
| 876 |
ErrorName() string |
| 877 |
} = OverloadManagerValidationError{} |