/pkg/api/envoy/api/v2/listener/listener_components.pb.validate.go

https://github.com/datawire/ambassador · Go · 742 lines · 528 code · 140 blank · 74 comment · 107 complexity · a65582aeabfabd25028c370a034518ad MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/api/v2/listener/listener_components.proto
  3. package envoy_api_v2_listener
  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 _listener_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}$")
  33. // Validate checks the field values on Filter with the rules defined in the
  34. // proto definition for this message. If any rules are violated, an error is returned.
  35. func (m *Filter) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if len(m.GetName()) < 1 {
  40. return FilterValidationError{
  41. field: "Name",
  42. reason: "value length must be at least 1 bytes",
  43. }
  44. }
  45. switch m.ConfigType.(type) {
  46. case *Filter_Config:
  47. if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
  48. if err := v.Validate(); err != nil {
  49. return FilterValidationError{
  50. field: "Config",
  51. reason: "embedded message failed validation",
  52. cause: err,
  53. }
  54. }
  55. }
  56. case *Filter_TypedConfig:
  57. if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
  58. if err := v.Validate(); err != nil {
  59. return FilterValidationError{
  60. field: "TypedConfig",
  61. reason: "embedded message failed validation",
  62. cause: err,
  63. }
  64. }
  65. }
  66. }
  67. return nil
  68. }
  69. // FilterValidationError is the validation error returned by Filter.Validate if
  70. // the designated constraints aren't met.
  71. type FilterValidationError struct {
  72. field string
  73. reason string
  74. cause error
  75. key bool
  76. }
  77. // Field function returns field value.
  78. func (e FilterValidationError) Field() string { return e.field }
  79. // Reason function returns reason value.
  80. func (e FilterValidationError) Reason() string { return e.reason }
  81. // Cause function returns cause value.
  82. func (e FilterValidationError) Cause() error { return e.cause }
  83. // Key function returns key value.
  84. func (e FilterValidationError) Key() bool { return e.key }
  85. // ErrorName returns error name.
  86. func (e FilterValidationError) ErrorName() string { return "FilterValidationError" }
  87. // Error satisfies the builtin error interface
  88. func (e FilterValidationError) Error() string {
  89. cause := ""
  90. if e.cause != nil {
  91. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  92. }
  93. key := ""
  94. if e.key {
  95. key = "key for "
  96. }
  97. return fmt.Sprintf(
  98. "invalid %sFilter.%s: %s%s",
  99. key,
  100. e.field,
  101. e.reason,
  102. cause)
  103. }
  104. var _ error = FilterValidationError{}
  105. var _ interface {
  106. Field() string
  107. Reason() string
  108. Key() bool
  109. Cause() error
  110. ErrorName() string
  111. } = FilterValidationError{}
  112. // Validate checks the field values on FilterChainMatch with the rules defined
  113. // in the proto definition for this message. If any rules are violated, an
  114. // error is returned.
  115. func (m *FilterChainMatch) Validate() error {
  116. if m == nil {
  117. return nil
  118. }
  119. if wrapper := m.GetDestinationPort(); wrapper != nil {
  120. if val := wrapper.GetValue(); val < 1 || val > 65535 {
  121. return FilterChainMatchValidationError{
  122. field: "DestinationPort",
  123. reason: "value must be inside range [1, 65535]",
  124. }
  125. }
  126. }
  127. for idx, item := range m.GetPrefixRanges() {
  128. _, _ = idx, item
  129. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  130. if err := v.Validate(); err != nil {
  131. return FilterChainMatchValidationError{
  132. field: fmt.Sprintf("PrefixRanges[%v]", idx),
  133. reason: "embedded message failed validation",
  134. cause: err,
  135. }
  136. }
  137. }
  138. }
  139. // no validation rules for AddressSuffix
  140. if v, ok := interface{}(m.GetSuffixLen()).(interface{ Validate() error }); ok {
  141. if err := v.Validate(); err != nil {
  142. return FilterChainMatchValidationError{
  143. field: "SuffixLen",
  144. reason: "embedded message failed validation",
  145. cause: err,
  146. }
  147. }
  148. }
  149. if _, ok := FilterChainMatch_ConnectionSourceType_name[int32(m.GetSourceType())]; !ok {
  150. return FilterChainMatchValidationError{
  151. field: "SourceType",
  152. reason: "value must be one of the defined enum values",
  153. }
  154. }
  155. for idx, item := range m.GetSourcePrefixRanges() {
  156. _, _ = idx, item
  157. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  158. if err := v.Validate(); err != nil {
  159. return FilterChainMatchValidationError{
  160. field: fmt.Sprintf("SourcePrefixRanges[%v]", idx),
  161. reason: "embedded message failed validation",
  162. cause: err,
  163. }
  164. }
  165. }
  166. }
  167. for idx, item := range m.GetSourcePorts() {
  168. _, _ = idx, item
  169. if val := item; val < 1 || val > 65535 {
  170. return FilterChainMatchValidationError{
  171. field: fmt.Sprintf("SourcePorts[%v]", idx),
  172. reason: "value must be inside range [1, 65535]",
  173. }
  174. }
  175. }
  176. // no validation rules for TransportProtocol
  177. return nil
  178. }
  179. // FilterChainMatchValidationError is the validation error returned by
  180. // FilterChainMatch.Validate if the designated constraints aren't met.
  181. type FilterChainMatchValidationError struct {
  182. field string
  183. reason string
  184. cause error
  185. key bool
  186. }
  187. // Field function returns field value.
  188. func (e FilterChainMatchValidationError) Field() string { return e.field }
  189. // Reason function returns reason value.
  190. func (e FilterChainMatchValidationError) Reason() string { return e.reason }
  191. // Cause function returns cause value.
  192. func (e FilterChainMatchValidationError) Cause() error { return e.cause }
  193. // Key function returns key value.
  194. func (e FilterChainMatchValidationError) Key() bool { return e.key }
  195. // ErrorName returns error name.
  196. func (e FilterChainMatchValidationError) ErrorName() string { return "FilterChainMatchValidationError" }
  197. // Error satisfies the builtin error interface
  198. func (e FilterChainMatchValidationError) Error() string {
  199. cause := ""
  200. if e.cause != nil {
  201. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  202. }
  203. key := ""
  204. if e.key {
  205. key = "key for "
  206. }
  207. return fmt.Sprintf(
  208. "invalid %sFilterChainMatch.%s: %s%s",
  209. key,
  210. e.field,
  211. e.reason,
  212. cause)
  213. }
  214. var _ error = FilterChainMatchValidationError{}
  215. var _ interface {
  216. Field() string
  217. Reason() string
  218. Key() bool
  219. Cause() error
  220. ErrorName() string
  221. } = FilterChainMatchValidationError{}
  222. // Validate checks the field values on FilterChain with the rules defined in
  223. // the proto definition for this message. If any rules are violated, an error
  224. // is returned.
  225. func (m *FilterChain) Validate() error {
  226. if m == nil {
  227. return nil
  228. }
  229. if v, ok := interface{}(m.GetFilterChainMatch()).(interface{ Validate() error }); ok {
  230. if err := v.Validate(); err != nil {
  231. return FilterChainValidationError{
  232. field: "FilterChainMatch",
  233. reason: "embedded message failed validation",
  234. cause: err,
  235. }
  236. }
  237. }
  238. if v, ok := interface{}(m.GetTlsContext()).(interface{ Validate() error }); ok {
  239. if err := v.Validate(); err != nil {
  240. return FilterChainValidationError{
  241. field: "TlsContext",
  242. reason: "embedded message failed validation",
  243. cause: err,
  244. }
  245. }
  246. }
  247. for idx, item := range m.GetFilters() {
  248. _, _ = idx, item
  249. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  250. if err := v.Validate(); err != nil {
  251. return FilterChainValidationError{
  252. field: fmt.Sprintf("Filters[%v]", idx),
  253. reason: "embedded message failed validation",
  254. cause: err,
  255. }
  256. }
  257. }
  258. }
  259. if v, ok := interface{}(m.GetUseProxyProto()).(interface{ Validate() error }); ok {
  260. if err := v.Validate(); err != nil {
  261. return FilterChainValidationError{
  262. field: "UseProxyProto",
  263. reason: "embedded message failed validation",
  264. cause: err,
  265. }
  266. }
  267. }
  268. if v, ok := interface{}(m.GetMetadata()).(interface{ Validate() error }); ok {
  269. if err := v.Validate(); err != nil {
  270. return FilterChainValidationError{
  271. field: "Metadata",
  272. reason: "embedded message failed validation",
  273. cause: err,
  274. }
  275. }
  276. }
  277. if v, ok := interface{}(m.GetTransportSocket()).(interface{ Validate() error }); ok {
  278. if err := v.Validate(); err != nil {
  279. return FilterChainValidationError{
  280. field: "TransportSocket",
  281. reason: "embedded message failed validation",
  282. cause: err,
  283. }
  284. }
  285. }
  286. // no validation rules for Name
  287. return nil
  288. }
  289. // FilterChainValidationError is the validation error returned by
  290. // FilterChain.Validate if the designated constraints aren't met.
  291. type FilterChainValidationError struct {
  292. field string
  293. reason string
  294. cause error
  295. key bool
  296. }
  297. // Field function returns field value.
  298. func (e FilterChainValidationError) Field() string { return e.field }
  299. // Reason function returns reason value.
  300. func (e FilterChainValidationError) Reason() string { return e.reason }
  301. // Cause function returns cause value.
  302. func (e FilterChainValidationError) Cause() error { return e.cause }
  303. // Key function returns key value.
  304. func (e FilterChainValidationError) Key() bool { return e.key }
  305. // ErrorName returns error name.
  306. func (e FilterChainValidationError) ErrorName() string { return "FilterChainValidationError" }
  307. // Error satisfies the builtin error interface
  308. func (e FilterChainValidationError) Error() string {
  309. cause := ""
  310. if e.cause != nil {
  311. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  312. }
  313. key := ""
  314. if e.key {
  315. key = "key for "
  316. }
  317. return fmt.Sprintf(
  318. "invalid %sFilterChain.%s: %s%s",
  319. key,
  320. e.field,
  321. e.reason,
  322. cause)
  323. }
  324. var _ error = FilterChainValidationError{}
  325. var _ interface {
  326. Field() string
  327. Reason() string
  328. Key() bool
  329. Cause() error
  330. ErrorName() string
  331. } = FilterChainValidationError{}
  332. // Validate checks the field values on ListenerFilterChainMatchPredicate with
  333. // the rules defined in the proto definition for this message. If any rules
  334. // are violated, an error is returned.
  335. func (m *ListenerFilterChainMatchPredicate) Validate() error {
  336. if m == nil {
  337. return nil
  338. }
  339. switch m.Rule.(type) {
  340. case *ListenerFilterChainMatchPredicate_OrMatch:
  341. if v, ok := interface{}(m.GetOrMatch()).(interface{ Validate() error }); ok {
  342. if err := v.Validate(); err != nil {
  343. return ListenerFilterChainMatchPredicateValidationError{
  344. field: "OrMatch",
  345. reason: "embedded message failed validation",
  346. cause: err,
  347. }
  348. }
  349. }
  350. case *ListenerFilterChainMatchPredicate_AndMatch:
  351. if v, ok := interface{}(m.GetAndMatch()).(interface{ Validate() error }); ok {
  352. if err := v.Validate(); err != nil {
  353. return ListenerFilterChainMatchPredicateValidationError{
  354. field: "AndMatch",
  355. reason: "embedded message failed validation",
  356. cause: err,
  357. }
  358. }
  359. }
  360. case *ListenerFilterChainMatchPredicate_NotMatch:
  361. if v, ok := interface{}(m.GetNotMatch()).(interface{ Validate() error }); ok {
  362. if err := v.Validate(); err != nil {
  363. return ListenerFilterChainMatchPredicateValidationError{
  364. field: "NotMatch",
  365. reason: "embedded message failed validation",
  366. cause: err,
  367. }
  368. }
  369. }
  370. case *ListenerFilterChainMatchPredicate_AnyMatch:
  371. if m.GetAnyMatch() != true {
  372. return ListenerFilterChainMatchPredicateValidationError{
  373. field: "AnyMatch",
  374. reason: "value must equal true",
  375. }
  376. }
  377. case *ListenerFilterChainMatchPredicate_DestinationPortRange:
  378. if v, ok := interface{}(m.GetDestinationPortRange()).(interface{ Validate() error }); ok {
  379. if err := v.Validate(); err != nil {
  380. return ListenerFilterChainMatchPredicateValidationError{
  381. field: "DestinationPortRange",
  382. reason: "embedded message failed validation",
  383. cause: err,
  384. }
  385. }
  386. }
  387. default:
  388. return ListenerFilterChainMatchPredicateValidationError{
  389. field: "Rule",
  390. reason: "value is required",
  391. }
  392. }
  393. return nil
  394. }
  395. // ListenerFilterChainMatchPredicateValidationError is the validation error
  396. // returned by ListenerFilterChainMatchPredicate.Validate if the designated
  397. // constraints aren't met.
  398. type ListenerFilterChainMatchPredicateValidationError struct {
  399. field string
  400. reason string
  401. cause error
  402. key bool
  403. }
  404. // Field function returns field value.
  405. func (e ListenerFilterChainMatchPredicateValidationError) Field() string { return e.field }
  406. // Reason function returns reason value.
  407. func (e ListenerFilterChainMatchPredicateValidationError) Reason() string { return e.reason }
  408. // Cause function returns cause value.
  409. func (e ListenerFilterChainMatchPredicateValidationError) Cause() error { return e.cause }
  410. // Key function returns key value.
  411. func (e ListenerFilterChainMatchPredicateValidationError) Key() bool { return e.key }
  412. // ErrorName returns error name.
  413. func (e ListenerFilterChainMatchPredicateValidationError) ErrorName() string {
  414. return "ListenerFilterChainMatchPredicateValidationError"
  415. }
  416. // Error satisfies the builtin error interface
  417. func (e ListenerFilterChainMatchPredicateValidationError) Error() string {
  418. cause := ""
  419. if e.cause != nil {
  420. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  421. }
  422. key := ""
  423. if e.key {
  424. key = "key for "
  425. }
  426. return fmt.Sprintf(
  427. "invalid %sListenerFilterChainMatchPredicate.%s: %s%s",
  428. key,
  429. e.field,
  430. e.reason,
  431. cause)
  432. }
  433. var _ error = ListenerFilterChainMatchPredicateValidationError{}
  434. var _ interface {
  435. Field() string
  436. Reason() string
  437. Key() bool
  438. Cause() error
  439. ErrorName() string
  440. } = ListenerFilterChainMatchPredicateValidationError{}
  441. // Validate checks the field values on ListenerFilter with the rules defined in
  442. // the proto definition for this message. If any rules are violated, an error
  443. // is returned.
  444. func (m *ListenerFilter) Validate() error {
  445. if m == nil {
  446. return nil
  447. }
  448. if len(m.GetName()) < 1 {
  449. return ListenerFilterValidationError{
  450. field: "Name",
  451. reason: "value length must be at least 1 bytes",
  452. }
  453. }
  454. if v, ok := interface{}(m.GetFilterDisabled()).(interface{ Validate() error }); ok {
  455. if err := v.Validate(); err != nil {
  456. return ListenerFilterValidationError{
  457. field: "FilterDisabled",
  458. reason: "embedded message failed validation",
  459. cause: err,
  460. }
  461. }
  462. }
  463. switch m.ConfigType.(type) {
  464. case *ListenerFilter_Config:
  465. if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
  466. if err := v.Validate(); err != nil {
  467. return ListenerFilterValidationError{
  468. field: "Config",
  469. reason: "embedded message failed validation",
  470. cause: err,
  471. }
  472. }
  473. }
  474. case *ListenerFilter_TypedConfig:
  475. if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
  476. if err := v.Validate(); err != nil {
  477. return ListenerFilterValidationError{
  478. field: "TypedConfig",
  479. reason: "embedded message failed validation",
  480. cause: err,
  481. }
  482. }
  483. }
  484. }
  485. return nil
  486. }
  487. // ListenerFilterValidationError is the validation error returned by
  488. // ListenerFilter.Validate if the designated constraints aren't met.
  489. type ListenerFilterValidationError struct {
  490. field string
  491. reason string
  492. cause error
  493. key bool
  494. }
  495. // Field function returns field value.
  496. func (e ListenerFilterValidationError) Field() string { return e.field }
  497. // Reason function returns reason value.
  498. func (e ListenerFilterValidationError) Reason() string { return e.reason }
  499. // Cause function returns cause value.
  500. func (e ListenerFilterValidationError) Cause() error { return e.cause }
  501. // Key function returns key value.
  502. func (e ListenerFilterValidationError) Key() bool { return e.key }
  503. // ErrorName returns error name.
  504. func (e ListenerFilterValidationError) ErrorName() string { return "ListenerFilterValidationError" }
  505. // Error satisfies the builtin error interface
  506. func (e ListenerFilterValidationError) Error() string {
  507. cause := ""
  508. if e.cause != nil {
  509. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  510. }
  511. key := ""
  512. if e.key {
  513. key = "key for "
  514. }
  515. return fmt.Sprintf(
  516. "invalid %sListenerFilter.%s: %s%s",
  517. key,
  518. e.field,
  519. e.reason,
  520. cause)
  521. }
  522. var _ error = ListenerFilterValidationError{}
  523. var _ interface {
  524. Field() string
  525. Reason() string
  526. Key() bool
  527. Cause() error
  528. ErrorName() string
  529. } = ListenerFilterValidationError{}
  530. // Validate checks the field values on
  531. // ListenerFilterChainMatchPredicate_MatchSet with the rules defined in the
  532. // proto definition for this message. If any rules are violated, an error is returned.
  533. func (m *ListenerFilterChainMatchPredicate_MatchSet) Validate() error {
  534. if m == nil {
  535. return nil
  536. }
  537. if len(m.GetRules()) < 2 {
  538. return ListenerFilterChainMatchPredicate_MatchSetValidationError{
  539. field: "Rules",
  540. reason: "value must contain at least 2 item(s)",
  541. }
  542. }
  543. for idx, item := range m.GetRules() {
  544. _, _ = idx, item
  545. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  546. if err := v.Validate(); err != nil {
  547. return ListenerFilterChainMatchPredicate_MatchSetValidationError{
  548. field: fmt.Sprintf("Rules[%v]", idx),
  549. reason: "embedded message failed validation",
  550. cause: err,
  551. }
  552. }
  553. }
  554. }
  555. return nil
  556. }
  557. // ListenerFilterChainMatchPredicate_MatchSetValidationError is the validation
  558. // error returned by ListenerFilterChainMatchPredicate_MatchSet.Validate if
  559. // the designated constraints aren't met.
  560. type ListenerFilterChainMatchPredicate_MatchSetValidationError struct {
  561. field string
  562. reason string
  563. cause error
  564. key bool
  565. }
  566. // Field function returns field value.
  567. func (e ListenerFilterChainMatchPredicate_MatchSetValidationError) Field() string { return e.field }
  568. // Reason function returns reason value.
  569. func (e ListenerFilterChainMatchPredicate_MatchSetValidationError) Reason() string { return e.reason }
  570. // Cause function returns cause value.
  571. func (e ListenerFilterChainMatchPredicate_MatchSetValidationError) Cause() error { return e.cause }
  572. // Key function returns key value.
  573. func (e ListenerFilterChainMatchPredicate_MatchSetValidationError) Key() bool { return e.key }
  574. // ErrorName returns error name.
  575. func (e ListenerFilterChainMatchPredicate_MatchSetValidationError) ErrorName() string {
  576. return "ListenerFilterChainMatchPredicate_MatchSetValidationError"
  577. }
  578. // Error satisfies the builtin error interface
  579. func (e ListenerFilterChainMatchPredicate_MatchSetValidationError) Error() string {
  580. cause := ""
  581. if e.cause != nil {
  582. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  583. }
  584. key := ""
  585. if e.key {
  586. key = "key for "
  587. }
  588. return fmt.Sprintf(
  589. "invalid %sListenerFilterChainMatchPredicate_MatchSet.%s: %s%s",
  590. key,
  591. e.field,
  592. e.reason,
  593. cause)
  594. }
  595. var _ error = ListenerFilterChainMatchPredicate_MatchSetValidationError{}
  596. var _ interface {
  597. Field() string
  598. Reason() string
  599. Key() bool
  600. Cause() error
  601. ErrorName() string
  602. } = ListenerFilterChainMatchPredicate_MatchSetValidationError{}