/vendor/github.com/envoyproxy/go-control-plane/envoy/api/v2/core/address.pb.validate.go

https://github.com/monzo/egress-operator · Go · 594 lines · 411 code · 114 blank · 69 comment · 67 complexity · f94e9b8c59e2f0c66a3fbfb49e0ca35e MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/api/v2/core/address.proto
  3. package envoy_api_v2_core
  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 _address_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 Pipe with the rules defined in the proto
  34. // definition for this message. If any rules are violated, an error is returned.
  35. func (m *Pipe) Validate() error {
  36. if m == nil {
  37. return nil
  38. }
  39. if len(m.GetPath()) < 1 {
  40. return PipeValidationError{
  41. field: "Path",
  42. reason: "value length must be at least 1 bytes",
  43. }
  44. }
  45. return nil
  46. }
  47. // PipeValidationError is the validation error returned by Pipe.Validate if the
  48. // designated constraints aren't met.
  49. type PipeValidationError struct {
  50. field string
  51. reason string
  52. cause error
  53. key bool
  54. }
  55. // Field function returns field value.
  56. func (e PipeValidationError) Field() string { return e.field }
  57. // Reason function returns reason value.
  58. func (e PipeValidationError) Reason() string { return e.reason }
  59. // Cause function returns cause value.
  60. func (e PipeValidationError) Cause() error { return e.cause }
  61. // Key function returns key value.
  62. func (e PipeValidationError) Key() bool { return e.key }
  63. // ErrorName returns error name.
  64. func (e PipeValidationError) ErrorName() string { return "PipeValidationError" }
  65. // Error satisfies the builtin error interface
  66. func (e PipeValidationError) Error() string {
  67. cause := ""
  68. if e.cause != nil {
  69. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  70. }
  71. key := ""
  72. if e.key {
  73. key = "key for "
  74. }
  75. return fmt.Sprintf(
  76. "invalid %sPipe.%s: %s%s",
  77. key,
  78. e.field,
  79. e.reason,
  80. cause)
  81. }
  82. var _ error = PipeValidationError{}
  83. var _ interface {
  84. Field() string
  85. Reason() string
  86. Key() bool
  87. Cause() error
  88. ErrorName() string
  89. } = PipeValidationError{}
  90. // Validate checks the field values on SocketAddress with the rules defined in
  91. // the proto definition for this message. If any rules are violated, an error
  92. // is returned.
  93. func (m *SocketAddress) Validate() error {
  94. if m == nil {
  95. return nil
  96. }
  97. if _, ok := SocketAddress_Protocol_name[int32(m.GetProtocol())]; !ok {
  98. return SocketAddressValidationError{
  99. field: "Protocol",
  100. reason: "value must be one of the defined enum values",
  101. }
  102. }
  103. if len(m.GetAddress()) < 1 {
  104. return SocketAddressValidationError{
  105. field: "Address",
  106. reason: "value length must be at least 1 bytes",
  107. }
  108. }
  109. // no validation rules for ResolverName
  110. // no validation rules for Ipv4Compat
  111. switch m.PortSpecifier.(type) {
  112. case *SocketAddress_PortValue:
  113. if m.GetPortValue() > 65535 {
  114. return SocketAddressValidationError{
  115. field: "PortValue",
  116. reason: "value must be less than or equal to 65535",
  117. }
  118. }
  119. case *SocketAddress_NamedPort:
  120. // no validation rules for NamedPort
  121. default:
  122. return SocketAddressValidationError{
  123. field: "PortSpecifier",
  124. reason: "value is required",
  125. }
  126. }
  127. return nil
  128. }
  129. // SocketAddressValidationError is the validation error returned by
  130. // SocketAddress.Validate if the designated constraints aren't met.
  131. type SocketAddressValidationError struct {
  132. field string
  133. reason string
  134. cause error
  135. key bool
  136. }
  137. // Field function returns field value.
  138. func (e SocketAddressValidationError) Field() string { return e.field }
  139. // Reason function returns reason value.
  140. func (e SocketAddressValidationError) Reason() string { return e.reason }
  141. // Cause function returns cause value.
  142. func (e SocketAddressValidationError) Cause() error { return e.cause }
  143. // Key function returns key value.
  144. func (e SocketAddressValidationError) Key() bool { return e.key }
  145. // ErrorName returns error name.
  146. func (e SocketAddressValidationError) ErrorName() string { return "SocketAddressValidationError" }
  147. // Error satisfies the builtin error interface
  148. func (e SocketAddressValidationError) Error() string {
  149. cause := ""
  150. if e.cause != nil {
  151. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  152. }
  153. key := ""
  154. if e.key {
  155. key = "key for "
  156. }
  157. return fmt.Sprintf(
  158. "invalid %sSocketAddress.%s: %s%s",
  159. key,
  160. e.field,
  161. e.reason,
  162. cause)
  163. }
  164. var _ error = SocketAddressValidationError{}
  165. var _ interface {
  166. Field() string
  167. Reason() string
  168. Key() bool
  169. Cause() error
  170. ErrorName() string
  171. } = SocketAddressValidationError{}
  172. // Validate checks the field values on TcpKeepalive with the rules defined in
  173. // the proto definition for this message. If any rules are violated, an error
  174. // is returned.
  175. func (m *TcpKeepalive) Validate() error {
  176. if m == nil {
  177. return nil
  178. }
  179. if v, ok := interface{}(m.GetKeepaliveProbes()).(interface{ Validate() error }); ok {
  180. if err := v.Validate(); err != nil {
  181. return TcpKeepaliveValidationError{
  182. field: "KeepaliveProbes",
  183. reason: "embedded message failed validation",
  184. cause: err,
  185. }
  186. }
  187. }
  188. if v, ok := interface{}(m.GetKeepaliveTime()).(interface{ Validate() error }); ok {
  189. if err := v.Validate(); err != nil {
  190. return TcpKeepaliveValidationError{
  191. field: "KeepaliveTime",
  192. reason: "embedded message failed validation",
  193. cause: err,
  194. }
  195. }
  196. }
  197. if v, ok := interface{}(m.GetKeepaliveInterval()).(interface{ Validate() error }); ok {
  198. if err := v.Validate(); err != nil {
  199. return TcpKeepaliveValidationError{
  200. field: "KeepaliveInterval",
  201. reason: "embedded message failed validation",
  202. cause: err,
  203. }
  204. }
  205. }
  206. return nil
  207. }
  208. // TcpKeepaliveValidationError is the validation error returned by
  209. // TcpKeepalive.Validate if the designated constraints aren't met.
  210. type TcpKeepaliveValidationError struct {
  211. field string
  212. reason string
  213. cause error
  214. key bool
  215. }
  216. // Field function returns field value.
  217. func (e TcpKeepaliveValidationError) Field() string { return e.field }
  218. // Reason function returns reason value.
  219. func (e TcpKeepaliveValidationError) Reason() string { return e.reason }
  220. // Cause function returns cause value.
  221. func (e TcpKeepaliveValidationError) Cause() error { return e.cause }
  222. // Key function returns key value.
  223. func (e TcpKeepaliveValidationError) Key() bool { return e.key }
  224. // ErrorName returns error name.
  225. func (e TcpKeepaliveValidationError) ErrorName() string { return "TcpKeepaliveValidationError" }
  226. // Error satisfies the builtin error interface
  227. func (e TcpKeepaliveValidationError) Error() string {
  228. cause := ""
  229. if e.cause != nil {
  230. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  231. }
  232. key := ""
  233. if e.key {
  234. key = "key for "
  235. }
  236. return fmt.Sprintf(
  237. "invalid %sTcpKeepalive.%s: %s%s",
  238. key,
  239. e.field,
  240. e.reason,
  241. cause)
  242. }
  243. var _ error = TcpKeepaliveValidationError{}
  244. var _ interface {
  245. Field() string
  246. Reason() string
  247. Key() bool
  248. Cause() error
  249. ErrorName() string
  250. } = TcpKeepaliveValidationError{}
  251. // Validate checks the field values on BindConfig with the rules defined in the
  252. // proto definition for this message. If any rules are violated, an error is returned.
  253. func (m *BindConfig) Validate() error {
  254. if m == nil {
  255. return nil
  256. }
  257. if m.GetSourceAddress() == nil {
  258. return BindConfigValidationError{
  259. field: "SourceAddress",
  260. reason: "value is required",
  261. }
  262. }
  263. if v, ok := interface{}(m.GetSourceAddress()).(interface{ Validate() error }); ok {
  264. if err := v.Validate(); err != nil {
  265. return BindConfigValidationError{
  266. field: "SourceAddress",
  267. reason: "embedded message failed validation",
  268. cause: err,
  269. }
  270. }
  271. }
  272. if v, ok := interface{}(m.GetFreebind()).(interface{ Validate() error }); ok {
  273. if err := v.Validate(); err != nil {
  274. return BindConfigValidationError{
  275. field: "Freebind",
  276. reason: "embedded message failed validation",
  277. cause: err,
  278. }
  279. }
  280. }
  281. for idx, item := range m.GetSocketOptions() {
  282. _, _ = idx, item
  283. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  284. if err := v.Validate(); err != nil {
  285. return BindConfigValidationError{
  286. field: fmt.Sprintf("SocketOptions[%v]", idx),
  287. reason: "embedded message failed validation",
  288. cause: err,
  289. }
  290. }
  291. }
  292. }
  293. return nil
  294. }
  295. // BindConfigValidationError is the validation error returned by
  296. // BindConfig.Validate if the designated constraints aren't met.
  297. type BindConfigValidationError struct {
  298. field string
  299. reason string
  300. cause error
  301. key bool
  302. }
  303. // Field function returns field value.
  304. func (e BindConfigValidationError) Field() string { return e.field }
  305. // Reason function returns reason value.
  306. func (e BindConfigValidationError) Reason() string { return e.reason }
  307. // Cause function returns cause value.
  308. func (e BindConfigValidationError) Cause() error { return e.cause }
  309. // Key function returns key value.
  310. func (e BindConfigValidationError) Key() bool { return e.key }
  311. // ErrorName returns error name.
  312. func (e BindConfigValidationError) ErrorName() string { return "BindConfigValidationError" }
  313. // Error satisfies the builtin error interface
  314. func (e BindConfigValidationError) Error() string {
  315. cause := ""
  316. if e.cause != nil {
  317. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  318. }
  319. key := ""
  320. if e.key {
  321. key = "key for "
  322. }
  323. return fmt.Sprintf(
  324. "invalid %sBindConfig.%s: %s%s",
  325. key,
  326. e.field,
  327. e.reason,
  328. cause)
  329. }
  330. var _ error = BindConfigValidationError{}
  331. var _ interface {
  332. Field() string
  333. Reason() string
  334. Key() bool
  335. Cause() error
  336. ErrorName() string
  337. } = BindConfigValidationError{}
  338. // Validate checks the field values on Address with the rules defined in the
  339. // proto definition for this message. If any rules are violated, an error is returned.
  340. func (m *Address) Validate() error {
  341. if m == nil {
  342. return nil
  343. }
  344. switch m.Address.(type) {
  345. case *Address_SocketAddress:
  346. if v, ok := interface{}(m.GetSocketAddress()).(interface{ Validate() error }); ok {
  347. if err := v.Validate(); err != nil {
  348. return AddressValidationError{
  349. field: "SocketAddress",
  350. reason: "embedded message failed validation",
  351. cause: err,
  352. }
  353. }
  354. }
  355. case *Address_Pipe:
  356. if v, ok := interface{}(m.GetPipe()).(interface{ Validate() error }); ok {
  357. if err := v.Validate(); err != nil {
  358. return AddressValidationError{
  359. field: "Pipe",
  360. reason: "embedded message failed validation",
  361. cause: err,
  362. }
  363. }
  364. }
  365. default:
  366. return AddressValidationError{
  367. field: "Address",
  368. reason: "value is required",
  369. }
  370. }
  371. return nil
  372. }
  373. // AddressValidationError is the validation error returned by Address.Validate
  374. // if the designated constraints aren't met.
  375. type AddressValidationError struct {
  376. field string
  377. reason string
  378. cause error
  379. key bool
  380. }
  381. // Field function returns field value.
  382. func (e AddressValidationError) Field() string { return e.field }
  383. // Reason function returns reason value.
  384. func (e AddressValidationError) Reason() string { return e.reason }
  385. // Cause function returns cause value.
  386. func (e AddressValidationError) Cause() error { return e.cause }
  387. // Key function returns key value.
  388. func (e AddressValidationError) Key() bool { return e.key }
  389. // ErrorName returns error name.
  390. func (e AddressValidationError) ErrorName() string { return "AddressValidationError" }
  391. // Error satisfies the builtin error interface
  392. func (e AddressValidationError) Error() string {
  393. cause := ""
  394. if e.cause != nil {
  395. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  396. }
  397. key := ""
  398. if e.key {
  399. key = "key for "
  400. }
  401. return fmt.Sprintf(
  402. "invalid %sAddress.%s: %s%s",
  403. key,
  404. e.field,
  405. e.reason,
  406. cause)
  407. }
  408. var _ error = AddressValidationError{}
  409. var _ interface {
  410. Field() string
  411. Reason() string
  412. Key() bool
  413. Cause() error
  414. ErrorName() string
  415. } = AddressValidationError{}
  416. // Validate checks the field values on CidrRange with the rules defined in the
  417. // proto definition for this message. If any rules are violated, an error is returned.
  418. func (m *CidrRange) Validate() error {
  419. if m == nil {
  420. return nil
  421. }
  422. if len(m.GetAddressPrefix()) < 1 {
  423. return CidrRangeValidationError{
  424. field: "AddressPrefix",
  425. reason: "value length must be at least 1 bytes",
  426. }
  427. }
  428. if wrapper := m.GetPrefixLen(); wrapper != nil {
  429. if wrapper.GetValue() > 128 {
  430. return CidrRangeValidationError{
  431. field: "PrefixLen",
  432. reason: "value must be less than or equal to 128",
  433. }
  434. }
  435. }
  436. return nil
  437. }
  438. // CidrRangeValidationError is the validation error returned by
  439. // CidrRange.Validate if the designated constraints aren't met.
  440. type CidrRangeValidationError struct {
  441. field string
  442. reason string
  443. cause error
  444. key bool
  445. }
  446. // Field function returns field value.
  447. func (e CidrRangeValidationError) Field() string { return e.field }
  448. // Reason function returns reason value.
  449. func (e CidrRangeValidationError) Reason() string { return e.reason }
  450. // Cause function returns cause value.
  451. func (e CidrRangeValidationError) Cause() error { return e.cause }
  452. // Key function returns key value.
  453. func (e CidrRangeValidationError) Key() bool { return e.key }
  454. // ErrorName returns error name.
  455. func (e CidrRangeValidationError) ErrorName() string { return "CidrRangeValidationError" }
  456. // Error satisfies the builtin error interface
  457. func (e CidrRangeValidationError) Error() string {
  458. cause := ""
  459. if e.cause != nil {
  460. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  461. }
  462. key := ""
  463. if e.key {
  464. key = "key for "
  465. }
  466. return fmt.Sprintf(
  467. "invalid %sCidrRange.%s: %s%s",
  468. key,
  469. e.field,
  470. e.reason,
  471. cause)
  472. }
  473. var _ error = CidrRangeValidationError{}
  474. var _ interface {
  475. Field() string
  476. Reason() string
  477. Key() bool
  478. Cause() error
  479. ErrorName() string
  480. } = CidrRangeValidationError{}