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

https://github.com/datawire/ambassador · Go · 486 lines · 350 code · 87 blank · 49 comment · 63 complexity · 1861572f67c68203a377e0623ca10969 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/network/tcp_proxy/v4alpha/tcp_proxy.proto
  3. package envoy_extensions_filters_network_tcp_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 _tcp_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 TcpProxy with the rules defined in the
  34. // proto definition for this message. If any rules are violated, an error is returned.
  35. func (m *TcpProxy) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if len(m.GetStatPrefix()) < 1 {
  40. return TcpProxyValidationError{
  41. field: "StatPrefix",
  42. reason: "value length must be at least 1 bytes",
  43. }
  44. }
  45. if v, ok := interface{}(m.GetMetadataMatch()).(interface{ Validate() error }); ok {
  46. if err := v.Validate(); err != nil {
  47. return TcpProxyValidationError{
  48. field: "MetadataMatch",
  49. reason: "embedded message failed validation",
  50. cause: err,
  51. }
  52. }
  53. }
  54. if v, ok := interface{}(m.GetIdleTimeout()).(interface{ Validate() error }); ok {
  55. if err := v.Validate(); err != nil {
  56. return TcpProxyValidationError{
  57. field: "IdleTimeout",
  58. reason: "embedded message failed validation",
  59. cause: err,
  60. }
  61. }
  62. }
  63. if v, ok := interface{}(m.GetDownstreamIdleTimeout()).(interface{ Validate() error }); ok {
  64. if err := v.Validate(); err != nil {
  65. return TcpProxyValidationError{
  66. field: "DownstreamIdleTimeout",
  67. reason: "embedded message failed validation",
  68. cause: err,
  69. }
  70. }
  71. }
  72. if v, ok := interface{}(m.GetUpstreamIdleTimeout()).(interface{ Validate() error }); ok {
  73. if err := v.Validate(); err != nil {
  74. return TcpProxyValidationError{
  75. field: "UpstreamIdleTimeout",
  76. reason: "embedded message failed validation",
  77. cause: err,
  78. }
  79. }
  80. }
  81. for idx, item := range m.GetAccessLog() {
  82. _, _ = idx, item
  83. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  84. if err := v.Validate(); err != nil {
  85. return TcpProxyValidationError{
  86. field: fmt.Sprintf("AccessLog[%v]", idx),
  87. reason: "embedded message failed validation",
  88. cause: err,
  89. }
  90. }
  91. }
  92. }
  93. if wrapper := m.GetMaxConnectAttempts(); wrapper != nil {
  94. if wrapper.GetValue() < 1 {
  95. return TcpProxyValidationError{
  96. field: "MaxConnectAttempts",
  97. reason: "value must be greater than or equal to 1",
  98. }
  99. }
  100. }
  101. if len(m.GetHashPolicy()) > 1 {
  102. return TcpProxyValidationError{
  103. field: "HashPolicy",
  104. reason: "value must contain no more than 1 item(s)",
  105. }
  106. }
  107. for idx, item := range m.GetHashPolicy() {
  108. _, _ = idx, item
  109. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  110. if err := v.Validate(); err != nil {
  111. return TcpProxyValidationError{
  112. field: fmt.Sprintf("HashPolicy[%v]", idx),
  113. reason: "embedded message failed validation",
  114. cause: err,
  115. }
  116. }
  117. }
  118. }
  119. if v, ok := interface{}(m.GetTunnelingConfig()).(interface{ Validate() error }); ok {
  120. if err := v.Validate(); err != nil {
  121. return TcpProxyValidationError{
  122. field: "TunnelingConfig",
  123. reason: "embedded message failed validation",
  124. cause: err,
  125. }
  126. }
  127. }
  128. switch m.ClusterSpecifier.(type) {
  129. case *TcpProxy_Cluster:
  130. // no validation rules for Cluster
  131. case *TcpProxy_WeightedClusters:
  132. if v, ok := interface{}(m.GetWeightedClusters()).(interface{ Validate() error }); ok {
  133. if err := v.Validate(); err != nil {
  134. return TcpProxyValidationError{
  135. field: "WeightedClusters",
  136. reason: "embedded message failed validation",
  137. cause: err,
  138. }
  139. }
  140. }
  141. default:
  142. return TcpProxyValidationError{
  143. field: "ClusterSpecifier",
  144. reason: "value is required",
  145. }
  146. }
  147. return nil
  148. }
  149. // TcpProxyValidationError is the validation error returned by
  150. // TcpProxy.Validate if the designated constraints aren't met.
  151. type TcpProxyValidationError struct {
  152. field string
  153. reason string
  154. cause error
  155. key bool
  156. }
  157. // Field function returns field value.
  158. func (e TcpProxyValidationError) Field() string { return e.field }
  159. // Reason function returns reason value.
  160. func (e TcpProxyValidationError) Reason() string { return e.reason }
  161. // Cause function returns cause value.
  162. func (e TcpProxyValidationError) Cause() error { return e.cause }
  163. // Key function returns key value.
  164. func (e TcpProxyValidationError) Key() bool { return e.key }
  165. // ErrorName returns error name.
  166. func (e TcpProxyValidationError) ErrorName() string { return "TcpProxyValidationError" }
  167. // Error satisfies the builtin error interface
  168. func (e TcpProxyValidationError) Error() string {
  169. cause := ""
  170. if e.cause != nil {
  171. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  172. }
  173. key := ""
  174. if e.key {
  175. key = "key for "
  176. }
  177. return fmt.Sprintf(
  178. "invalid %sTcpProxy.%s: %s%s",
  179. key,
  180. e.field,
  181. e.reason,
  182. cause)
  183. }
  184. var _ error = TcpProxyValidationError{}
  185. var _ interface {
  186. Field() string
  187. Reason() string
  188. Key() bool
  189. Cause() error
  190. ErrorName() string
  191. } = TcpProxyValidationError{}
  192. // Validate checks the field values on TcpProxy_WeightedCluster with the rules
  193. // defined in the proto definition for this message. If any rules are
  194. // violated, an error is returned.
  195. func (m *TcpProxy_WeightedCluster) Validate() error {
  196. if m == nil {
  197. return nil
  198. }
  199. if len(m.GetClusters()) < 1 {
  200. return TcpProxy_WeightedClusterValidationError{
  201. field: "Clusters",
  202. reason: "value must contain at least 1 item(s)",
  203. }
  204. }
  205. for idx, item := range m.GetClusters() {
  206. _, _ = idx, item
  207. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  208. if err := v.Validate(); err != nil {
  209. return TcpProxy_WeightedClusterValidationError{
  210. field: fmt.Sprintf("Clusters[%v]", idx),
  211. reason: "embedded message failed validation",
  212. cause: err,
  213. }
  214. }
  215. }
  216. }
  217. return nil
  218. }
  219. // TcpProxy_WeightedClusterValidationError is the validation error returned by
  220. // TcpProxy_WeightedCluster.Validate if the designated constraints aren't met.
  221. type TcpProxy_WeightedClusterValidationError struct {
  222. field string
  223. reason string
  224. cause error
  225. key bool
  226. }
  227. // Field function returns field value.
  228. func (e TcpProxy_WeightedClusterValidationError) Field() string { return e.field }
  229. // Reason function returns reason value.
  230. func (e TcpProxy_WeightedClusterValidationError) Reason() string { return e.reason }
  231. // Cause function returns cause value.
  232. func (e TcpProxy_WeightedClusterValidationError) Cause() error { return e.cause }
  233. // Key function returns key value.
  234. func (e TcpProxy_WeightedClusterValidationError) Key() bool { return e.key }
  235. // ErrorName returns error name.
  236. func (e TcpProxy_WeightedClusterValidationError) ErrorName() string {
  237. return "TcpProxy_WeightedClusterValidationError"
  238. }
  239. // Error satisfies the builtin error interface
  240. func (e TcpProxy_WeightedClusterValidationError) Error() string {
  241. cause := ""
  242. if e.cause != nil {
  243. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  244. }
  245. key := ""
  246. if e.key {
  247. key = "key for "
  248. }
  249. return fmt.Sprintf(
  250. "invalid %sTcpProxy_WeightedCluster.%s: %s%s",
  251. key,
  252. e.field,
  253. e.reason,
  254. cause)
  255. }
  256. var _ error = TcpProxy_WeightedClusterValidationError{}
  257. var _ interface {
  258. Field() string
  259. Reason() string
  260. Key() bool
  261. Cause() error
  262. ErrorName() string
  263. } = TcpProxy_WeightedClusterValidationError{}
  264. // Validate checks the field values on TcpProxy_TunnelingConfig with the rules
  265. // defined in the proto definition for this message. If any rules are
  266. // violated, an error is returned.
  267. func (m *TcpProxy_TunnelingConfig) Validate() error {
  268. if m == nil {
  269. return nil
  270. }
  271. if len(m.GetHostname()) < 1 {
  272. return TcpProxy_TunnelingConfigValidationError{
  273. field: "Hostname",
  274. reason: "value length must be at least 1 bytes",
  275. }
  276. }
  277. return nil
  278. }
  279. // TcpProxy_TunnelingConfigValidationError is the validation error returned by
  280. // TcpProxy_TunnelingConfig.Validate if the designated constraints aren't met.
  281. type TcpProxy_TunnelingConfigValidationError struct {
  282. field string
  283. reason string
  284. cause error
  285. key bool
  286. }
  287. // Field function returns field value.
  288. func (e TcpProxy_TunnelingConfigValidationError) Field() string { return e.field }
  289. // Reason function returns reason value.
  290. func (e TcpProxy_TunnelingConfigValidationError) Reason() string { return e.reason }
  291. // Cause function returns cause value.
  292. func (e TcpProxy_TunnelingConfigValidationError) Cause() error { return e.cause }
  293. // Key function returns key value.
  294. func (e TcpProxy_TunnelingConfigValidationError) Key() bool { return e.key }
  295. // ErrorName returns error name.
  296. func (e TcpProxy_TunnelingConfigValidationError) ErrorName() string {
  297. return "TcpProxy_TunnelingConfigValidationError"
  298. }
  299. // Error satisfies the builtin error interface
  300. func (e TcpProxy_TunnelingConfigValidationError) Error() string {
  301. cause := ""
  302. if e.cause != nil {
  303. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  304. }
  305. key := ""
  306. if e.key {
  307. key = "key for "
  308. }
  309. return fmt.Sprintf(
  310. "invalid %sTcpProxy_TunnelingConfig.%s: %s%s",
  311. key,
  312. e.field,
  313. e.reason,
  314. cause)
  315. }
  316. var _ error = TcpProxy_TunnelingConfigValidationError{}
  317. var _ interface {
  318. Field() string
  319. Reason() string
  320. Key() bool
  321. Cause() error
  322. ErrorName() string
  323. } = TcpProxy_TunnelingConfigValidationError{}
  324. // Validate checks the field values on TcpProxy_WeightedCluster_ClusterWeight
  325. // with the rules defined in the proto definition for this message. If any
  326. // rules are violated, an error is returned.
  327. func (m *TcpProxy_WeightedCluster_ClusterWeight) Validate() error {
  328. if m == nil {
  329. return nil
  330. }
  331. if len(m.GetName()) < 1 {
  332. return TcpProxy_WeightedCluster_ClusterWeightValidationError{
  333. field: "Name",
  334. reason: "value length must be at least 1 bytes",
  335. }
  336. }
  337. if m.GetWeight() < 1 {
  338. return TcpProxy_WeightedCluster_ClusterWeightValidationError{
  339. field: "Weight",
  340. reason: "value must be greater than or equal to 1",
  341. }
  342. }
  343. if v, ok := interface{}(m.GetMetadataMatch()).(interface{ Validate() error }); ok {
  344. if err := v.Validate(); err != nil {
  345. return TcpProxy_WeightedCluster_ClusterWeightValidationError{
  346. field: "MetadataMatch",
  347. reason: "embedded message failed validation",
  348. cause: err,
  349. }
  350. }
  351. }
  352. return nil
  353. }
  354. // TcpProxy_WeightedCluster_ClusterWeightValidationError is the validation
  355. // error returned by TcpProxy_WeightedCluster_ClusterWeight.Validate if the
  356. // designated constraints aren't met.
  357. type TcpProxy_WeightedCluster_ClusterWeightValidationError struct {
  358. field string
  359. reason string
  360. cause error
  361. key bool
  362. }
  363. // Field function returns field value.
  364. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Field() string { return e.field }
  365. // Reason function returns reason value.
  366. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Reason() string { return e.reason }
  367. // Cause function returns cause value.
  368. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Cause() error { return e.cause }
  369. // Key function returns key value.
  370. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Key() bool { return e.key }
  371. // ErrorName returns error name.
  372. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) ErrorName() string {
  373. return "TcpProxy_WeightedCluster_ClusterWeightValidationError"
  374. }
  375. // Error satisfies the builtin error interface
  376. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Error() string {
  377. cause := ""
  378. if e.cause != nil {
  379. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  380. }
  381. key := ""
  382. if e.key {
  383. key = "key for "
  384. }
  385. return fmt.Sprintf(
  386. "invalid %sTcpProxy_WeightedCluster_ClusterWeight.%s: %s%s",
  387. key,
  388. e.field,
  389. e.reason,
  390. cause)
  391. }
  392. var _ error = TcpProxy_WeightedCluster_ClusterWeightValidationError{}
  393. var _ interface {
  394. Field() string
  395. Reason() string
  396. Key() bool
  397. Cause() error
  398. ErrorName() string
  399. } = TcpProxy_WeightedCluster_ClusterWeightValidationError{}