/pkg/api/envoy/config/listener/v4alpha/listener_components.pb.validate.go

https://github.com/datawire/ambassador · Go · 708 lines · 499 code · 135 blank · 74 comment · 98 complexity · 9f5467097d9c612389fc2fd183ea1a43 MD5 · raw file

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