github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/rbac/v3/rbac.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/config/rbac/v3/rbac.proto 3 4 package envoy_config_rbac_v3 5 6 import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "strings" 15 "time" 16 "unicode/utf8" 17 18 "google.golang.org/protobuf/types/known/anypb" 19 ) 20 21 // ensure the imports are used 22 var ( 23 _ = bytes.MinRead 24 _ = errors.New("") 25 _ = fmt.Print 26 _ = utf8.UTFMax 27 _ = (*regexp.Regexp)(nil) 28 _ = (*strings.Reader)(nil) 29 _ = net.IPv4len 30 _ = time.Duration(0) 31 _ = (*url.URL)(nil) 32 _ = (*mail.Address)(nil) 33 _ = anypb.Any{} 34 ) 35 36 // Validate checks the field values on RBAC with the rules defined in the proto 37 // definition for this message. If any rules are violated, an error is returned. 38 func (m *RBAC) Validate() error { 39 if m == nil { 40 return nil 41 } 42 43 if _, ok := RBAC_Action_name[int32(m.GetAction())]; !ok { 44 return RBACValidationError{ 45 field: "Action", 46 reason: "value must be one of the defined enum values", 47 } 48 } 49 50 for key, val := range m.GetPolicies() { 51 _ = val 52 53 // no validation rules for Policies[key] 54 55 if v, ok := interface{}(val).(interface{ Validate() error }); ok { 56 if err := v.Validate(); err != nil { 57 return RBACValidationError{ 58 field: fmt.Sprintf("Policies[%v]", key), 59 reason: "embedded message failed validation", 60 cause: err, 61 } 62 } 63 } 64 65 } 66 67 return nil 68 } 69 70 // RBACValidationError is the validation error returned by RBAC.Validate if the 71 // designated constraints aren't met. 72 type RBACValidationError struct { 73 field string 74 reason string 75 cause error 76 key bool 77 } 78 79 // Field function returns field value. 80 func (e RBACValidationError) Field() string { return e.field } 81 82 // Reason function returns reason value. 83 func (e RBACValidationError) Reason() string { return e.reason } 84 85 // Cause function returns cause value. 86 func (e RBACValidationError) Cause() error { return e.cause } 87 88 // Key function returns key value. 89 func (e RBACValidationError) Key() bool { return e.key } 90 91 // ErrorName returns error name. 92 func (e RBACValidationError) ErrorName() string { return "RBACValidationError" } 93 94 // Error satisfies the builtin error interface 95 func (e RBACValidationError) Error() string { 96 cause := "" 97 if e.cause != nil { 98 cause = fmt.Sprintf(" | caused by: %v", e.cause) 99 } 100 101 key := "" 102 if e.key { 103 key = "key for " 104 } 105 106 return fmt.Sprintf( 107 "invalid %sRBAC.%s: %s%s", 108 key, 109 e.field, 110 e.reason, 111 cause) 112 } 113 114 var _ error = RBACValidationError{} 115 116 var _ interface { 117 Field() string 118 Reason() string 119 Key() bool 120 Cause() error 121 ErrorName() string 122 } = RBACValidationError{} 123 124 // Validate checks the field values on Policy with the rules defined in the 125 // proto definition for this message. If any rules are violated, an error is returned. 126 func (m *Policy) Validate() error { 127 if m == nil { 128 return nil 129 } 130 131 if len(m.GetPermissions()) < 1 { 132 return PolicyValidationError{ 133 field: "Permissions", 134 reason: "value must contain at least 1 item(s)", 135 } 136 } 137 138 for idx, item := range m.GetPermissions() { 139 _, _ = idx, item 140 141 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 142 if err := v.Validate(); err != nil { 143 return PolicyValidationError{ 144 field: fmt.Sprintf("Permissions[%v]", idx), 145 reason: "embedded message failed validation", 146 cause: err, 147 } 148 } 149 } 150 151 } 152 153 if len(m.GetPrincipals()) < 1 { 154 return PolicyValidationError{ 155 field: "Principals", 156 reason: "value must contain at least 1 item(s)", 157 } 158 } 159 160 for idx, item := range m.GetPrincipals() { 161 _, _ = idx, item 162 163 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 164 if err := v.Validate(); err != nil { 165 return PolicyValidationError{ 166 field: fmt.Sprintf("Principals[%v]", idx), 167 reason: "embedded message failed validation", 168 cause: err, 169 } 170 } 171 } 172 173 } 174 175 if v, ok := interface{}(m.GetCondition()).(interface{ Validate() error }); ok { 176 if err := v.Validate(); err != nil { 177 return PolicyValidationError{ 178 field: "Condition", 179 reason: "embedded message failed validation", 180 cause: err, 181 } 182 } 183 } 184 185 if v, ok := interface{}(m.GetCheckedCondition()).(interface{ Validate() error }); ok { 186 if err := v.Validate(); err != nil { 187 return PolicyValidationError{ 188 field: "CheckedCondition", 189 reason: "embedded message failed validation", 190 cause: err, 191 } 192 } 193 } 194 195 return nil 196 } 197 198 // PolicyValidationError is the validation error returned by Policy.Validate if 199 // the designated constraints aren't met. 200 type PolicyValidationError struct { 201 field string 202 reason string 203 cause error 204 key bool 205 } 206 207 // Field function returns field value. 208 func (e PolicyValidationError) Field() string { return e.field } 209 210 // Reason function returns reason value. 211 func (e PolicyValidationError) Reason() string { return e.reason } 212 213 // Cause function returns cause value. 214 func (e PolicyValidationError) Cause() error { return e.cause } 215 216 // Key function returns key value. 217 func (e PolicyValidationError) Key() bool { return e.key } 218 219 // ErrorName returns error name. 220 func (e PolicyValidationError) ErrorName() string { return "PolicyValidationError" } 221 222 // Error satisfies the builtin error interface 223 func (e PolicyValidationError) Error() string { 224 cause := "" 225 if e.cause != nil { 226 cause = fmt.Sprintf(" | caused by: %v", e.cause) 227 } 228 229 key := "" 230 if e.key { 231 key = "key for " 232 } 233 234 return fmt.Sprintf( 235 "invalid %sPolicy.%s: %s%s", 236 key, 237 e.field, 238 e.reason, 239 cause) 240 } 241 242 var _ error = PolicyValidationError{} 243 244 var _ interface { 245 Field() string 246 Reason() string 247 Key() bool 248 Cause() error 249 ErrorName() string 250 } = PolicyValidationError{} 251 252 // Validate checks the field values on Permission with the rules defined in the 253 // proto definition for this message. If any rules are violated, an error is returned. 254 func (m *Permission) Validate() error { 255 if m == nil { 256 return nil 257 } 258 259 switch m.Rule.(type) { 260 261 case *Permission_AndRules: 262 263 if v, ok := interface{}(m.GetAndRules()).(interface{ Validate() error }); ok { 264 if err := v.Validate(); err != nil { 265 return PermissionValidationError{ 266 field: "AndRules", 267 reason: "embedded message failed validation", 268 cause: err, 269 } 270 } 271 } 272 273 case *Permission_OrRules: 274 275 if v, ok := interface{}(m.GetOrRules()).(interface{ Validate() error }); ok { 276 if err := v.Validate(); err != nil { 277 return PermissionValidationError{ 278 field: "OrRules", 279 reason: "embedded message failed validation", 280 cause: err, 281 } 282 } 283 } 284 285 case *Permission_Any: 286 287 if m.GetAny() != true { 288 return PermissionValidationError{ 289 field: "Any", 290 reason: "value must equal true", 291 } 292 } 293 294 case *Permission_Header: 295 296 if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok { 297 if err := v.Validate(); err != nil { 298 return PermissionValidationError{ 299 field: "Header", 300 reason: "embedded message failed validation", 301 cause: err, 302 } 303 } 304 } 305 306 case *Permission_UrlPath: 307 308 if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok { 309 if err := v.Validate(); err != nil { 310 return PermissionValidationError{ 311 field: "UrlPath", 312 reason: "embedded message failed validation", 313 cause: err, 314 } 315 } 316 } 317 318 case *Permission_DestinationIp: 319 320 if v, ok := interface{}(m.GetDestinationIp()).(interface{ Validate() error }); ok { 321 if err := v.Validate(); err != nil { 322 return PermissionValidationError{ 323 field: "DestinationIp", 324 reason: "embedded message failed validation", 325 cause: err, 326 } 327 } 328 } 329 330 case *Permission_DestinationPort: 331 332 if m.GetDestinationPort() > 65535 { 333 return PermissionValidationError{ 334 field: "DestinationPort", 335 reason: "value must be less than or equal to 65535", 336 } 337 } 338 339 case *Permission_DestinationPortRange: 340 341 if v, ok := interface{}(m.GetDestinationPortRange()).(interface{ Validate() error }); ok { 342 if err := v.Validate(); err != nil { 343 return PermissionValidationError{ 344 field: "DestinationPortRange", 345 reason: "embedded message failed validation", 346 cause: err, 347 } 348 } 349 } 350 351 case *Permission_Metadata: 352 353 if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { 354 if err := v.Validate(); err != nil { 355 return PermissionValidationError{ 356 field: "Metadata", 357 reason: "embedded message failed validation", 358 cause: err, 359 } 360 } 361 } 362 363 case *Permission_NotRule: 364 365 if v, ok := interface{}(m.GetNotRule()).(interface{ Validate() error }); ok { 366 if err := v.Validate(); err != nil { 367 return PermissionValidationError{ 368 field: "NotRule", 369 reason: "embedded message failed validation", 370 cause: err, 371 } 372 } 373 } 374 375 case *Permission_RequestedServerName: 376 377 if v, ok := interface{}(m.GetRequestedServerName()).(interface{ Validate() error }); ok { 378 if err := v.Validate(); err != nil { 379 return PermissionValidationError{ 380 field: "RequestedServerName", 381 reason: "embedded message failed validation", 382 cause: err, 383 } 384 } 385 } 386 387 default: 388 return PermissionValidationError{ 389 field: "Rule", 390 reason: "value is required", 391 } 392 393 } 394 395 return nil 396 } 397 398 // PermissionValidationError is the validation error returned by 399 // Permission.Validate if the designated constraints aren't met. 400 type PermissionValidationError struct { 401 field string 402 reason string 403 cause error 404 key bool 405 } 406 407 // Field function returns field value. 408 func (e PermissionValidationError) Field() string { return e.field } 409 410 // Reason function returns reason value. 411 func (e PermissionValidationError) Reason() string { return e.reason } 412 413 // Cause function returns cause value. 414 func (e PermissionValidationError) Cause() error { return e.cause } 415 416 // Key function returns key value. 417 func (e PermissionValidationError) Key() bool { return e.key } 418 419 // ErrorName returns error name. 420 func (e PermissionValidationError) ErrorName() string { return "PermissionValidationError" } 421 422 // Error satisfies the builtin error interface 423 func (e PermissionValidationError) Error() string { 424 cause := "" 425 if e.cause != nil { 426 cause = fmt.Sprintf(" | caused by: %v", e.cause) 427 } 428 429 key := "" 430 if e.key { 431 key = "key for " 432 } 433 434 return fmt.Sprintf( 435 "invalid %sPermission.%s: %s%s", 436 key, 437 e.field, 438 e.reason, 439 cause) 440 } 441 442 var _ error = PermissionValidationError{} 443 444 var _ interface { 445 Field() string 446 Reason() string 447 Key() bool 448 Cause() error 449 ErrorName() string 450 } = PermissionValidationError{} 451 452 // Validate checks the field values on Principal with the rules defined in the 453 // proto definition for this message. If any rules are violated, an error is returned. 454 func (m *Principal) Validate() error { 455 if m == nil { 456 return nil 457 } 458 459 switch m.Identifier.(type) { 460 461 case *Principal_AndIds: 462 463 if v, ok := interface{}(m.GetAndIds()).(interface{ Validate() error }); ok { 464 if err := v.Validate(); err != nil { 465 return PrincipalValidationError{ 466 field: "AndIds", 467 reason: "embedded message failed validation", 468 cause: err, 469 } 470 } 471 } 472 473 case *Principal_OrIds: 474 475 if v, ok := interface{}(m.GetOrIds()).(interface{ Validate() error }); ok { 476 if err := v.Validate(); err != nil { 477 return PrincipalValidationError{ 478 field: "OrIds", 479 reason: "embedded message failed validation", 480 cause: err, 481 } 482 } 483 } 484 485 case *Principal_Any: 486 487 if m.GetAny() != true { 488 return PrincipalValidationError{ 489 field: "Any", 490 reason: "value must equal true", 491 } 492 } 493 494 case *Principal_Authenticated_: 495 496 if v, ok := interface{}(m.GetAuthenticated()).(interface{ Validate() error }); ok { 497 if err := v.Validate(); err != nil { 498 return PrincipalValidationError{ 499 field: "Authenticated", 500 reason: "embedded message failed validation", 501 cause: err, 502 } 503 } 504 } 505 506 case *Principal_SourceIp: 507 508 if v, ok := interface{}(m.GetSourceIp()).(interface{ Validate() error }); ok { 509 if err := v.Validate(); err != nil { 510 return PrincipalValidationError{ 511 field: "SourceIp", 512 reason: "embedded message failed validation", 513 cause: err, 514 } 515 } 516 } 517 518 case *Principal_DirectRemoteIp: 519 520 if v, ok := interface{}(m.GetDirectRemoteIp()).(interface{ Validate() error }); ok { 521 if err := v.Validate(); err != nil { 522 return PrincipalValidationError{ 523 field: "DirectRemoteIp", 524 reason: "embedded message failed validation", 525 cause: err, 526 } 527 } 528 } 529 530 case *Principal_RemoteIp: 531 532 if v, ok := interface{}(m.GetRemoteIp()).(interface{ Validate() error }); ok { 533 if err := v.Validate(); err != nil { 534 return PrincipalValidationError{ 535 field: "RemoteIp", 536 reason: "embedded message failed validation", 537 cause: err, 538 } 539 } 540 } 541 542 case *Principal_Header: 543 544 if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok { 545 if err := v.Validate(); err != nil { 546 return PrincipalValidationError{ 547 field: "Header", 548 reason: "embedded message failed validation", 549 cause: err, 550 } 551 } 552 } 553 554 case *Principal_UrlPath: 555 556 if v, ok := interface{}(m.GetUrlPath()).(interface{ Validate() error }); ok { 557 if err := v.Validate(); err != nil { 558 return PrincipalValidationError{ 559 field: "UrlPath", 560 reason: "embedded message failed validation", 561 cause: err, 562 } 563 } 564 } 565 566 case *Principal_Metadata: 567 568 if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok { 569 if err := v.Validate(); err != nil { 570 return PrincipalValidationError{ 571 field: "Metadata", 572 reason: "embedded message failed validation", 573 cause: err, 574 } 575 } 576 } 577 578 case *Principal_NotId: 579 580 if v, ok := interface{}(m.GetNotId()).(interface{ Validate() error }); ok { 581 if err := v.Validate(); err != nil { 582 return PrincipalValidationError{ 583 field: "NotId", 584 reason: "embedded message failed validation", 585 cause: err, 586 } 587 } 588 } 589 590 default: 591 return PrincipalValidationError{ 592 field: "Identifier", 593 reason: "value is required", 594 } 595 596 } 597 598 return nil 599 } 600 601 // PrincipalValidationError is the validation error returned by 602 // Principal.Validate if the designated constraints aren't met. 603 type PrincipalValidationError struct { 604 field string 605 reason string 606 cause error 607 key bool 608 } 609 610 // Field function returns field value. 611 func (e PrincipalValidationError) Field() string { return e.field } 612 613 // Reason function returns reason value. 614 func (e PrincipalValidationError) Reason() string { return e.reason } 615 616 // Cause function returns cause value. 617 func (e PrincipalValidationError) Cause() error { return e.cause } 618 619 // Key function returns key value. 620 func (e PrincipalValidationError) Key() bool { return e.key } 621 622 // ErrorName returns error name. 623 func (e PrincipalValidationError) ErrorName() string { return "PrincipalValidationError" } 624 625 // Error satisfies the builtin error interface 626 func (e PrincipalValidationError) Error() string { 627 cause := "" 628 if e.cause != nil { 629 cause = fmt.Sprintf(" | caused by: %v", e.cause) 630 } 631 632 key := "" 633 if e.key { 634 key = "key for " 635 } 636 637 return fmt.Sprintf( 638 "invalid %sPrincipal.%s: %s%s", 639 key, 640 e.field, 641 e.reason, 642 cause) 643 } 644 645 var _ error = PrincipalValidationError{} 646 647 var _ interface { 648 Field() string 649 Reason() string 650 Key() bool 651 Cause() error 652 ErrorName() string 653 } = PrincipalValidationError{} 654 655 // Validate checks the field values on Permission_Set with the rules defined in 656 // the proto definition for this message. If any rules are violated, an error 657 // is returned. 658 func (m *Permission_Set) Validate() error { 659 if m == nil { 660 return nil 661 } 662 663 if len(m.GetRules()) < 1 { 664 return Permission_SetValidationError{ 665 field: "Rules", 666 reason: "value must contain at least 1 item(s)", 667 } 668 } 669 670 for idx, item := range m.GetRules() { 671 _, _ = idx, item 672 673 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 674 if err := v.Validate(); err != nil { 675 return Permission_SetValidationError{ 676 field: fmt.Sprintf("Rules[%v]", idx), 677 reason: "embedded message failed validation", 678 cause: err, 679 } 680 } 681 } 682 683 } 684 685 return nil 686 } 687 688 // Permission_SetValidationError is the validation error returned by 689 // Permission_Set.Validate if the designated constraints aren't met. 690 type Permission_SetValidationError struct { 691 field string 692 reason string 693 cause error 694 key bool 695 } 696 697 // Field function returns field value. 698 func (e Permission_SetValidationError) Field() string { return e.field } 699 700 // Reason function returns reason value. 701 func (e Permission_SetValidationError) Reason() string { return e.reason } 702 703 // Cause function returns cause value. 704 func (e Permission_SetValidationError) Cause() error { return e.cause } 705 706 // Key function returns key value. 707 func (e Permission_SetValidationError) Key() bool { return e.key } 708 709 // ErrorName returns error name. 710 func (e Permission_SetValidationError) ErrorName() string { return "Permission_SetValidationError" } 711 712 // Error satisfies the builtin error interface 713 func (e Permission_SetValidationError) Error() string { 714 cause := "" 715 if e.cause != nil { 716 cause = fmt.Sprintf(" | caused by: %v", e.cause) 717 } 718 719 key := "" 720 if e.key { 721 key = "key for " 722 } 723 724 return fmt.Sprintf( 725 "invalid %sPermission_Set.%s: %s%s", 726 key, 727 e.field, 728 e.reason, 729 cause) 730 } 731 732 var _ error = Permission_SetValidationError{} 733 734 var _ interface { 735 Field() string 736 Reason() string 737 Key() bool 738 Cause() error 739 ErrorName() string 740 } = Permission_SetValidationError{} 741 742 // Validate checks the field values on Principal_Set with the rules defined in 743 // the proto definition for this message. If any rules are violated, an error 744 // is returned. 745 func (m *Principal_Set) Validate() error { 746 if m == nil { 747 return nil 748 } 749 750 if len(m.GetIds()) < 1 { 751 return Principal_SetValidationError{ 752 field: "Ids", 753 reason: "value must contain at least 1 item(s)", 754 } 755 } 756 757 for idx, item := range m.GetIds() { 758 _, _ = idx, item 759 760 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 761 if err := v.Validate(); err != nil { 762 return Principal_SetValidationError{ 763 field: fmt.Sprintf("Ids[%v]", idx), 764 reason: "embedded message failed validation", 765 cause: err, 766 } 767 } 768 } 769 770 } 771 772 return nil 773 } 774 775 // Principal_SetValidationError is the validation error returned by 776 // Principal_Set.Validate if the designated constraints aren't met. 777 type Principal_SetValidationError struct { 778 field string 779 reason string 780 cause error 781 key bool 782 } 783 784 // Field function returns field value. 785 func (e Principal_SetValidationError) Field() string { return e.field } 786 787 // Reason function returns reason value. 788 func (e Principal_SetValidationError) Reason() string { return e.reason } 789 790 // Cause function returns cause value. 791 func (e Principal_SetValidationError) Cause() error { return e.cause } 792 793 // Key function returns key value. 794 func (e Principal_SetValidationError) Key() bool { return e.key } 795 796 // ErrorName returns error name. 797 func (e Principal_SetValidationError) ErrorName() string { return "Principal_SetValidationError" } 798 799 // Error satisfies the builtin error interface 800 func (e Principal_SetValidationError) Error() string { 801 cause := "" 802 if e.cause != nil { 803 cause = fmt.Sprintf(" | caused by: %v", e.cause) 804 } 805 806 key := "" 807 if e.key { 808 key = "key for " 809 } 810 811 return fmt.Sprintf( 812 "invalid %sPrincipal_Set.%s: %s%s", 813 key, 814 e.field, 815 e.reason, 816 cause) 817 } 818 819 var _ error = Principal_SetValidationError{} 820 821 var _ interface { 822 Field() string 823 Reason() string 824 Key() bool 825 Cause() error 826 ErrorName() string 827 } = Principal_SetValidationError{} 828 829 // Validate checks the field values on Principal_Authenticated with the rules 830 // defined in the proto definition for this message. If any rules are 831 // violated, an error is returned. 832 func (m *Principal_Authenticated) Validate() error { 833 if m == nil { 834 return nil 835 } 836 837 if v, ok := interface{}(m.GetPrincipalName()).(interface{ Validate() error }); ok { 838 if err := v.Validate(); err != nil { 839 return Principal_AuthenticatedValidationError{ 840 field: "PrincipalName", 841 reason: "embedded message failed validation", 842 cause: err, 843 } 844 } 845 } 846 847 return nil 848 } 849 850 // Principal_AuthenticatedValidationError is the validation error returned by 851 // Principal_Authenticated.Validate if the designated constraints aren't met. 852 type Principal_AuthenticatedValidationError struct { 853 field string 854 reason string 855 cause error 856 key bool 857 } 858 859 // Field function returns field value. 860 func (e Principal_AuthenticatedValidationError) Field() string { return e.field } 861 862 // Reason function returns reason value. 863 func (e Principal_AuthenticatedValidationError) Reason() string { return e.reason } 864 865 // Cause function returns cause value. 866 func (e Principal_AuthenticatedValidationError) Cause() error { return e.cause } 867 868 // Key function returns key value. 869 func (e Principal_AuthenticatedValidationError) Key() bool { return e.key } 870 871 // ErrorName returns error name. 872 func (e Principal_AuthenticatedValidationError) ErrorName() string { 873 return "Principal_AuthenticatedValidationError" 874 } 875 876 // Error satisfies the builtin error interface 877 func (e Principal_AuthenticatedValidationError) Error() string { 878 cause := "" 879 if e.cause != nil { 880 cause = fmt.Sprintf(" | caused by: %v", e.cause) 881 } 882 883 key := "" 884 if e.key { 885 key = "key for " 886 } 887 888 return fmt.Sprintf( 889 "invalid %sPrincipal_Authenticated.%s: %s%s", 890 key, 891 e.field, 892 e.reason, 893 cause) 894 } 895 896 var _ error = Principal_AuthenticatedValidationError{} 897 898 var _ interface { 899 Field() string 900 Reason() string 901 Key() bool 902 Cause() error 903 ErrorName() string 904 } = Principal_AuthenticatedValidationError{}