/vendor/github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3/endpoint_components.pb.validate.go

https://github.com/XiaoMi/naftis · Go · 425 lines · 296 code · 81 blank · 48 comment · 51 complexity · bcddac1c83f752fe61454cb4a50c2023 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/endpoint/v3/endpoint_components.proto
  3. package envoy_config_endpoint_v3
  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. v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
  17. )
  18. // ensure the imports are used
  19. var (
  20. _ = bytes.MinRead
  21. _ = errors.New("")
  22. _ = fmt.Print
  23. _ = utf8.UTFMax
  24. _ = (*regexp.Regexp)(nil)
  25. _ = (*strings.Reader)(nil)
  26. _ = net.IPv4len
  27. _ = time.Duration(0)
  28. _ = (*url.URL)(nil)
  29. _ = (*mail.Address)(nil)
  30. _ = ptypes.DynamicAny{}
  31. _ = v3.HealthStatus(0)
  32. )
  33. // define the regex for a UUID once up-front
  34. var _endpoint_components_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}$")
  35. // Validate checks the field values on Endpoint with the rules defined in the
  36. // proto definition for this message. If any rules are violated, an error is returned.
  37. func (m *Endpoint) Validate() error {
  38. if m == nil {
  39. return nil
  40. }
  41. if v, ok := interface{}(m.GetAddress()).(interface{ Validate() error }); ok {
  42. if err := v.Validate(); err != nil {
  43. return EndpointValidationError{
  44. field: "Address",
  45. reason: "embedded message failed validation",
  46. cause: err,
  47. }
  48. }
  49. }
  50. if v, ok := interface{}(m.GetHealthCheckConfig()).(interface{ Validate() error }); ok {
  51. if err := v.Validate(); err != nil {
  52. return EndpointValidationError{
  53. field: "HealthCheckConfig",
  54. reason: "embedded message failed validation",
  55. cause: err,
  56. }
  57. }
  58. }
  59. return nil
  60. }
  61. // EndpointValidationError is the validation error returned by
  62. // Endpoint.Validate if the designated constraints aren't met.
  63. type EndpointValidationError struct {
  64. field string
  65. reason string
  66. cause error
  67. key bool
  68. }
  69. // Field function returns field value.
  70. func (e EndpointValidationError) Field() string { return e.field }
  71. // Reason function returns reason value.
  72. func (e EndpointValidationError) Reason() string { return e.reason }
  73. // Cause function returns cause value.
  74. func (e EndpointValidationError) Cause() error { return e.cause }
  75. // Key function returns key value.
  76. func (e EndpointValidationError) Key() bool { return e.key }
  77. // ErrorName returns error name.
  78. func (e EndpointValidationError) ErrorName() string { return "EndpointValidationError" }
  79. // Error satisfies the builtin error interface
  80. func (e EndpointValidationError) Error() string {
  81. cause := ""
  82. if e.cause != nil {
  83. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  84. }
  85. key := ""
  86. if e.key {
  87. key = "key for "
  88. }
  89. return fmt.Sprintf(
  90. "invalid %sEndpoint.%s: %s%s",
  91. key,
  92. e.field,
  93. e.reason,
  94. cause)
  95. }
  96. var _ error = EndpointValidationError{}
  97. var _ interface {
  98. Field() string
  99. Reason() string
  100. Key() bool
  101. Cause() error
  102. ErrorName() string
  103. } = EndpointValidationError{}
  104. // Validate checks the field values on LbEndpoint with the rules defined in the
  105. // proto definition for this message. If any rules are violated, an error is returned.
  106. func (m *LbEndpoint) Validate() error {
  107. if m == nil {
  108. return nil
  109. }
  110. // no validation rules for HealthStatus
  111. if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
  112. if err := v.Validate(); err != nil {
  113. return LbEndpointValidationError{
  114. field: "Metadata",
  115. reason: "embedded message failed validation",
  116. cause: err,
  117. }
  118. }
  119. }
  120. if wrapper := m.GetLoadBalancingWeight(); wrapper != nil {
  121. if wrapper.GetValue() < 1 {
  122. return LbEndpointValidationError{
  123. field: "LoadBalancingWeight",
  124. reason: "value must be greater than or equal to 1",
  125. }
  126. }
  127. }
  128. switch m.HostIdentifier.(type) {
  129. case *LbEndpoint_Endpoint:
  130. if v, ok := interface{}(m.GetEndpoint()).(interface{ Validate() error }); ok {
  131. if err := v.Validate(); err != nil {
  132. return LbEndpointValidationError{
  133. field: "Endpoint",
  134. reason: "embedded message failed validation",
  135. cause: err,
  136. }
  137. }
  138. }
  139. case *LbEndpoint_EndpointName:
  140. // no validation rules for EndpointName
  141. }
  142. return nil
  143. }
  144. // LbEndpointValidationError is the validation error returned by
  145. // LbEndpoint.Validate if the designated constraints aren't met.
  146. type LbEndpointValidationError struct {
  147. field string
  148. reason string
  149. cause error
  150. key bool
  151. }
  152. // Field function returns field value.
  153. func (e LbEndpointValidationError) Field() string { return e.field }
  154. // Reason function returns reason value.
  155. func (e LbEndpointValidationError) Reason() string { return e.reason }
  156. // Cause function returns cause value.
  157. func (e LbEndpointValidationError) Cause() error { return e.cause }
  158. // Key function returns key value.
  159. func (e LbEndpointValidationError) Key() bool { return e.key }
  160. // ErrorName returns error name.
  161. func (e LbEndpointValidationError) ErrorName() string { return "LbEndpointValidationError" }
  162. // Error satisfies the builtin error interface
  163. func (e LbEndpointValidationError) Error() string {
  164. cause := ""
  165. if e.cause != nil {
  166. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  167. }
  168. key := ""
  169. if e.key {
  170. key = "key for "
  171. }
  172. return fmt.Sprintf(
  173. "invalid %sLbEndpoint.%s: %s%s",
  174. key,
  175. e.field,
  176. e.reason,
  177. cause)
  178. }
  179. var _ error = LbEndpointValidationError{}
  180. var _ interface {
  181. Field() string
  182. Reason() string
  183. Key() bool
  184. Cause() error
  185. ErrorName() string
  186. } = LbEndpointValidationError{}
  187. // Validate checks the field values on LocalityLbEndpoints with the rules
  188. // defined in the proto definition for this message. If any rules are
  189. // violated, an error is returned.
  190. func (m *LocalityLbEndpoints) Validate() error {
  191. if m == nil {
  192. return nil
  193. }
  194. if v, ok := interface{}(m.GetLocality()).(interface{ Validate() error }); ok {
  195. if err := v.Validate(); err != nil {
  196. return LocalityLbEndpointsValidationError{
  197. field: "Locality",
  198. reason: "embedded message failed validation",
  199. cause: err,
  200. }
  201. }
  202. }
  203. for idx, item := range m.GetLbEndpoints() {
  204. _, _ = idx, item
  205. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  206. if err := v.Validate(); err != nil {
  207. return LocalityLbEndpointsValidationError{
  208. field: fmt.Sprintf("LbEndpoints[%v]", idx),
  209. reason: "embedded message failed validation",
  210. cause: err,
  211. }
  212. }
  213. }
  214. }
  215. if wrapper := m.GetLoadBalancingWeight(); wrapper != nil {
  216. if wrapper.GetValue() < 1 {
  217. return LocalityLbEndpointsValidationError{
  218. field: "LoadBalancingWeight",
  219. reason: "value must be greater than or equal to 1",
  220. }
  221. }
  222. }
  223. if m.GetPriority() > 128 {
  224. return LocalityLbEndpointsValidationError{
  225. field: "Priority",
  226. reason: "value must be less than or equal to 128",
  227. }
  228. }
  229. if v, ok := interface{}(m.GetProximity()).(interface{ Validate() error }); ok {
  230. if err := v.Validate(); err != nil {
  231. return LocalityLbEndpointsValidationError{
  232. field: "Proximity",
  233. reason: "embedded message failed validation",
  234. cause: err,
  235. }
  236. }
  237. }
  238. return nil
  239. }
  240. // LocalityLbEndpointsValidationError is the validation error returned by
  241. // LocalityLbEndpoints.Validate if the designated constraints aren't met.
  242. type LocalityLbEndpointsValidationError struct {
  243. field string
  244. reason string
  245. cause error
  246. key bool
  247. }
  248. // Field function returns field value.
  249. func (e LocalityLbEndpointsValidationError) Field() string { return e.field }
  250. // Reason function returns reason value.
  251. func (e LocalityLbEndpointsValidationError) Reason() string { return e.reason }
  252. // Cause function returns cause value.
  253. func (e LocalityLbEndpointsValidationError) Cause() error { return e.cause }
  254. // Key function returns key value.
  255. func (e LocalityLbEndpointsValidationError) Key() bool { return e.key }
  256. // ErrorName returns error name.
  257. func (e LocalityLbEndpointsValidationError) ErrorName() string {
  258. return "LocalityLbEndpointsValidationError"
  259. }
  260. // Error satisfies the builtin error interface
  261. func (e LocalityLbEndpointsValidationError) Error() string {
  262. cause := ""
  263. if e.cause != nil {
  264. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  265. }
  266. key := ""
  267. if e.key {
  268. key = "key for "
  269. }
  270. return fmt.Sprintf(
  271. "invalid %sLocalityLbEndpoints.%s: %s%s",
  272. key,
  273. e.field,
  274. e.reason,
  275. cause)
  276. }
  277. var _ error = LocalityLbEndpointsValidationError{}
  278. var _ interface {
  279. Field() string
  280. Reason() string
  281. Key() bool
  282. Cause() error
  283. ErrorName() string
  284. } = LocalityLbEndpointsValidationError{}
  285. // Validate checks the field values on Endpoint_HealthCheckConfig with the
  286. // rules defined in the proto definition for this message. If any rules are
  287. // violated, an error is returned.
  288. func (m *Endpoint_HealthCheckConfig) Validate() error {
  289. if m == nil {
  290. return nil
  291. }
  292. if m.GetPortValue() > 65535 {
  293. return Endpoint_HealthCheckConfigValidationError{
  294. field: "PortValue",
  295. reason: "value must be less than or equal to 65535",
  296. }
  297. }
  298. return nil
  299. }
  300. // Endpoint_HealthCheckConfigValidationError is the validation error returned
  301. // by Endpoint_HealthCheckConfig.Validate if the designated constraints aren't met.
  302. type Endpoint_HealthCheckConfigValidationError struct {
  303. field string
  304. reason string
  305. cause error
  306. key bool
  307. }
  308. // Field function returns field value.
  309. func (e Endpoint_HealthCheckConfigValidationError) Field() string { return e.field }
  310. // Reason function returns reason value.
  311. func (e Endpoint_HealthCheckConfigValidationError) Reason() string { return e.reason }
  312. // Cause function returns cause value.
  313. func (e Endpoint_HealthCheckConfigValidationError) Cause() error { return e.cause }
  314. // Key function returns key value.
  315. func (e Endpoint_HealthCheckConfigValidationError) Key() bool { return e.key }
  316. // ErrorName returns error name.
  317. func (e Endpoint_HealthCheckConfigValidationError) ErrorName() string {
  318. return "Endpoint_HealthCheckConfigValidationError"
  319. }
  320. // Error satisfies the builtin error interface
  321. func (e Endpoint_HealthCheckConfigValidationError) Error() string {
  322. cause := ""
  323. if e.cause != nil {
  324. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  325. }
  326. key := ""
  327. if e.key {
  328. key = "key for "
  329. }
  330. return fmt.Sprintf(
  331. "invalid %sEndpoint_HealthCheckConfig.%s: %s%s",
  332. key,
  333. e.field,
  334. e.reason,
  335. cause)
  336. }
  337. var _ error = Endpoint_HealthCheckConfigValidationError{}
  338. var _ interface {
  339. Field() string
  340. Reason() string
  341. Key() bool
  342. Cause() error
  343. ErrorName() string
  344. } = Endpoint_HealthCheckConfigValidationError{}