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

https://github.com/datawire/ambassador · Go · 317 lines · 222 code · 58 blank · 37 comment · 32 complexity · ff8387b9a208ce57692fe2e709e30998 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/network/thrift_proxy/v4alpha/thrift_proxy.proto
  3. package envoy_extensions_filters_network_thrift_proxy_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 _thrift_proxy_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 ThriftProxy with the rules defined in
  34. // the proto definition for this message. If any rules are violated, an error
  35. // is returned.
  36. func (m *ThriftProxy) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if _, ok := TransportType_name[int32(m.GetTransport())]; !ok {
  41. return ThriftProxyValidationError{
  42. field: "Transport",
  43. reason: "value must be one of the defined enum values",
  44. }
  45. }
  46. if _, ok := ProtocolType_name[int32(m.GetProtocol())]; !ok {
  47. return ThriftProxyValidationError{
  48. field: "Protocol",
  49. reason: "value must be one of the defined enum values",
  50. }
  51. }
  52. if len(m.GetStatPrefix()) < 1 {
  53. return ThriftProxyValidationError{
  54. field: "StatPrefix",
  55. reason: "value length must be at least 1 bytes",
  56. }
  57. }
  58. if v, ok := interface{}(m.GetRouteConfig()).(interface{ Validate() error }); ok {
  59. if err := v.Validate(); err != nil {
  60. return ThriftProxyValidationError{
  61. field: "RouteConfig",
  62. reason: "embedded message failed validation",
  63. cause: err,
  64. }
  65. }
  66. }
  67. for idx, item := range m.GetThriftFilters() {
  68. _, _ = idx, item
  69. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  70. if err := v.Validate(); err != nil {
  71. return ThriftProxyValidationError{
  72. field: fmt.Sprintf("ThriftFilters[%v]", idx),
  73. reason: "embedded message failed validation",
  74. cause: err,
  75. }
  76. }
  77. }
  78. }
  79. return nil
  80. }
  81. // ThriftProxyValidationError is the validation error returned by
  82. // ThriftProxy.Validate if the designated constraints aren't met.
  83. type ThriftProxyValidationError struct {
  84. field string
  85. reason string
  86. cause error
  87. key bool
  88. }
  89. // Field function returns field value.
  90. func (e ThriftProxyValidationError) Field() string { return e.field }
  91. // Reason function returns reason value.
  92. func (e ThriftProxyValidationError) Reason() string { return e.reason }
  93. // Cause function returns cause value.
  94. func (e ThriftProxyValidationError) Cause() error { return e.cause }
  95. // Key function returns key value.
  96. func (e ThriftProxyValidationError) Key() bool { return e.key }
  97. // ErrorName returns error name.
  98. func (e ThriftProxyValidationError) ErrorName() string { return "ThriftProxyValidationError" }
  99. // Error satisfies the builtin error interface
  100. func (e ThriftProxyValidationError) Error() string {
  101. cause := ""
  102. if e.cause != nil {
  103. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  104. }
  105. key := ""
  106. if e.key {
  107. key = "key for "
  108. }
  109. return fmt.Sprintf(
  110. "invalid %sThriftProxy.%s: %s%s",
  111. key,
  112. e.field,
  113. e.reason,
  114. cause)
  115. }
  116. var _ error = ThriftProxyValidationError{}
  117. var _ interface {
  118. Field() string
  119. Reason() string
  120. Key() bool
  121. Cause() error
  122. ErrorName() string
  123. } = ThriftProxyValidationError{}
  124. // Validate checks the field values on ThriftFilter with the rules defined in
  125. // the proto definition for this message. If any rules are violated, an error
  126. // is returned.
  127. func (m *ThriftFilter) Validate() error {
  128. if m == nil {
  129. return nil
  130. }
  131. if len(m.GetName()) < 1 {
  132. return ThriftFilterValidationError{
  133. field: "Name",
  134. reason: "value length must be at least 1 bytes",
  135. }
  136. }
  137. switch m.ConfigType.(type) {
  138. case *ThriftFilter_TypedConfig:
  139. if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
  140. if err := v.Validate(); err != nil {
  141. return ThriftFilterValidationError{
  142. field: "TypedConfig",
  143. reason: "embedded message failed validation",
  144. cause: err,
  145. }
  146. }
  147. }
  148. }
  149. return nil
  150. }
  151. // ThriftFilterValidationError is the validation error returned by
  152. // ThriftFilter.Validate if the designated constraints aren't met.
  153. type ThriftFilterValidationError struct {
  154. field string
  155. reason string
  156. cause error
  157. key bool
  158. }
  159. // Field function returns field value.
  160. func (e ThriftFilterValidationError) Field() string { return e.field }
  161. // Reason function returns reason value.
  162. func (e ThriftFilterValidationError) Reason() string { return e.reason }
  163. // Cause function returns cause value.
  164. func (e ThriftFilterValidationError) Cause() error { return e.cause }
  165. // Key function returns key value.
  166. func (e ThriftFilterValidationError) Key() bool { return e.key }
  167. // ErrorName returns error name.
  168. func (e ThriftFilterValidationError) ErrorName() string { return "ThriftFilterValidationError" }
  169. // Error satisfies the builtin error interface
  170. func (e ThriftFilterValidationError) Error() string {
  171. cause := ""
  172. if e.cause != nil {
  173. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  174. }
  175. key := ""
  176. if e.key {
  177. key = "key for "
  178. }
  179. return fmt.Sprintf(
  180. "invalid %sThriftFilter.%s: %s%s",
  181. key,
  182. e.field,
  183. e.reason,
  184. cause)
  185. }
  186. var _ error = ThriftFilterValidationError{}
  187. var _ interface {
  188. Field() string
  189. Reason() string
  190. Key() bool
  191. Cause() error
  192. ErrorName() string
  193. } = ThriftFilterValidationError{}
  194. // Validate checks the field values on ThriftProtocolOptions with the rules
  195. // defined in the proto definition for this message. If any rules are
  196. // violated, an error is returned.
  197. func (m *ThriftProtocolOptions) Validate() error {
  198. if m == nil {
  199. return nil
  200. }
  201. if _, ok := TransportType_name[int32(m.GetTransport())]; !ok {
  202. return ThriftProtocolOptionsValidationError{
  203. field: "Transport",
  204. reason: "value must be one of the defined enum values",
  205. }
  206. }
  207. if _, ok := ProtocolType_name[int32(m.GetProtocol())]; !ok {
  208. return ThriftProtocolOptionsValidationError{
  209. field: "Protocol",
  210. reason: "value must be one of the defined enum values",
  211. }
  212. }
  213. return nil
  214. }
  215. // ThriftProtocolOptionsValidationError is the validation error returned by
  216. // ThriftProtocolOptions.Validate if the designated constraints aren't met.
  217. type ThriftProtocolOptionsValidationError struct {
  218. field string
  219. reason string
  220. cause error
  221. key bool
  222. }
  223. // Field function returns field value.
  224. func (e ThriftProtocolOptionsValidationError) Field() string { return e.field }
  225. // Reason function returns reason value.
  226. func (e ThriftProtocolOptionsValidationError) Reason() string { return e.reason }
  227. // Cause function returns cause value.
  228. func (e ThriftProtocolOptionsValidationError) Cause() error { return e.cause }
  229. // Key function returns key value.
  230. func (e ThriftProtocolOptionsValidationError) Key() bool { return e.key }
  231. // ErrorName returns error name.
  232. func (e ThriftProtocolOptionsValidationError) ErrorName() string {
  233. return "ThriftProtocolOptionsValidationError"
  234. }
  235. // Error satisfies the builtin error interface
  236. func (e ThriftProtocolOptionsValidationError) Error() string {
  237. cause := ""
  238. if e.cause != nil {
  239. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  240. }
  241. key := ""
  242. if e.key {
  243. key = "key for "
  244. }
  245. return fmt.Sprintf(
  246. "invalid %sThriftProtocolOptions.%s: %s%s",
  247. key,
  248. e.field,
  249. e.reason,
  250. cause)
  251. }
  252. var _ error = ThriftProtocolOptionsValidationError{}
  253. var _ interface {
  254. Field() string
  255. Reason() string
  256. Key() bool
  257. Cause() error
  258. ErrorName() string
  259. } = ThriftProtocolOptionsValidationError{}