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

https://github.com/datawire/ambassador · Go · 694 lines · 493 code · 127 blank · 74 comment · 90 complexity · 4e348f38e572f8ad4459006c09c7aba8 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/network/tcp_proxy/v3/tcp_proxy.proto
  3. package envoy_extensions_filters_network_tcp_proxy_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. )
  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. if v, ok := interface{}(m.GetHiddenEnvoyDeprecatedDeprecatedV1()).(interface{ Validate() error }); ok {
  129. if err := v.Validate(); err != nil {
  130. return TcpProxyValidationError{
  131. field: "HiddenEnvoyDeprecatedDeprecatedV1",
  132. reason: "embedded message failed validation",
  133. cause: err,
  134. }
  135. }
  136. }
  137. switch m.ClusterSpecifier.(type) {
  138. case *TcpProxy_Cluster:
  139. // no validation rules for Cluster
  140. case *TcpProxy_WeightedClusters:
  141. if v, ok := interface{}(m.GetWeightedClusters()).(interface{ Validate() error }); ok {
  142. if err := v.Validate(); err != nil {
  143. return TcpProxyValidationError{
  144. field: "WeightedClusters",
  145. reason: "embedded message failed validation",
  146. cause: err,
  147. }
  148. }
  149. }
  150. default:
  151. return TcpProxyValidationError{
  152. field: "ClusterSpecifier",
  153. reason: "value is required",
  154. }
  155. }
  156. return nil
  157. }
  158. // TcpProxyValidationError is the validation error returned by
  159. // TcpProxy.Validate if the designated constraints aren't met.
  160. type TcpProxyValidationError struct {
  161. field string
  162. reason string
  163. cause error
  164. key bool
  165. }
  166. // Field function returns field value.
  167. func (e TcpProxyValidationError) Field() string { return e.field }
  168. // Reason function returns reason value.
  169. func (e TcpProxyValidationError) Reason() string { return e.reason }
  170. // Cause function returns cause value.
  171. func (e TcpProxyValidationError) Cause() error { return e.cause }
  172. // Key function returns key value.
  173. func (e TcpProxyValidationError) Key() bool { return e.key }
  174. // ErrorName returns error name.
  175. func (e TcpProxyValidationError) ErrorName() string { return "TcpProxyValidationError" }
  176. // Error satisfies the builtin error interface
  177. func (e TcpProxyValidationError) Error() string {
  178. cause := ""
  179. if e.cause != nil {
  180. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  181. }
  182. key := ""
  183. if e.key {
  184. key = "key for "
  185. }
  186. return fmt.Sprintf(
  187. "invalid %sTcpProxy.%s: %s%s",
  188. key,
  189. e.field,
  190. e.reason,
  191. cause)
  192. }
  193. var _ error = TcpProxyValidationError{}
  194. var _ interface {
  195. Field() string
  196. Reason() string
  197. Key() bool
  198. Cause() error
  199. ErrorName() string
  200. } = TcpProxyValidationError{}
  201. // Validate checks the field values on TcpProxy_WeightedCluster with the rules
  202. // defined in the proto definition for this message. If any rules are
  203. // violated, an error is returned.
  204. func (m *TcpProxy_WeightedCluster) Validate() error {
  205. if m == nil {
  206. return nil
  207. }
  208. if len(m.GetClusters()) < 1 {
  209. return TcpProxy_WeightedClusterValidationError{
  210. field: "Clusters",
  211. reason: "value must contain at least 1 item(s)",
  212. }
  213. }
  214. for idx, item := range m.GetClusters() {
  215. _, _ = idx, item
  216. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  217. if err := v.Validate(); err != nil {
  218. return TcpProxy_WeightedClusterValidationError{
  219. field: fmt.Sprintf("Clusters[%v]", idx),
  220. reason: "embedded message failed validation",
  221. cause: err,
  222. }
  223. }
  224. }
  225. }
  226. return nil
  227. }
  228. // TcpProxy_WeightedClusterValidationError is the validation error returned by
  229. // TcpProxy_WeightedCluster.Validate if the designated constraints aren't met.
  230. type TcpProxy_WeightedClusterValidationError struct {
  231. field string
  232. reason string
  233. cause error
  234. key bool
  235. }
  236. // Field function returns field value.
  237. func (e TcpProxy_WeightedClusterValidationError) Field() string { return e.field }
  238. // Reason function returns reason value.
  239. func (e TcpProxy_WeightedClusterValidationError) Reason() string { return e.reason }
  240. // Cause function returns cause value.
  241. func (e TcpProxy_WeightedClusterValidationError) Cause() error { return e.cause }
  242. // Key function returns key value.
  243. func (e TcpProxy_WeightedClusterValidationError) Key() bool { return e.key }
  244. // ErrorName returns error name.
  245. func (e TcpProxy_WeightedClusterValidationError) ErrorName() string {
  246. return "TcpProxy_WeightedClusterValidationError"
  247. }
  248. // Error satisfies the builtin error interface
  249. func (e TcpProxy_WeightedClusterValidationError) Error() string {
  250. cause := ""
  251. if e.cause != nil {
  252. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  253. }
  254. key := ""
  255. if e.key {
  256. key = "key for "
  257. }
  258. return fmt.Sprintf(
  259. "invalid %sTcpProxy_WeightedCluster.%s: %s%s",
  260. key,
  261. e.field,
  262. e.reason,
  263. cause)
  264. }
  265. var _ error = TcpProxy_WeightedClusterValidationError{}
  266. var _ interface {
  267. Field() string
  268. Reason() string
  269. Key() bool
  270. Cause() error
  271. ErrorName() string
  272. } = TcpProxy_WeightedClusterValidationError{}
  273. // Validate checks the field values on TcpProxy_TunnelingConfig with the rules
  274. // defined in the proto definition for this message. If any rules are
  275. // violated, an error is returned.
  276. func (m *TcpProxy_TunnelingConfig) Validate() error {
  277. if m == nil {
  278. return nil
  279. }
  280. if len(m.GetHostname()) < 1 {
  281. return TcpProxy_TunnelingConfigValidationError{
  282. field: "Hostname",
  283. reason: "value length must be at least 1 bytes",
  284. }
  285. }
  286. return nil
  287. }
  288. // TcpProxy_TunnelingConfigValidationError is the validation error returned by
  289. // TcpProxy_TunnelingConfig.Validate if the designated constraints aren't met.
  290. type TcpProxy_TunnelingConfigValidationError struct {
  291. field string
  292. reason string
  293. cause error
  294. key bool
  295. }
  296. // Field function returns field value.
  297. func (e TcpProxy_TunnelingConfigValidationError) Field() string { return e.field }
  298. // Reason function returns reason value.
  299. func (e TcpProxy_TunnelingConfigValidationError) Reason() string { return e.reason }
  300. // Cause function returns cause value.
  301. func (e TcpProxy_TunnelingConfigValidationError) Cause() error { return e.cause }
  302. // Key function returns key value.
  303. func (e TcpProxy_TunnelingConfigValidationError) Key() bool { return e.key }
  304. // ErrorName returns error name.
  305. func (e TcpProxy_TunnelingConfigValidationError) ErrorName() string {
  306. return "TcpProxy_TunnelingConfigValidationError"
  307. }
  308. // Error satisfies the builtin error interface
  309. func (e TcpProxy_TunnelingConfigValidationError) Error() string {
  310. cause := ""
  311. if e.cause != nil {
  312. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  313. }
  314. key := ""
  315. if e.key {
  316. key = "key for "
  317. }
  318. return fmt.Sprintf(
  319. "invalid %sTcpProxy_TunnelingConfig.%s: %s%s",
  320. key,
  321. e.field,
  322. e.reason,
  323. cause)
  324. }
  325. var _ error = TcpProxy_TunnelingConfigValidationError{}
  326. var _ interface {
  327. Field() string
  328. Reason() string
  329. Key() bool
  330. Cause() error
  331. ErrorName() string
  332. } = TcpProxy_TunnelingConfigValidationError{}
  333. // Validate checks the field values on TcpProxy_DeprecatedV1 with the rules
  334. // defined in the proto definition for this message. If any rules are
  335. // violated, an error is returned.
  336. func (m *TcpProxy_DeprecatedV1) Validate() error {
  337. if m == nil {
  338. return nil
  339. }
  340. if len(m.GetRoutes()) < 1 {
  341. return TcpProxy_DeprecatedV1ValidationError{
  342. field: "Routes",
  343. reason: "value must contain at least 1 item(s)",
  344. }
  345. }
  346. for idx, item := range m.GetRoutes() {
  347. _, _ = idx, item
  348. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  349. if err := v.Validate(); err != nil {
  350. return TcpProxy_DeprecatedV1ValidationError{
  351. field: fmt.Sprintf("Routes[%v]", idx),
  352. reason: "embedded message failed validation",
  353. cause: err,
  354. }
  355. }
  356. }
  357. }
  358. return nil
  359. }
  360. // TcpProxy_DeprecatedV1ValidationError is the validation error returned by
  361. // TcpProxy_DeprecatedV1.Validate if the designated constraints aren't met.
  362. type TcpProxy_DeprecatedV1ValidationError struct {
  363. field string
  364. reason string
  365. cause error
  366. key bool
  367. }
  368. // Field function returns field value.
  369. func (e TcpProxy_DeprecatedV1ValidationError) Field() string { return e.field }
  370. // Reason function returns reason value.
  371. func (e TcpProxy_DeprecatedV1ValidationError) Reason() string { return e.reason }
  372. // Cause function returns cause value.
  373. func (e TcpProxy_DeprecatedV1ValidationError) Cause() error { return e.cause }
  374. // Key function returns key value.
  375. func (e TcpProxy_DeprecatedV1ValidationError) Key() bool { return e.key }
  376. // ErrorName returns error name.
  377. func (e TcpProxy_DeprecatedV1ValidationError) ErrorName() string {
  378. return "TcpProxy_DeprecatedV1ValidationError"
  379. }
  380. // Error satisfies the builtin error interface
  381. func (e TcpProxy_DeprecatedV1ValidationError) Error() string {
  382. cause := ""
  383. if e.cause != nil {
  384. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  385. }
  386. key := ""
  387. if e.key {
  388. key = "key for "
  389. }
  390. return fmt.Sprintf(
  391. "invalid %sTcpProxy_DeprecatedV1.%s: %s%s",
  392. key,
  393. e.field,
  394. e.reason,
  395. cause)
  396. }
  397. var _ error = TcpProxy_DeprecatedV1ValidationError{}
  398. var _ interface {
  399. Field() string
  400. Reason() string
  401. Key() bool
  402. Cause() error
  403. ErrorName() string
  404. } = TcpProxy_DeprecatedV1ValidationError{}
  405. // Validate checks the field values on TcpProxy_WeightedCluster_ClusterWeight
  406. // with the rules defined in the proto definition for this message. If any
  407. // rules are violated, an error is returned.
  408. func (m *TcpProxy_WeightedCluster_ClusterWeight) Validate() error {
  409. if m == nil {
  410. return nil
  411. }
  412. if len(m.GetName()) < 1 {
  413. return TcpProxy_WeightedCluster_ClusterWeightValidationError{
  414. field: "Name",
  415. reason: "value length must be at least 1 bytes",
  416. }
  417. }
  418. if m.GetWeight() < 1 {
  419. return TcpProxy_WeightedCluster_ClusterWeightValidationError{
  420. field: "Weight",
  421. reason: "value must be greater than or equal to 1",
  422. }
  423. }
  424. if v, ok := interface{}(m.GetMetadataMatch()).(interface{ Validate() error }); ok {
  425. if err := v.Validate(); err != nil {
  426. return TcpProxy_WeightedCluster_ClusterWeightValidationError{
  427. field: "MetadataMatch",
  428. reason: "embedded message failed validation",
  429. cause: err,
  430. }
  431. }
  432. }
  433. return nil
  434. }
  435. // TcpProxy_WeightedCluster_ClusterWeightValidationError is the validation
  436. // error returned by TcpProxy_WeightedCluster_ClusterWeight.Validate if the
  437. // designated constraints aren't met.
  438. type TcpProxy_WeightedCluster_ClusterWeightValidationError struct {
  439. field string
  440. reason string
  441. cause error
  442. key bool
  443. }
  444. // Field function returns field value.
  445. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Field() string { return e.field }
  446. // Reason function returns reason value.
  447. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Reason() string { return e.reason }
  448. // Cause function returns cause value.
  449. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Cause() error { return e.cause }
  450. // Key function returns key value.
  451. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Key() bool { return e.key }
  452. // ErrorName returns error name.
  453. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) ErrorName() string {
  454. return "TcpProxy_WeightedCluster_ClusterWeightValidationError"
  455. }
  456. // Error satisfies the builtin error interface
  457. func (e TcpProxy_WeightedCluster_ClusterWeightValidationError) Error() string {
  458. cause := ""
  459. if e.cause != nil {
  460. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  461. }
  462. key := ""
  463. if e.key {
  464. key = "key for "
  465. }
  466. return fmt.Sprintf(
  467. "invalid %sTcpProxy_WeightedCluster_ClusterWeight.%s: %s%s",
  468. key,
  469. e.field,
  470. e.reason,
  471. cause)
  472. }
  473. var _ error = TcpProxy_WeightedCluster_ClusterWeightValidationError{}
  474. var _ interface {
  475. Field() string
  476. Reason() string
  477. Key() bool
  478. Cause() error
  479. ErrorName() string
  480. } = TcpProxy_WeightedCluster_ClusterWeightValidationError{}
  481. // Validate checks the field values on TcpProxy_DeprecatedV1_TCPRoute with the
  482. // rules defined in the proto definition for this message. If any rules are
  483. // violated, an error is returned.
  484. func (m *TcpProxy_DeprecatedV1_TCPRoute) Validate() error {
  485. if m == nil {
  486. return nil
  487. }
  488. if len(m.GetCluster()) < 1 {
  489. return TcpProxy_DeprecatedV1_TCPRouteValidationError{
  490. field: "Cluster",
  491. reason: "value length must be at least 1 bytes",
  492. }
  493. }
  494. for idx, item := range m.GetDestinationIpList() {
  495. _, _ = idx, item
  496. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  497. if err := v.Validate(); err != nil {
  498. return TcpProxy_DeprecatedV1_TCPRouteValidationError{
  499. field: fmt.Sprintf("DestinationIpList[%v]", idx),
  500. reason: "embedded message failed validation",
  501. cause: err,
  502. }
  503. }
  504. }
  505. }
  506. // no validation rules for DestinationPorts
  507. for idx, item := range m.GetSourceIpList() {
  508. _, _ = idx, item
  509. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  510. if err := v.Validate(); err != nil {
  511. return TcpProxy_DeprecatedV1_TCPRouteValidationError{
  512. field: fmt.Sprintf("SourceIpList[%v]", idx),
  513. reason: "embedded message failed validation",
  514. cause: err,
  515. }
  516. }
  517. }
  518. }
  519. // no validation rules for SourcePorts
  520. return nil
  521. }
  522. // TcpProxy_DeprecatedV1_TCPRouteValidationError is the validation error
  523. // returned by TcpProxy_DeprecatedV1_TCPRoute.Validate if the designated
  524. // constraints aren't met.
  525. type TcpProxy_DeprecatedV1_TCPRouteValidationError struct {
  526. field string
  527. reason string
  528. cause error
  529. key bool
  530. }
  531. // Field function returns field value.
  532. func (e TcpProxy_DeprecatedV1_TCPRouteValidationError) Field() string { return e.field }
  533. // Reason function returns reason value.
  534. func (e TcpProxy_DeprecatedV1_TCPRouteValidationError) Reason() string { return e.reason }
  535. // Cause function returns cause value.
  536. func (e TcpProxy_DeprecatedV1_TCPRouteValidationError) Cause() error { return e.cause }
  537. // Key function returns key value.
  538. func (e TcpProxy_DeprecatedV1_TCPRouteValidationError) Key() bool { return e.key }
  539. // ErrorName returns error name.
  540. func (e TcpProxy_DeprecatedV1_TCPRouteValidationError) ErrorName() string {
  541. return "TcpProxy_DeprecatedV1_TCPRouteValidationError"
  542. }
  543. // Error satisfies the builtin error interface
  544. func (e TcpProxy_DeprecatedV1_TCPRouteValidationError) Error() string {
  545. cause := ""
  546. if e.cause != nil {
  547. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  548. }
  549. key := ""
  550. if e.key {
  551. key = "key for "
  552. }
  553. return fmt.Sprintf(
  554. "invalid %sTcpProxy_DeprecatedV1_TCPRoute.%s: %s%s",
  555. key,
  556. e.field,
  557. e.reason,
  558. cause)
  559. }
  560. var _ error = TcpProxy_DeprecatedV1_TCPRouteValidationError{}
  561. var _ interface {
  562. Field() string
  563. Reason() string
  564. Key() bool
  565. Cause() error
  566. ErrorName() string
  567. } = TcpProxy_DeprecatedV1_TCPRouteValidationError{}