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

https://github.com/cloudfoundry/bosh-cli · Go · 707 lines · 549 code · 95 blank · 63 comment · 131 complexity · 1c212485b2350a3281041e5ae0e2c655 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/route/v3/route.proto
  3. package envoy_config_route_v3
  4. import (
  5. "bytes"
  6. "errors"
  7. "fmt"
  8. "net"
  9. "net/mail"
  10. "net/url"
  11. "regexp"
  12. "sort"
  13. "strings"
  14. "time"
  15. "unicode/utf8"
  16. "google.golang.org/protobuf/types/known/anypb"
  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. _ = anypb.Any{}
  31. _ = sort.Sort
  32. )
  33. // Validate checks the field values on RouteConfiguration with the rules
  34. // defined in the proto definition for this message. If any rules are
  35. // violated, the first error encountered is returned, or nil if there are no violations.
  36. func (m *RouteConfiguration) Validate() error {
  37. return m.validate(false)
  38. }
  39. // ValidateAll checks the field values on RouteConfiguration with the rules
  40. // defined in the proto definition for this message. If any rules are
  41. // violated, the result is a list of violation errors wrapped in
  42. // RouteConfigurationMultiError, or nil if none found.
  43. func (m *RouteConfiguration) ValidateAll() error {
  44. return m.validate(true)
  45. }
  46. func (m *RouteConfiguration) validate(all bool) error {
  47. if m == nil {
  48. return nil
  49. }
  50. var errors []error
  51. // no validation rules for Name
  52. for idx, item := range m.GetVirtualHosts() {
  53. _, _ = idx, item
  54. if all {
  55. switch v := interface{}(item).(type) {
  56. case interface{ ValidateAll() error }:
  57. if err := v.ValidateAll(); err != nil {
  58. errors = append(errors, RouteConfigurationValidationError{
  59. field: fmt.Sprintf("VirtualHosts[%v]", idx),
  60. reason: "embedded message failed validation",
  61. cause: err,
  62. })
  63. }
  64. case interface{ Validate() error }:
  65. if err := v.Validate(); err != nil {
  66. errors = append(errors, RouteConfigurationValidationError{
  67. field: fmt.Sprintf("VirtualHosts[%v]", idx),
  68. reason: "embedded message failed validation",
  69. cause: err,
  70. })
  71. }
  72. }
  73. } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  74. if err := v.Validate(); err != nil {
  75. return RouteConfigurationValidationError{
  76. field: fmt.Sprintf("VirtualHosts[%v]", idx),
  77. reason: "embedded message failed validation",
  78. cause: err,
  79. }
  80. }
  81. }
  82. }
  83. if all {
  84. switch v := interface{}(m.GetVhds()).(type) {
  85. case interface{ ValidateAll() error }:
  86. if err := v.ValidateAll(); err != nil {
  87. errors = append(errors, RouteConfigurationValidationError{
  88. field: "Vhds",
  89. reason: "embedded message failed validation",
  90. cause: err,
  91. })
  92. }
  93. case interface{ Validate() error }:
  94. if err := v.Validate(); err != nil {
  95. errors = append(errors, RouteConfigurationValidationError{
  96. field: "Vhds",
  97. reason: "embedded message failed validation",
  98. cause: err,
  99. })
  100. }
  101. }
  102. } else if v, ok := interface{}(m.GetVhds()).(interface{ Validate() error }); ok {
  103. if err := v.Validate(); err != nil {
  104. return RouteConfigurationValidationError{
  105. field: "Vhds",
  106. reason: "embedded message failed validation",
  107. cause: err,
  108. }
  109. }
  110. }
  111. for idx, item := range m.GetInternalOnlyHeaders() {
  112. _, _ = idx, item
  113. if !_RouteConfiguration_InternalOnlyHeaders_Pattern.MatchString(item) {
  114. err := RouteConfigurationValidationError{
  115. field: fmt.Sprintf("InternalOnlyHeaders[%v]", idx),
  116. reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
  117. }
  118. if !all {
  119. return err
  120. }
  121. errors = append(errors, err)
  122. }
  123. }
  124. if len(m.GetResponseHeadersToAdd()) > 1000 {
  125. err := RouteConfigurationValidationError{
  126. field: "ResponseHeadersToAdd",
  127. reason: "value must contain no more than 1000 item(s)",
  128. }
  129. if !all {
  130. return err
  131. }
  132. errors = append(errors, err)
  133. }
  134. for idx, item := range m.GetResponseHeadersToAdd() {
  135. _, _ = idx, item
  136. if all {
  137. switch v := interface{}(item).(type) {
  138. case interface{ ValidateAll() error }:
  139. if err := v.ValidateAll(); err != nil {
  140. errors = append(errors, RouteConfigurationValidationError{
  141. field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
  142. reason: "embedded message failed validation",
  143. cause: err,
  144. })
  145. }
  146. case interface{ Validate() error }:
  147. if err := v.Validate(); err != nil {
  148. errors = append(errors, RouteConfigurationValidationError{
  149. field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
  150. reason: "embedded message failed validation",
  151. cause: err,
  152. })
  153. }
  154. }
  155. } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  156. if err := v.Validate(); err != nil {
  157. return RouteConfigurationValidationError{
  158. field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
  159. reason: "embedded message failed validation",
  160. cause: err,
  161. }
  162. }
  163. }
  164. }
  165. for idx, item := range m.GetResponseHeadersToRemove() {
  166. _, _ = idx, item
  167. if !_RouteConfiguration_ResponseHeadersToRemove_Pattern.MatchString(item) {
  168. err := RouteConfigurationValidationError{
  169. field: fmt.Sprintf("ResponseHeadersToRemove[%v]", idx),
  170. reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
  171. }
  172. if !all {
  173. return err
  174. }
  175. errors = append(errors, err)
  176. }
  177. }
  178. if len(m.GetRequestHeadersToAdd()) > 1000 {
  179. err := RouteConfigurationValidationError{
  180. field: "RequestHeadersToAdd",
  181. reason: "value must contain no more than 1000 item(s)",
  182. }
  183. if !all {
  184. return err
  185. }
  186. errors = append(errors, err)
  187. }
  188. for idx, item := range m.GetRequestHeadersToAdd() {
  189. _, _ = idx, item
  190. if all {
  191. switch v := interface{}(item).(type) {
  192. case interface{ ValidateAll() error }:
  193. if err := v.ValidateAll(); err != nil {
  194. errors = append(errors, RouteConfigurationValidationError{
  195. field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
  196. reason: "embedded message failed validation",
  197. cause: err,
  198. })
  199. }
  200. case interface{ Validate() error }:
  201. if err := v.Validate(); err != nil {
  202. errors = append(errors, RouteConfigurationValidationError{
  203. field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
  204. reason: "embedded message failed validation",
  205. cause: err,
  206. })
  207. }
  208. }
  209. } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  210. if err := v.Validate(); err != nil {
  211. return RouteConfigurationValidationError{
  212. field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
  213. reason: "embedded message failed validation",
  214. cause: err,
  215. }
  216. }
  217. }
  218. }
  219. for idx, item := range m.GetRequestHeadersToRemove() {
  220. _, _ = idx, item
  221. if !_RouteConfiguration_RequestHeadersToRemove_Pattern.MatchString(item) {
  222. err := RouteConfigurationValidationError{
  223. field: fmt.Sprintf("RequestHeadersToRemove[%v]", idx),
  224. reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
  225. }
  226. if !all {
  227. return err
  228. }
  229. errors = append(errors, err)
  230. }
  231. }
  232. // no validation rules for MostSpecificHeaderMutationsWins
  233. if all {
  234. switch v := interface{}(m.GetValidateClusters()).(type) {
  235. case interface{ ValidateAll() error }:
  236. if err := v.ValidateAll(); err != nil {
  237. errors = append(errors, RouteConfigurationValidationError{
  238. field: "ValidateClusters",
  239. reason: "embedded message failed validation",
  240. cause: err,
  241. })
  242. }
  243. case interface{ Validate() error }:
  244. if err := v.Validate(); err != nil {
  245. errors = append(errors, RouteConfigurationValidationError{
  246. field: "ValidateClusters",
  247. reason: "embedded message failed validation",
  248. cause: err,
  249. })
  250. }
  251. }
  252. } else if v, ok := interface{}(m.GetValidateClusters()).(interface{ Validate() error }); ok {
  253. if err := v.Validate(); err != nil {
  254. return RouteConfigurationValidationError{
  255. field: "ValidateClusters",
  256. reason: "embedded message failed validation",
  257. cause: err,
  258. }
  259. }
  260. }
  261. if all {
  262. switch v := interface{}(m.GetMaxDirectResponseBodySizeBytes()).(type) {
  263. case interface{ ValidateAll() error }:
  264. if err := v.ValidateAll(); err != nil {
  265. errors = append(errors, RouteConfigurationValidationError{
  266. field: "MaxDirectResponseBodySizeBytes",
  267. reason: "embedded message failed validation",
  268. cause: err,
  269. })
  270. }
  271. case interface{ Validate() error }:
  272. if err := v.Validate(); err != nil {
  273. errors = append(errors, RouteConfigurationValidationError{
  274. field: "MaxDirectResponseBodySizeBytes",
  275. reason: "embedded message failed validation",
  276. cause: err,
  277. })
  278. }
  279. }
  280. } else if v, ok := interface{}(m.GetMaxDirectResponseBodySizeBytes()).(interface{ Validate() error }); ok {
  281. if err := v.Validate(); err != nil {
  282. return RouteConfigurationValidationError{
  283. field: "MaxDirectResponseBodySizeBytes",
  284. reason: "embedded message failed validation",
  285. cause: err,
  286. }
  287. }
  288. }
  289. for idx, item := range m.GetClusterSpecifierPlugins() {
  290. _, _ = idx, item
  291. if all {
  292. switch v := interface{}(item).(type) {
  293. case interface{ ValidateAll() error }:
  294. if err := v.ValidateAll(); err != nil {
  295. errors = append(errors, RouteConfigurationValidationError{
  296. field: fmt.Sprintf("ClusterSpecifierPlugins[%v]", idx),
  297. reason: "embedded message failed validation",
  298. cause: err,
  299. })
  300. }
  301. case interface{ Validate() error }:
  302. if err := v.Validate(); err != nil {
  303. errors = append(errors, RouteConfigurationValidationError{
  304. field: fmt.Sprintf("ClusterSpecifierPlugins[%v]", idx),
  305. reason: "embedded message failed validation",
  306. cause: err,
  307. })
  308. }
  309. }
  310. } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  311. if err := v.Validate(); err != nil {
  312. return RouteConfigurationValidationError{
  313. field: fmt.Sprintf("ClusterSpecifierPlugins[%v]", idx),
  314. reason: "embedded message failed validation",
  315. cause: err,
  316. }
  317. }
  318. }
  319. }
  320. if len(errors) > 0 {
  321. return RouteConfigurationMultiError(errors)
  322. }
  323. return nil
  324. }
  325. // RouteConfigurationMultiError is an error wrapping multiple validation errors
  326. // returned by RouteConfiguration.ValidateAll() if the designated constraints
  327. // aren't met.
  328. type RouteConfigurationMultiError []error
  329. // Error returns a concatenation of all the error messages it wraps.
  330. func (m RouteConfigurationMultiError) Error() string {
  331. var msgs []string
  332. for _, err := range m {
  333. msgs = append(msgs, err.Error())
  334. }
  335. return strings.Join(msgs, "; ")
  336. }
  337. // AllErrors returns a list of validation violation errors.
  338. func (m RouteConfigurationMultiError) AllErrors() []error { return m }
  339. // RouteConfigurationValidationError is the validation error returned by
  340. // RouteConfiguration.Validate if the designated constraints aren't met.
  341. type RouteConfigurationValidationError struct {
  342. field string
  343. reason string
  344. cause error
  345. key bool
  346. }
  347. // Field function returns field value.
  348. func (e RouteConfigurationValidationError) Field() string { return e.field }
  349. // Reason function returns reason value.
  350. func (e RouteConfigurationValidationError) Reason() string { return e.reason }
  351. // Cause function returns cause value.
  352. func (e RouteConfigurationValidationError) Cause() error { return e.cause }
  353. // Key function returns key value.
  354. func (e RouteConfigurationValidationError) Key() bool { return e.key }
  355. // ErrorName returns error name.
  356. func (e RouteConfigurationValidationError) ErrorName() string {
  357. return "RouteConfigurationValidationError"
  358. }
  359. // Error satisfies the builtin error interface
  360. func (e RouteConfigurationValidationError) Error() string {
  361. cause := ""
  362. if e.cause != nil {
  363. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  364. }
  365. key := ""
  366. if e.key {
  367. key = "key for "
  368. }
  369. return fmt.Sprintf(
  370. "invalid %sRouteConfiguration.%s: %s%s",
  371. key,
  372. e.field,
  373. e.reason,
  374. cause)
  375. }
  376. var _ error = RouteConfigurationValidationError{}
  377. var _ interface {
  378. Field() string
  379. Reason() string
  380. Key() bool
  381. Cause() error
  382. ErrorName() string
  383. } = RouteConfigurationValidationError{}
  384. var _RouteConfiguration_InternalOnlyHeaders_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
  385. var _RouteConfiguration_ResponseHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
  386. var _RouteConfiguration_RequestHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
  387. // Validate checks the field values on ClusterSpecifierPlugin with the rules
  388. // defined in the proto definition for this message. If any rules are
  389. // violated, the first error encountered is returned, or nil if there are no violations.
  390. func (m *ClusterSpecifierPlugin) Validate() error {
  391. return m.validate(false)
  392. }
  393. // ValidateAll checks the field values on ClusterSpecifierPlugin with the rules
  394. // defined in the proto definition for this message. If any rules are
  395. // violated, the result is a list of violation errors wrapped in
  396. // ClusterSpecifierPluginMultiError, or nil if none found.
  397. func (m *ClusterSpecifierPlugin) ValidateAll() error {
  398. return m.validate(true)
  399. }
  400. func (m *ClusterSpecifierPlugin) validate(all bool) error {
  401. if m == nil {
  402. return nil
  403. }
  404. var errors []error
  405. if all {
  406. switch v := interface{}(m.GetExtension()).(type) {
  407. case interface{ ValidateAll() error }:
  408. if err := v.ValidateAll(); err != nil {
  409. errors = append(errors, ClusterSpecifierPluginValidationError{
  410. field: "Extension",
  411. reason: "embedded message failed validation",
  412. cause: err,
  413. })
  414. }
  415. case interface{ Validate() error }:
  416. if err := v.Validate(); err != nil {
  417. errors = append(errors, ClusterSpecifierPluginValidationError{
  418. field: "Extension",
  419. reason: "embedded message failed validation",
  420. cause: err,
  421. })
  422. }
  423. }
  424. } else if v, ok := interface{}(m.GetExtension()).(interface{ Validate() error }); ok {
  425. if err := v.Validate(); err != nil {
  426. return ClusterSpecifierPluginValidationError{
  427. field: "Extension",
  428. reason: "embedded message failed validation",
  429. cause: err,
  430. }
  431. }
  432. }
  433. if len(errors) > 0 {
  434. return ClusterSpecifierPluginMultiError(errors)
  435. }
  436. return nil
  437. }
  438. // ClusterSpecifierPluginMultiError is an error wrapping multiple validation
  439. // errors returned by ClusterSpecifierPlugin.ValidateAll() if the designated
  440. // constraints aren't met.
  441. type ClusterSpecifierPluginMultiError []error
  442. // Error returns a concatenation of all the error messages it wraps.
  443. func (m ClusterSpecifierPluginMultiError) Error() string {
  444. var msgs []string
  445. for _, err := range m {
  446. msgs = append(msgs, err.Error())
  447. }
  448. return strings.Join(msgs, "; ")
  449. }
  450. // AllErrors returns a list of validation violation errors.
  451. func (m ClusterSpecifierPluginMultiError) AllErrors() []error { return m }
  452. // ClusterSpecifierPluginValidationError is the validation error returned by
  453. // ClusterSpecifierPlugin.Validate if the designated constraints aren't met.
  454. type ClusterSpecifierPluginValidationError struct {
  455. field string
  456. reason string
  457. cause error
  458. key bool
  459. }
  460. // Field function returns field value.
  461. func (e ClusterSpecifierPluginValidationError) Field() string { return e.field }
  462. // Reason function returns reason value.
  463. func (e ClusterSpecifierPluginValidationError) Reason() string { return e.reason }
  464. // Cause function returns cause value.
  465. func (e ClusterSpecifierPluginValidationError) Cause() error { return e.cause }
  466. // Key function returns key value.
  467. func (e ClusterSpecifierPluginValidationError) Key() bool { return e.key }
  468. // ErrorName returns error name.
  469. func (e ClusterSpecifierPluginValidationError) ErrorName() string {
  470. return "ClusterSpecifierPluginValidationError"
  471. }
  472. // Error satisfies the builtin error interface
  473. func (e ClusterSpecifierPluginValidationError) Error() string {
  474. cause := ""
  475. if e.cause != nil {
  476. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  477. }
  478. key := ""
  479. if e.key {
  480. key = "key for "
  481. }
  482. return fmt.Sprintf(
  483. "invalid %sClusterSpecifierPlugin.%s: %s%s",
  484. key,
  485. e.field,
  486. e.reason,
  487. cause)
  488. }
  489. var _ error = ClusterSpecifierPluginValidationError{}
  490. var _ interface {
  491. Field() string
  492. Reason() string
  493. Key() bool
  494. Cause() error
  495. ErrorName() string
  496. } = ClusterSpecifierPluginValidationError{}
  497. // Validate checks the field values on Vhds with the rules defined in the proto
  498. // definition for this message. If any rules are violated, the first error
  499. // encountered is returned, or nil if there are no violations.
  500. func (m *Vhds) Validate() error {
  501. return m.validate(false)
  502. }
  503. // ValidateAll checks the field values on Vhds with the rules defined in the
  504. // proto definition for this message. If any rules are violated, the result is
  505. // a list of violation errors wrapped in VhdsMultiError, or nil if none found.
  506. func (m *Vhds) ValidateAll() error {
  507. return m.validate(true)
  508. }
  509. func (m *Vhds) validate(all bool) error {
  510. if m == nil {
  511. return nil
  512. }
  513. var errors []error
  514. if m.GetConfigSource() == nil {
  515. err := VhdsValidationError{
  516. field: "ConfigSource",
  517. reason: "value is required",
  518. }
  519. if !all {
  520. return err
  521. }
  522. errors = append(errors, err)
  523. }
  524. if all {
  525. switch v := interface{}(m.GetConfigSource()).(type) {
  526. case interface{ ValidateAll() error }:
  527. if err := v.ValidateAll(); err != nil {
  528. errors = append(errors, VhdsValidationError{
  529. field: "ConfigSource",
  530. reason: "embedded message failed validation",
  531. cause: err,
  532. })
  533. }
  534. case interface{ Validate() error }:
  535. if err := v.Validate(); err != nil {
  536. errors = append(errors, VhdsValidationError{
  537. field: "ConfigSource",
  538. reason: "embedded message failed validation",
  539. cause: err,
  540. })
  541. }
  542. }
  543. } else if v, ok := interface{}(m.GetConfigSource()).(interface{ Validate() error }); ok {
  544. if err := v.Validate(); err != nil {
  545. return VhdsValidationError{
  546. field: "ConfigSource",
  547. reason: "embedded message failed validation",
  548. cause: err,
  549. }
  550. }
  551. }
  552. if len(errors) > 0 {
  553. return VhdsMultiError(errors)
  554. }
  555. return nil
  556. }
  557. // VhdsMultiError is an error wrapping multiple validation errors returned by
  558. // Vhds.ValidateAll() if the designated constraints aren't met.
  559. type VhdsMultiError []error
  560. // Error returns a concatenation of all the error messages it wraps.
  561. func (m VhdsMultiError) Error() string {
  562. var msgs []string
  563. for _, err := range m {
  564. msgs = append(msgs, err.Error())
  565. }
  566. return strings.Join(msgs, "; ")
  567. }
  568. // AllErrors returns a list of validation violation errors.
  569. func (m VhdsMultiError) AllErrors() []error { return m }
  570. // VhdsValidationError is the validation error returned by Vhds.Validate if the
  571. // designated constraints aren't met.
  572. type VhdsValidationError struct {
  573. field string
  574. reason string
  575. cause error
  576. key bool
  577. }
  578. // Field function returns field value.
  579. func (e VhdsValidationError) Field() string { return e.field }
  580. // Reason function returns reason value.
  581. func (e VhdsValidationError) Reason() string { return e.reason }
  582. // Cause function returns cause value.
  583. func (e VhdsValidationError) Cause() error { return e.cause }
  584. // Key function returns key value.
  585. func (e VhdsValidationError) Key() bool { return e.key }
  586. // ErrorName returns error name.
  587. func (e VhdsValidationError) ErrorName() string { return "VhdsValidationError" }
  588. // Error satisfies the builtin error interface
  589. func (e VhdsValidationError) Error() string {
  590. cause := ""
  591. if e.cause != nil {
  592. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  593. }
  594. key := ""
  595. if e.key {
  596. key = "key for "
  597. }
  598. return fmt.Sprintf(
  599. "invalid %sVhds.%s: %s%s",
  600. key,
  601. e.field,
  602. e.reason,
  603. cause)
  604. }
  605. var _ error = VhdsValidationError{}
  606. var _ interface {
  607. Field() string
  608. Reason() string
  609. Key() bool
  610. Cause() error
  611. ErrorName() string
  612. } = VhdsValidationError{}