/pkg/api/envoy/extensions/transport_sockets/tls/v4alpha/tls.pb.validate.go

https://github.com/datawire/ambassador · Go · 684 lines · 497 code · 122 blank · 65 comment · 101 complexity · 11a462e2fbe5222e7fef0e878dd4497a MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/transport_sockets/tls/v4alpha/tls.proto
  3. package envoy_extensions_transport_sockets_tls_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 _tls_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 UpstreamTlsContext with the rules
  34. // defined in the proto definition for this message. If any rules are
  35. // violated, an error is returned.
  36. func (m *UpstreamTlsContext) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if v, ok := interface{}(m.GetCommonTlsContext()).(interface{ Validate() error }); ok {
  41. if err := v.Validate(); err != nil {
  42. return UpstreamTlsContextValidationError{
  43. field: "CommonTlsContext",
  44. reason: "embedded message failed validation",
  45. cause: err,
  46. }
  47. }
  48. }
  49. if len(m.GetSni()) > 255 {
  50. return UpstreamTlsContextValidationError{
  51. field: "Sni",
  52. reason: "value length must be at most 255 bytes",
  53. }
  54. }
  55. // no validation rules for AllowRenegotiation
  56. if v, ok := interface{}(m.GetMaxSessionKeys()).(interface{ Validate() error }); ok {
  57. if err := v.Validate(); err != nil {
  58. return UpstreamTlsContextValidationError{
  59. field: "MaxSessionKeys",
  60. reason: "embedded message failed validation",
  61. cause: err,
  62. }
  63. }
  64. }
  65. return nil
  66. }
  67. // UpstreamTlsContextValidationError is the validation error returned by
  68. // UpstreamTlsContext.Validate if the designated constraints aren't met.
  69. type UpstreamTlsContextValidationError struct {
  70. field string
  71. reason string
  72. cause error
  73. key bool
  74. }
  75. // Field function returns field value.
  76. func (e UpstreamTlsContextValidationError) Field() string { return e.field }
  77. // Reason function returns reason value.
  78. func (e UpstreamTlsContextValidationError) Reason() string { return e.reason }
  79. // Cause function returns cause value.
  80. func (e UpstreamTlsContextValidationError) Cause() error { return e.cause }
  81. // Key function returns key value.
  82. func (e UpstreamTlsContextValidationError) Key() bool { return e.key }
  83. // ErrorName returns error name.
  84. func (e UpstreamTlsContextValidationError) ErrorName() string {
  85. return "UpstreamTlsContextValidationError"
  86. }
  87. // Error satisfies the builtin error interface
  88. func (e UpstreamTlsContextValidationError) 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 %sUpstreamTlsContext.%s: %s%s",
  99. key,
  100. e.field,
  101. e.reason,
  102. cause)
  103. }
  104. var _ error = UpstreamTlsContextValidationError{}
  105. var _ interface {
  106. Field() string
  107. Reason() string
  108. Key() bool
  109. Cause() error
  110. ErrorName() string
  111. } = UpstreamTlsContextValidationError{}
  112. // Validate checks the field values on DownstreamTlsContext with the rules
  113. // defined in the proto definition for this message. If any rules are
  114. // violated, an error is returned.
  115. func (m *DownstreamTlsContext) Validate() error {
  116. if m == nil {
  117. return nil
  118. }
  119. if v, ok := interface{}(m.GetCommonTlsContext()).(interface{ Validate() error }); ok {
  120. if err := v.Validate(); err != nil {
  121. return DownstreamTlsContextValidationError{
  122. field: "CommonTlsContext",
  123. reason: "embedded message failed validation",
  124. cause: err,
  125. }
  126. }
  127. }
  128. if v, ok := interface{}(m.GetRequireClientCertificate()).(interface{ Validate() error }); ok {
  129. if err := v.Validate(); err != nil {
  130. return DownstreamTlsContextValidationError{
  131. field: "RequireClientCertificate",
  132. reason: "embedded message failed validation",
  133. cause: err,
  134. }
  135. }
  136. }
  137. if v, ok := interface{}(m.GetRequireSni()).(interface{ Validate() error }); ok {
  138. if err := v.Validate(); err != nil {
  139. return DownstreamTlsContextValidationError{
  140. field: "RequireSni",
  141. reason: "embedded message failed validation",
  142. cause: err,
  143. }
  144. }
  145. }
  146. if d := m.GetSessionTimeout(); d != nil {
  147. dur, err := ptypes.Duration(d)
  148. if err != nil {
  149. return DownstreamTlsContextValidationError{
  150. field: "SessionTimeout",
  151. reason: "value is not a valid duration",
  152. cause: err,
  153. }
  154. }
  155. lt := time.Duration(4294967296*time.Second + 0*time.Nanosecond)
  156. gte := time.Duration(0*time.Second + 0*time.Nanosecond)
  157. if dur < gte || dur >= lt {
  158. return DownstreamTlsContextValidationError{
  159. field: "SessionTimeout",
  160. reason: "value must be inside range [0s, 1193046h28m16s)",
  161. }
  162. }
  163. }
  164. switch m.SessionTicketKeysType.(type) {
  165. case *DownstreamTlsContext_SessionTicketKeys:
  166. if v, ok := interface{}(m.GetSessionTicketKeys()).(interface{ Validate() error }); ok {
  167. if err := v.Validate(); err != nil {
  168. return DownstreamTlsContextValidationError{
  169. field: "SessionTicketKeys",
  170. reason: "embedded message failed validation",
  171. cause: err,
  172. }
  173. }
  174. }
  175. case *DownstreamTlsContext_SessionTicketKeysSdsSecretConfig:
  176. if v, ok := interface{}(m.GetSessionTicketKeysSdsSecretConfig()).(interface{ Validate() error }); ok {
  177. if err := v.Validate(); err != nil {
  178. return DownstreamTlsContextValidationError{
  179. field: "SessionTicketKeysSdsSecretConfig",
  180. reason: "embedded message failed validation",
  181. cause: err,
  182. }
  183. }
  184. }
  185. case *DownstreamTlsContext_DisableStatelessSessionResumption:
  186. // no validation rules for DisableStatelessSessionResumption
  187. }
  188. return nil
  189. }
  190. // DownstreamTlsContextValidationError is the validation error returned by
  191. // DownstreamTlsContext.Validate if the designated constraints aren't met.
  192. type DownstreamTlsContextValidationError struct {
  193. field string
  194. reason string
  195. cause error
  196. key bool
  197. }
  198. // Field function returns field value.
  199. func (e DownstreamTlsContextValidationError) Field() string { return e.field }
  200. // Reason function returns reason value.
  201. func (e DownstreamTlsContextValidationError) Reason() string { return e.reason }
  202. // Cause function returns cause value.
  203. func (e DownstreamTlsContextValidationError) Cause() error { return e.cause }
  204. // Key function returns key value.
  205. func (e DownstreamTlsContextValidationError) Key() bool { return e.key }
  206. // ErrorName returns error name.
  207. func (e DownstreamTlsContextValidationError) ErrorName() string {
  208. return "DownstreamTlsContextValidationError"
  209. }
  210. // Error satisfies the builtin error interface
  211. func (e DownstreamTlsContextValidationError) Error() string {
  212. cause := ""
  213. if e.cause != nil {
  214. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  215. }
  216. key := ""
  217. if e.key {
  218. key = "key for "
  219. }
  220. return fmt.Sprintf(
  221. "invalid %sDownstreamTlsContext.%s: %s%s",
  222. key,
  223. e.field,
  224. e.reason,
  225. cause)
  226. }
  227. var _ error = DownstreamTlsContextValidationError{}
  228. var _ interface {
  229. Field() string
  230. Reason() string
  231. Key() bool
  232. Cause() error
  233. ErrorName() string
  234. } = DownstreamTlsContextValidationError{}
  235. // Validate checks the field values on CommonTlsContext with the rules defined
  236. // in the proto definition for this message. If any rules are violated, an
  237. // error is returned.
  238. func (m *CommonTlsContext) Validate() error {
  239. if m == nil {
  240. return nil
  241. }
  242. if v, ok := interface{}(m.GetTlsParams()).(interface{ Validate() error }); ok {
  243. if err := v.Validate(); err != nil {
  244. return CommonTlsContextValidationError{
  245. field: "TlsParams",
  246. reason: "embedded message failed validation",
  247. cause: err,
  248. }
  249. }
  250. }
  251. for idx, item := range m.GetTlsCertificates() {
  252. _, _ = idx, item
  253. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  254. if err := v.Validate(); err != nil {
  255. return CommonTlsContextValidationError{
  256. field: fmt.Sprintf("TlsCertificates[%v]", idx),
  257. reason: "embedded message failed validation",
  258. cause: err,
  259. }
  260. }
  261. }
  262. }
  263. if len(m.GetTlsCertificateSdsSecretConfigs()) > 1 {
  264. return CommonTlsContextValidationError{
  265. field: "TlsCertificateSdsSecretConfigs",
  266. reason: "value must contain no more than 1 item(s)",
  267. }
  268. }
  269. for idx, item := range m.GetTlsCertificateSdsSecretConfigs() {
  270. _, _ = idx, item
  271. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  272. if err := v.Validate(); err != nil {
  273. return CommonTlsContextValidationError{
  274. field: fmt.Sprintf("TlsCertificateSdsSecretConfigs[%v]", idx),
  275. reason: "embedded message failed validation",
  276. cause: err,
  277. }
  278. }
  279. }
  280. }
  281. if v, ok := interface{}(m.GetTlsCertificateCertificateProvider()).(interface{ Validate() error }); ok {
  282. if err := v.Validate(); err != nil {
  283. return CommonTlsContextValidationError{
  284. field: "TlsCertificateCertificateProvider",
  285. reason: "embedded message failed validation",
  286. cause: err,
  287. }
  288. }
  289. }
  290. switch m.ValidationContextType.(type) {
  291. case *CommonTlsContext_ValidationContext:
  292. if v, ok := interface{}(m.GetValidationContext()).(interface{ Validate() error }); ok {
  293. if err := v.Validate(); err != nil {
  294. return CommonTlsContextValidationError{
  295. field: "ValidationContext",
  296. reason: "embedded message failed validation",
  297. cause: err,
  298. }
  299. }
  300. }
  301. case *CommonTlsContext_ValidationContextSdsSecretConfig:
  302. if v, ok := interface{}(m.GetValidationContextSdsSecretConfig()).(interface{ Validate() error }); ok {
  303. if err := v.Validate(); err != nil {
  304. return CommonTlsContextValidationError{
  305. field: "ValidationContextSdsSecretConfig",
  306. reason: "embedded message failed validation",
  307. cause: err,
  308. }
  309. }
  310. }
  311. case *CommonTlsContext_CombinedValidationContext:
  312. if v, ok := interface{}(m.GetCombinedValidationContext()).(interface{ Validate() error }); ok {
  313. if err := v.Validate(); err != nil {
  314. return CommonTlsContextValidationError{
  315. field: "CombinedValidationContext",
  316. reason: "embedded message failed validation",
  317. cause: err,
  318. }
  319. }
  320. }
  321. case *CommonTlsContext_ValidationContextCertificateProvider:
  322. if v, ok := interface{}(m.GetValidationContextCertificateProvider()).(interface{ Validate() error }); ok {
  323. if err := v.Validate(); err != nil {
  324. return CommonTlsContextValidationError{
  325. field: "ValidationContextCertificateProvider",
  326. reason: "embedded message failed validation",
  327. cause: err,
  328. }
  329. }
  330. }
  331. }
  332. return nil
  333. }
  334. // CommonTlsContextValidationError is the validation error returned by
  335. // CommonTlsContext.Validate if the designated constraints aren't met.
  336. type CommonTlsContextValidationError struct {
  337. field string
  338. reason string
  339. cause error
  340. key bool
  341. }
  342. // Field function returns field value.
  343. func (e CommonTlsContextValidationError) Field() string { return e.field }
  344. // Reason function returns reason value.
  345. func (e CommonTlsContextValidationError) Reason() string { return e.reason }
  346. // Cause function returns cause value.
  347. func (e CommonTlsContextValidationError) Cause() error { return e.cause }
  348. // Key function returns key value.
  349. func (e CommonTlsContextValidationError) Key() bool { return e.key }
  350. // ErrorName returns error name.
  351. func (e CommonTlsContextValidationError) ErrorName() string { return "CommonTlsContextValidationError" }
  352. // Error satisfies the builtin error interface
  353. func (e CommonTlsContextValidationError) Error() string {
  354. cause := ""
  355. if e.cause != nil {
  356. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  357. }
  358. key := ""
  359. if e.key {
  360. key = "key for "
  361. }
  362. return fmt.Sprintf(
  363. "invalid %sCommonTlsContext.%s: %s%s",
  364. key,
  365. e.field,
  366. e.reason,
  367. cause)
  368. }
  369. var _ error = CommonTlsContextValidationError{}
  370. var _ interface {
  371. Field() string
  372. Reason() string
  373. Key() bool
  374. Cause() error
  375. ErrorName() string
  376. } = CommonTlsContextValidationError{}
  377. // Validate checks the field values on CommonTlsContext_CertificateProvider
  378. // with the rules defined in the proto definition for this message. If any
  379. // rules are violated, an error is returned.
  380. func (m *CommonTlsContext_CertificateProvider) Validate() error {
  381. if m == nil {
  382. return nil
  383. }
  384. if len(m.GetName()) < 1 {
  385. return CommonTlsContext_CertificateProviderValidationError{
  386. field: "Name",
  387. reason: "value length must be at least 1 bytes",
  388. }
  389. }
  390. switch m.Config.(type) {
  391. case *CommonTlsContext_CertificateProvider_TypedConfig:
  392. if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
  393. if err := v.Validate(); err != nil {
  394. return CommonTlsContext_CertificateProviderValidationError{
  395. field: "TypedConfig",
  396. reason: "embedded message failed validation",
  397. cause: err,
  398. }
  399. }
  400. }
  401. default:
  402. return CommonTlsContext_CertificateProviderValidationError{
  403. field: "Config",
  404. reason: "value is required",
  405. }
  406. }
  407. return nil
  408. }
  409. // CommonTlsContext_CertificateProviderValidationError is the validation error
  410. // returned by CommonTlsContext_CertificateProvider.Validate if the designated
  411. // constraints aren't met.
  412. type CommonTlsContext_CertificateProviderValidationError struct {
  413. field string
  414. reason string
  415. cause error
  416. key bool
  417. }
  418. // Field function returns field value.
  419. func (e CommonTlsContext_CertificateProviderValidationError) Field() string { return e.field }
  420. // Reason function returns reason value.
  421. func (e CommonTlsContext_CertificateProviderValidationError) Reason() string { return e.reason }
  422. // Cause function returns cause value.
  423. func (e CommonTlsContext_CertificateProviderValidationError) Cause() error { return e.cause }
  424. // Key function returns key value.
  425. func (e CommonTlsContext_CertificateProviderValidationError) Key() bool { return e.key }
  426. // ErrorName returns error name.
  427. func (e CommonTlsContext_CertificateProviderValidationError) ErrorName() string {
  428. return "CommonTlsContext_CertificateProviderValidationError"
  429. }
  430. // Error satisfies the builtin error interface
  431. func (e CommonTlsContext_CertificateProviderValidationError) Error() string {
  432. cause := ""
  433. if e.cause != nil {
  434. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  435. }
  436. key := ""
  437. if e.key {
  438. key = "key for "
  439. }
  440. return fmt.Sprintf(
  441. "invalid %sCommonTlsContext_CertificateProvider.%s: %s%s",
  442. key,
  443. e.field,
  444. e.reason,
  445. cause)
  446. }
  447. var _ error = CommonTlsContext_CertificateProviderValidationError{}
  448. var _ interface {
  449. Field() string
  450. Reason() string
  451. Key() bool
  452. Cause() error
  453. ErrorName() string
  454. } = CommonTlsContext_CertificateProviderValidationError{}
  455. // Validate checks the field values on
  456. // CommonTlsContext_CombinedCertificateValidationContext with the rules
  457. // defined in the proto definition for this message. If any rules are
  458. // violated, an error is returned.
  459. func (m *CommonTlsContext_CombinedCertificateValidationContext) Validate() error {
  460. if m == nil {
  461. return nil
  462. }
  463. if m.GetDefaultValidationContext() == nil {
  464. return CommonTlsContext_CombinedCertificateValidationContextValidationError{
  465. field: "DefaultValidationContext",
  466. reason: "value is required",
  467. }
  468. }
  469. if v, ok := interface{}(m.GetDefaultValidationContext()).(interface{ Validate() error }); ok {
  470. if err := v.Validate(); err != nil {
  471. return CommonTlsContext_CombinedCertificateValidationContextValidationError{
  472. field: "DefaultValidationContext",
  473. reason: "embedded message failed validation",
  474. cause: err,
  475. }
  476. }
  477. }
  478. switch m.DynamicValidationContext.(type) {
  479. case *CommonTlsContext_CombinedCertificateValidationContext_ValidationContextSdsSecretConfig:
  480. if m.GetValidationContextSdsSecretConfig() == nil {
  481. return CommonTlsContext_CombinedCertificateValidationContextValidationError{
  482. field: "ValidationContextSdsSecretConfig",
  483. reason: "value is required",
  484. }
  485. }
  486. if v, ok := interface{}(m.GetValidationContextSdsSecretConfig()).(interface{ Validate() error }); ok {
  487. if err := v.Validate(); err != nil {
  488. return CommonTlsContext_CombinedCertificateValidationContextValidationError{
  489. field: "ValidationContextSdsSecretConfig",
  490. reason: "embedded message failed validation",
  491. cause: err,
  492. }
  493. }
  494. }
  495. case *CommonTlsContext_CombinedCertificateValidationContext_ValidationContextCertificateProvider:
  496. if v, ok := interface{}(m.GetValidationContextCertificateProvider()).(interface{ Validate() error }); ok {
  497. if err := v.Validate(); err != nil {
  498. return CommonTlsContext_CombinedCertificateValidationContextValidationError{
  499. field: "ValidationContextCertificateProvider",
  500. reason: "embedded message failed validation",
  501. cause: err,
  502. }
  503. }
  504. }
  505. }
  506. return nil
  507. }
  508. // CommonTlsContext_CombinedCertificateValidationContextValidationError is the
  509. // validation error returned by
  510. // CommonTlsContext_CombinedCertificateValidationContext.Validate if the
  511. // designated constraints aren't met.
  512. type CommonTlsContext_CombinedCertificateValidationContextValidationError struct {
  513. field string
  514. reason string
  515. cause error
  516. key bool
  517. }
  518. // Field function returns field value.
  519. func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Field() string {
  520. return e.field
  521. }
  522. // Reason function returns reason value.
  523. func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Reason() string {
  524. return e.reason
  525. }
  526. // Cause function returns cause value.
  527. func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Cause() error {
  528. return e.cause
  529. }
  530. // Key function returns key value.
  531. func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Key() bool {
  532. return e.key
  533. }
  534. // ErrorName returns error name.
  535. func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) ErrorName() string {
  536. return "CommonTlsContext_CombinedCertificateValidationContextValidationError"
  537. }
  538. // Error satisfies the builtin error interface
  539. func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Error() string {
  540. cause := ""
  541. if e.cause != nil {
  542. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  543. }
  544. key := ""
  545. if e.key {
  546. key = "key for "
  547. }
  548. return fmt.Sprintf(
  549. "invalid %sCommonTlsContext_CombinedCertificateValidationContext.%s: %s%s",
  550. key,
  551. e.field,
  552. e.reason,
  553. cause)
  554. }
  555. var _ error = CommonTlsContext_CombinedCertificateValidationContextValidationError{}
  556. var _ interface {
  557. Field() string
  558. Reason() string
  559. Key() bool
  560. Cause() error
  561. ErrorName() string
  562. } = CommonTlsContext_CombinedCertificateValidationContextValidationError{}