/pkg/api/envoy/extensions/transport_sockets/tls/v3/common.pb.validate.go

https://github.com/datawire/ambassador · Go · 593 lines · 426 code · 106 blank · 61 comment · 82 complexity · ee0eb2949856f4260795dc9e9c2e079f MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/transport_sockets/tls/v3/common.proto
  3. package envoy_extensions_transport_sockets_tls_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 _common_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 TlsParameters with the rules defined in
  34. // the proto definition for this message. If any rules are violated, an error
  35. // is returned.
  36. func (m *TlsParameters) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if _, ok := TlsParameters_TlsProtocol_name[int32(m.GetTlsMinimumProtocolVersion())]; !ok {
  41. return TlsParametersValidationError{
  42. field: "TlsMinimumProtocolVersion",
  43. reason: "value must be one of the defined enum values",
  44. }
  45. }
  46. if _, ok := TlsParameters_TlsProtocol_name[int32(m.GetTlsMaximumProtocolVersion())]; !ok {
  47. return TlsParametersValidationError{
  48. field: "TlsMaximumProtocolVersion",
  49. reason: "value must be one of the defined enum values",
  50. }
  51. }
  52. return nil
  53. }
  54. // TlsParametersValidationError is the validation error returned by
  55. // TlsParameters.Validate if the designated constraints aren't met.
  56. type TlsParametersValidationError struct {
  57. field string
  58. reason string
  59. cause error
  60. key bool
  61. }
  62. // Field function returns field value.
  63. func (e TlsParametersValidationError) Field() string { return e.field }
  64. // Reason function returns reason value.
  65. func (e TlsParametersValidationError) Reason() string { return e.reason }
  66. // Cause function returns cause value.
  67. func (e TlsParametersValidationError) Cause() error { return e.cause }
  68. // Key function returns key value.
  69. func (e TlsParametersValidationError) Key() bool { return e.key }
  70. // ErrorName returns error name.
  71. func (e TlsParametersValidationError) ErrorName() string { return "TlsParametersValidationError" }
  72. // Error satisfies the builtin error interface
  73. func (e TlsParametersValidationError) Error() string {
  74. cause := ""
  75. if e.cause != nil {
  76. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  77. }
  78. key := ""
  79. if e.key {
  80. key = "key for "
  81. }
  82. return fmt.Sprintf(
  83. "invalid %sTlsParameters.%s: %s%s",
  84. key,
  85. e.field,
  86. e.reason,
  87. cause)
  88. }
  89. var _ error = TlsParametersValidationError{}
  90. var _ interface {
  91. Field() string
  92. Reason() string
  93. Key() bool
  94. Cause() error
  95. ErrorName() string
  96. } = TlsParametersValidationError{}
  97. // Validate checks the field values on PrivateKeyProvider with the rules
  98. // defined in the proto definition for this message. If any rules are
  99. // violated, an error is returned.
  100. func (m *PrivateKeyProvider) Validate() error {
  101. if m == nil {
  102. return nil
  103. }
  104. if len(m.GetProviderName()) < 1 {
  105. return PrivateKeyProviderValidationError{
  106. field: "ProviderName",
  107. reason: "value length must be at least 1 bytes",
  108. }
  109. }
  110. switch m.ConfigType.(type) {
  111. case *PrivateKeyProvider_TypedConfig:
  112. if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
  113. if err := v.Validate(); err != nil {
  114. return PrivateKeyProviderValidationError{
  115. field: "TypedConfig",
  116. reason: "embedded message failed validation",
  117. cause: err,
  118. }
  119. }
  120. }
  121. case *PrivateKeyProvider_HiddenEnvoyDeprecatedConfig:
  122. if v, ok := interface{}(m.GetHiddenEnvoyDeprecatedConfig()).(interface{ Validate() error }); ok {
  123. if err := v.Validate(); err != nil {
  124. return PrivateKeyProviderValidationError{
  125. field: "HiddenEnvoyDeprecatedConfig",
  126. reason: "embedded message failed validation",
  127. cause: err,
  128. }
  129. }
  130. }
  131. }
  132. return nil
  133. }
  134. // PrivateKeyProviderValidationError is the validation error returned by
  135. // PrivateKeyProvider.Validate if the designated constraints aren't met.
  136. type PrivateKeyProviderValidationError struct {
  137. field string
  138. reason string
  139. cause error
  140. key bool
  141. }
  142. // Field function returns field value.
  143. func (e PrivateKeyProviderValidationError) Field() string { return e.field }
  144. // Reason function returns reason value.
  145. func (e PrivateKeyProviderValidationError) Reason() string { return e.reason }
  146. // Cause function returns cause value.
  147. func (e PrivateKeyProviderValidationError) Cause() error { return e.cause }
  148. // Key function returns key value.
  149. func (e PrivateKeyProviderValidationError) Key() bool { return e.key }
  150. // ErrorName returns error name.
  151. func (e PrivateKeyProviderValidationError) ErrorName() string {
  152. return "PrivateKeyProviderValidationError"
  153. }
  154. // Error satisfies the builtin error interface
  155. func (e PrivateKeyProviderValidationError) Error() string {
  156. cause := ""
  157. if e.cause != nil {
  158. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  159. }
  160. key := ""
  161. if e.key {
  162. key = "key for "
  163. }
  164. return fmt.Sprintf(
  165. "invalid %sPrivateKeyProvider.%s: %s%s",
  166. key,
  167. e.field,
  168. e.reason,
  169. cause)
  170. }
  171. var _ error = PrivateKeyProviderValidationError{}
  172. var _ interface {
  173. Field() string
  174. Reason() string
  175. Key() bool
  176. Cause() error
  177. ErrorName() string
  178. } = PrivateKeyProviderValidationError{}
  179. // Validate checks the field values on TlsCertificate with the rules defined in
  180. // the proto definition for this message. If any rules are violated, an error
  181. // is returned.
  182. func (m *TlsCertificate) Validate() error {
  183. if m == nil {
  184. return nil
  185. }
  186. if v, ok := interface{}(m.GetCertificateChain()).(interface{ Validate() error }); ok {
  187. if err := v.Validate(); err != nil {
  188. return TlsCertificateValidationError{
  189. field: "CertificateChain",
  190. reason: "embedded message failed validation",
  191. cause: err,
  192. }
  193. }
  194. }
  195. if v, ok := interface{}(m.GetPrivateKey()).(interface{ Validate() error }); ok {
  196. if err := v.Validate(); err != nil {
  197. return TlsCertificateValidationError{
  198. field: "PrivateKey",
  199. reason: "embedded message failed validation",
  200. cause: err,
  201. }
  202. }
  203. }
  204. if v, ok := interface{}(m.GetPrivateKeyProvider()).(interface{ Validate() error }); ok {
  205. if err := v.Validate(); err != nil {
  206. return TlsCertificateValidationError{
  207. field: "PrivateKeyProvider",
  208. reason: "embedded message failed validation",
  209. cause: err,
  210. }
  211. }
  212. }
  213. if v, ok := interface{}(m.GetPassword()).(interface{ Validate() error }); ok {
  214. if err := v.Validate(); err != nil {
  215. return TlsCertificateValidationError{
  216. field: "Password",
  217. reason: "embedded message failed validation",
  218. cause: err,
  219. }
  220. }
  221. }
  222. if v, ok := interface{}(m.GetOcspStaple()).(interface{ Validate() error }); ok {
  223. if err := v.Validate(); err != nil {
  224. return TlsCertificateValidationError{
  225. field: "OcspStaple",
  226. reason: "embedded message failed validation",
  227. cause: err,
  228. }
  229. }
  230. }
  231. for idx, item := range m.GetSignedCertificateTimestamp() {
  232. _, _ = idx, item
  233. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  234. if err := v.Validate(); err != nil {
  235. return TlsCertificateValidationError{
  236. field: fmt.Sprintf("SignedCertificateTimestamp[%v]", idx),
  237. reason: "embedded message failed validation",
  238. cause: err,
  239. }
  240. }
  241. }
  242. }
  243. return nil
  244. }
  245. // TlsCertificateValidationError is the validation error returned by
  246. // TlsCertificate.Validate if the designated constraints aren't met.
  247. type TlsCertificateValidationError struct {
  248. field string
  249. reason string
  250. cause error
  251. key bool
  252. }
  253. // Field function returns field value.
  254. func (e TlsCertificateValidationError) Field() string { return e.field }
  255. // Reason function returns reason value.
  256. func (e TlsCertificateValidationError) Reason() string { return e.reason }
  257. // Cause function returns cause value.
  258. func (e TlsCertificateValidationError) Cause() error { return e.cause }
  259. // Key function returns key value.
  260. func (e TlsCertificateValidationError) Key() bool { return e.key }
  261. // ErrorName returns error name.
  262. func (e TlsCertificateValidationError) ErrorName() string { return "TlsCertificateValidationError" }
  263. // Error satisfies the builtin error interface
  264. func (e TlsCertificateValidationError) Error() string {
  265. cause := ""
  266. if e.cause != nil {
  267. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  268. }
  269. key := ""
  270. if e.key {
  271. key = "key for "
  272. }
  273. return fmt.Sprintf(
  274. "invalid %sTlsCertificate.%s: %s%s",
  275. key,
  276. e.field,
  277. e.reason,
  278. cause)
  279. }
  280. var _ error = TlsCertificateValidationError{}
  281. var _ interface {
  282. Field() string
  283. Reason() string
  284. Key() bool
  285. Cause() error
  286. ErrorName() string
  287. } = TlsCertificateValidationError{}
  288. // Validate checks the field values on TlsSessionTicketKeys with the rules
  289. // defined in the proto definition for this message. If any rules are
  290. // violated, an error is returned.
  291. func (m *TlsSessionTicketKeys) Validate() error {
  292. if m == nil {
  293. return nil
  294. }
  295. if len(m.GetKeys()) < 1 {
  296. return TlsSessionTicketKeysValidationError{
  297. field: "Keys",
  298. reason: "value must contain at least 1 item(s)",
  299. }
  300. }
  301. for idx, item := range m.GetKeys() {
  302. _, _ = idx, item
  303. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  304. if err := v.Validate(); err != nil {
  305. return TlsSessionTicketKeysValidationError{
  306. field: fmt.Sprintf("Keys[%v]", idx),
  307. reason: "embedded message failed validation",
  308. cause: err,
  309. }
  310. }
  311. }
  312. }
  313. return nil
  314. }
  315. // TlsSessionTicketKeysValidationError is the validation error returned by
  316. // TlsSessionTicketKeys.Validate if the designated constraints aren't met.
  317. type TlsSessionTicketKeysValidationError struct {
  318. field string
  319. reason string
  320. cause error
  321. key bool
  322. }
  323. // Field function returns field value.
  324. func (e TlsSessionTicketKeysValidationError) Field() string { return e.field }
  325. // Reason function returns reason value.
  326. func (e TlsSessionTicketKeysValidationError) Reason() string { return e.reason }
  327. // Cause function returns cause value.
  328. func (e TlsSessionTicketKeysValidationError) Cause() error { return e.cause }
  329. // Key function returns key value.
  330. func (e TlsSessionTicketKeysValidationError) Key() bool { return e.key }
  331. // ErrorName returns error name.
  332. func (e TlsSessionTicketKeysValidationError) ErrorName() string {
  333. return "TlsSessionTicketKeysValidationError"
  334. }
  335. // Error satisfies the builtin error interface
  336. func (e TlsSessionTicketKeysValidationError) Error() string {
  337. cause := ""
  338. if e.cause != nil {
  339. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  340. }
  341. key := ""
  342. if e.key {
  343. key = "key for "
  344. }
  345. return fmt.Sprintf(
  346. "invalid %sTlsSessionTicketKeys.%s: %s%s",
  347. key,
  348. e.field,
  349. e.reason,
  350. cause)
  351. }
  352. var _ error = TlsSessionTicketKeysValidationError{}
  353. var _ interface {
  354. Field() string
  355. Reason() string
  356. Key() bool
  357. Cause() error
  358. ErrorName() string
  359. } = TlsSessionTicketKeysValidationError{}
  360. // Validate checks the field values on CertificateValidationContext with the
  361. // rules defined in the proto definition for this message. If any rules are
  362. // violated, an error is returned.
  363. func (m *CertificateValidationContext) Validate() error {
  364. if m == nil {
  365. return nil
  366. }
  367. if v, ok := interface{}(m.GetTrustedCa()).(interface{ Validate() error }); ok {
  368. if err := v.Validate(); err != nil {
  369. return CertificateValidationContextValidationError{
  370. field: "TrustedCa",
  371. reason: "embedded message failed validation",
  372. cause: err,
  373. }
  374. }
  375. }
  376. for idx, item := range m.GetVerifyCertificateSpki() {
  377. _, _ = idx, item
  378. if len(item) != 44 {
  379. return CertificateValidationContextValidationError{
  380. field: fmt.Sprintf("VerifyCertificateSpki[%v]", idx),
  381. reason: "value length must be 44 bytes",
  382. }
  383. }
  384. }
  385. for idx, item := range m.GetVerifyCertificateHash() {
  386. _, _ = idx, item
  387. if l := len(item); l < 64 || l > 95 {
  388. return CertificateValidationContextValidationError{
  389. field: fmt.Sprintf("VerifyCertificateHash[%v]", idx),
  390. reason: "value length must be between 64 and 95 bytes, inclusive",
  391. }
  392. }
  393. }
  394. for idx, item := range m.GetMatchSubjectAltNames() {
  395. _, _ = idx, item
  396. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  397. if err := v.Validate(); err != nil {
  398. return CertificateValidationContextValidationError{
  399. field: fmt.Sprintf("MatchSubjectAltNames[%v]", idx),
  400. reason: "embedded message failed validation",
  401. cause: err,
  402. }
  403. }
  404. }
  405. }
  406. if v, ok := interface{}(m.GetRequireOcspStaple()).(interface{ Validate() error }); ok {
  407. if err := v.Validate(); err != nil {
  408. return CertificateValidationContextValidationError{
  409. field: "RequireOcspStaple",
  410. reason: "embedded message failed validation",
  411. cause: err,
  412. }
  413. }
  414. }
  415. if v, ok := interface{}(m.GetRequireSignedCertificateTimestamp()).(interface{ Validate() error }); ok {
  416. if err := v.Validate(); err != nil {
  417. return CertificateValidationContextValidationError{
  418. field: "RequireSignedCertificateTimestamp",
  419. reason: "embedded message failed validation",
  420. cause: err,
  421. }
  422. }
  423. }
  424. if v, ok := interface{}(m.GetCrl()).(interface{ Validate() error }); ok {
  425. if err := v.Validate(); err != nil {
  426. return CertificateValidationContextValidationError{
  427. field: "Crl",
  428. reason: "embedded message failed validation",
  429. cause: err,
  430. }
  431. }
  432. }
  433. // no validation rules for AllowExpiredCertificate
  434. if _, ok := CertificateValidationContext_TrustChainVerification_name[int32(m.GetTrustChainVerification())]; !ok {
  435. return CertificateValidationContextValidationError{
  436. field: "TrustChainVerification",
  437. reason: "value must be one of the defined enum values",
  438. }
  439. }
  440. return nil
  441. }
  442. // CertificateValidationContextValidationError is the validation error returned
  443. // by CertificateValidationContext.Validate if the designated constraints
  444. // aren't met.
  445. type CertificateValidationContextValidationError struct {
  446. field string
  447. reason string
  448. cause error
  449. key bool
  450. }
  451. // Field function returns field value.
  452. func (e CertificateValidationContextValidationError) Field() string { return e.field }
  453. // Reason function returns reason value.
  454. func (e CertificateValidationContextValidationError) Reason() string { return e.reason }
  455. // Cause function returns cause value.
  456. func (e CertificateValidationContextValidationError) Cause() error { return e.cause }
  457. // Key function returns key value.
  458. func (e CertificateValidationContextValidationError) Key() bool { return e.key }
  459. // ErrorName returns error name.
  460. func (e CertificateValidationContextValidationError) ErrorName() string {
  461. return "CertificateValidationContextValidationError"
  462. }
  463. // Error satisfies the builtin error interface
  464. func (e CertificateValidationContextValidationError) Error() string {
  465. cause := ""
  466. if e.cause != nil {
  467. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  468. }
  469. key := ""
  470. if e.key {
  471. key = "key for "
  472. }
  473. return fmt.Sprintf(
  474. "invalid %sCertificateValidationContext.%s: %s%s",
  475. key,
  476. e.field,
  477. e.reason,
  478. cause)
  479. }
  480. var _ error = CertificateValidationContextValidationError{}
  481. var _ interface {
  482. Field() string
  483. Reason() string
  484. Key() bool
  485. Cause() error
  486. ErrorName() string
  487. } = CertificateValidationContextValidationError{}