/pkg/api/envoy/extensions/filters/network/rbac/v4alpha/rbac.pb.validate.go

https://github.com/datawire/ambassador · Go · 130 lines · 93 code · 22 blank · 15 comment · 12 complexity · 4f12abcb5861bea54dda81ab1389153e MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/network/rbac/v4alpha/rbac.proto
  3. package envoy_extensions_filters_network_rbac_v4alpha
  4. import (
  5. "bytes"
  6. "errors"
  7. "fmt"
  8. "net"
  9. "net/mail"
  10. "net/url"
  11. "regexp"
  12. "strings"
  13. "time"
  14. "unicode/utf8"
  15. "github.com/golang/protobuf/ptypes"
  16. )
  17. // ensure the imports are used
  18. var (
  19. _ = bytes.MinRead
  20. _ = errors.New("")
  21. _ = fmt.Print
  22. _ = utf8.UTFMax
  23. _ = (*regexp.Regexp)(nil)
  24. _ = (*strings.Reader)(nil)
  25. _ = net.IPv4len
  26. _ = time.Duration(0)
  27. _ = (*url.URL)(nil)
  28. _ = (*mail.Address)(nil)
  29. _ = ptypes.DynamicAny{}
  30. )
  31. // define the regex for a UUID once up-front
  32. var _rbac_uuidPattern = regexp.MustCompile("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")
  33. // Validate checks the field values on RBAC with the rules defined in the proto
  34. // definition for this message. If any rules are violated, an error is returned.
  35. func (m *RBAC) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if v, ok := interface{}(m.GetRules()).(interface{ Validate() error }); ok {
  40. if err := v.Validate(); err != nil {
  41. return RBACValidationError{
  42. field: "Rules",
  43. reason: "embedded message failed validation",
  44. cause: err,
  45. }
  46. }
  47. }
  48. if v, ok := interface{}(m.GetShadowRules()).(interface{ Validate() error }); ok {
  49. if err := v.Validate(); err != nil {
  50. return RBACValidationError{
  51. field: "ShadowRules",
  52. reason: "embedded message failed validation",
  53. cause: err,
  54. }
  55. }
  56. }
  57. if len(m.GetStatPrefix()) < 1 {
  58. return RBACValidationError{
  59. field: "StatPrefix",
  60. reason: "value length must be at least 1 bytes",
  61. }
  62. }
  63. // no validation rules for EnforcementType
  64. return nil
  65. }
  66. // RBACValidationError is the validation error returned by RBAC.Validate if the
  67. // designated constraints aren't met.
  68. type RBACValidationError struct {
  69. field string
  70. reason string
  71. cause error
  72. key bool
  73. }
  74. // Field function returns field value.
  75. func (e RBACValidationError) Field() string { return e.field }
  76. // Reason function returns reason value.
  77. func (e RBACValidationError) Reason() string { return e.reason }
  78. // Cause function returns cause value.
  79. func (e RBACValidationError) Cause() error { return e.cause }
  80. // Key function returns key value.
  81. func (e RBACValidationError) Key() bool { return e.key }
  82. // ErrorName returns error name.
  83. func (e RBACValidationError) ErrorName() string { return "RBACValidationError" }
  84. // Error satisfies the builtin error interface
  85. func (e RBACValidationError) Error() string {
  86. cause := ""
  87. if e.cause != nil {
  88. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  89. }
  90. key := ""
  91. if e.key {
  92. key = "key for "
  93. }
  94. return fmt.Sprintf(
  95. "invalid %sRBAC.%s: %s%s",
  96. key,
  97. e.field,
  98. e.reason,
  99. cause)
  100. }
  101. var _ error = RBACValidationError{}
  102. var _ interface {
  103. Field() string
  104. Reason() string
  105. Key() bool
  106. Cause() error
  107. ErrorName() string
  108. } = RBACValidationError{}