/vendor/github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/fault/v3/fault.pb.validate.go

https://github.com/cloudfoundry/bosh-cli · Go · 591 lines · 434 code · 86 blank · 71 comment · 97 complexity · 7c386adbe54db8745b38d577c53fdd28 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/http/fault/v3/fault.proto
  3. package envoy_extensions_filters_http_fault_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 FaultAbort with the rules defined in the
  34. // proto definition for this message. If any rules are violated, the first
  35. // error encountered is returned, or nil if there are no violations.
  36. func (m *FaultAbort) Validate() error {
  37. return m.validate(false)
  38. }
  39. // ValidateAll checks the field values on FaultAbort with the rules defined in
  40. // the proto definition for this message. If any rules are violated, the
  41. // result is a list of violation errors wrapped in FaultAbortMultiError, or
  42. // nil if none found.
  43. func (m *FaultAbort) ValidateAll() error {
  44. return m.validate(true)
  45. }
  46. func (m *FaultAbort) validate(all bool) error {
  47. if m == nil {
  48. return nil
  49. }
  50. var errors []error
  51. if all {
  52. switch v := interface{}(m.GetPercentage()).(type) {
  53. case interface{ ValidateAll() error }:
  54. if err := v.ValidateAll(); err != nil {
  55. errors = append(errors, FaultAbortValidationError{
  56. field: "Percentage",
  57. reason: "embedded message failed validation",
  58. cause: err,
  59. })
  60. }
  61. case interface{ Validate() error }:
  62. if err := v.Validate(); err != nil {
  63. errors = append(errors, FaultAbortValidationError{
  64. field: "Percentage",
  65. reason: "embedded message failed validation",
  66. cause: err,
  67. })
  68. }
  69. }
  70. } else if v, ok := interface{}(m.GetPercentage()).(interface{ Validate() error }); ok {
  71. if err := v.Validate(); err != nil {
  72. return FaultAbortValidationError{
  73. field: "Percentage",
  74. reason: "embedded message failed validation",
  75. cause: err,
  76. }
  77. }
  78. }
  79. switch m.ErrorType.(type) {
  80. case *FaultAbort_HttpStatus:
  81. if val := m.GetHttpStatus(); val < 200 || val >= 600 {
  82. err := FaultAbortValidationError{
  83. field: "HttpStatus",
  84. reason: "value must be inside range [200, 600)",
  85. }
  86. if !all {
  87. return err
  88. }
  89. errors = append(errors, err)
  90. }
  91. case *FaultAbort_GrpcStatus:
  92. // no validation rules for GrpcStatus
  93. case *FaultAbort_HeaderAbort_:
  94. if all {
  95. switch v := interface{}(m.GetHeaderAbort()).(type) {
  96. case interface{ ValidateAll() error }:
  97. if err := v.ValidateAll(); err != nil {
  98. errors = append(errors, FaultAbortValidationError{
  99. field: "HeaderAbort",
  100. reason: "embedded message failed validation",
  101. cause: err,
  102. })
  103. }
  104. case interface{ Validate() error }:
  105. if err := v.Validate(); err != nil {
  106. errors = append(errors, FaultAbortValidationError{
  107. field: "HeaderAbort",
  108. reason: "embedded message failed validation",
  109. cause: err,
  110. })
  111. }
  112. }
  113. } else if v, ok := interface{}(m.GetHeaderAbort()).(interface{ Validate() error }); ok {
  114. if err := v.Validate(); err != nil {
  115. return FaultAbortValidationError{
  116. field: "HeaderAbort",
  117. reason: "embedded message failed validation",
  118. cause: err,
  119. }
  120. }
  121. }
  122. default:
  123. err := FaultAbortValidationError{
  124. field: "ErrorType",
  125. reason: "value is required",
  126. }
  127. if !all {
  128. return err
  129. }
  130. errors = append(errors, err)
  131. }
  132. if len(errors) > 0 {
  133. return FaultAbortMultiError(errors)
  134. }
  135. return nil
  136. }
  137. // FaultAbortMultiError is an error wrapping multiple validation errors
  138. // returned by FaultAbort.ValidateAll() if the designated constraints aren't met.
  139. type FaultAbortMultiError []error
  140. // Error returns a concatenation of all the error messages it wraps.
  141. func (m FaultAbortMultiError) Error() string {
  142. var msgs []string
  143. for _, err := range m {
  144. msgs = append(msgs, err.Error())
  145. }
  146. return strings.Join(msgs, "; ")
  147. }
  148. // AllErrors returns a list of validation violation errors.
  149. func (m FaultAbortMultiError) AllErrors() []error { return m }
  150. // FaultAbortValidationError is the validation error returned by
  151. // FaultAbort.Validate if the designated constraints aren't met.
  152. type FaultAbortValidationError struct {
  153. field string
  154. reason string
  155. cause error
  156. key bool
  157. }
  158. // Field function returns field value.
  159. func (e FaultAbortValidationError) Field() string { return e.field }
  160. // Reason function returns reason value.
  161. func (e FaultAbortValidationError) Reason() string { return e.reason }
  162. // Cause function returns cause value.
  163. func (e FaultAbortValidationError) Cause() error { return e.cause }
  164. // Key function returns key value.
  165. func (e FaultAbortValidationError) Key() bool { return e.key }
  166. // ErrorName returns error name.
  167. func (e FaultAbortValidationError) ErrorName() string { return "FaultAbortValidationError" }
  168. // Error satisfies the builtin error interface
  169. func (e FaultAbortValidationError) Error() string {
  170. cause := ""
  171. if e.cause != nil {
  172. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  173. }
  174. key := ""
  175. if e.key {
  176. key = "key for "
  177. }
  178. return fmt.Sprintf(
  179. "invalid %sFaultAbort.%s: %s%s",
  180. key,
  181. e.field,
  182. e.reason,
  183. cause)
  184. }
  185. var _ error = FaultAbortValidationError{}
  186. var _ interface {
  187. Field() string
  188. Reason() string
  189. Key() bool
  190. Cause() error
  191. ErrorName() string
  192. } = FaultAbortValidationError{}
  193. // Validate checks the field values on HTTPFault with the rules defined in the
  194. // proto definition for this message. If any rules are violated, the first
  195. // error encountered is returned, or nil if there are no violations.
  196. func (m *HTTPFault) Validate() error {
  197. return m.validate(false)
  198. }
  199. // ValidateAll checks the field values on HTTPFault with the rules defined in
  200. // the proto definition for this message. If any rules are violated, the
  201. // result is a list of violation errors wrapped in HTTPFaultMultiError, or nil
  202. // if none found.
  203. func (m *HTTPFault) ValidateAll() error {
  204. return m.validate(true)
  205. }
  206. func (m *HTTPFault) validate(all bool) error {
  207. if m == nil {
  208. return nil
  209. }
  210. var errors []error
  211. if all {
  212. switch v := interface{}(m.GetDelay()).(type) {
  213. case interface{ ValidateAll() error }:
  214. if err := v.ValidateAll(); err != nil {
  215. errors = append(errors, HTTPFaultValidationError{
  216. field: "Delay",
  217. reason: "embedded message failed validation",
  218. cause: err,
  219. })
  220. }
  221. case interface{ Validate() error }:
  222. if err := v.Validate(); err != nil {
  223. errors = append(errors, HTTPFaultValidationError{
  224. field: "Delay",
  225. reason: "embedded message failed validation",
  226. cause: err,
  227. })
  228. }
  229. }
  230. } else if v, ok := interface{}(m.GetDelay()).(interface{ Validate() error }); ok {
  231. if err := v.Validate(); err != nil {
  232. return HTTPFaultValidationError{
  233. field: "Delay",
  234. reason: "embedded message failed validation",
  235. cause: err,
  236. }
  237. }
  238. }
  239. if all {
  240. switch v := interface{}(m.GetAbort()).(type) {
  241. case interface{ ValidateAll() error }:
  242. if err := v.ValidateAll(); err != nil {
  243. errors = append(errors, HTTPFaultValidationError{
  244. field: "Abort",
  245. reason: "embedded message failed validation",
  246. cause: err,
  247. })
  248. }
  249. case interface{ Validate() error }:
  250. if err := v.Validate(); err != nil {
  251. errors = append(errors, HTTPFaultValidationError{
  252. field: "Abort",
  253. reason: "embedded message failed validation",
  254. cause: err,
  255. })
  256. }
  257. }
  258. } else if v, ok := interface{}(m.GetAbort()).(interface{ Validate() error }); ok {
  259. if err := v.Validate(); err != nil {
  260. return HTTPFaultValidationError{
  261. field: "Abort",
  262. reason: "embedded message failed validation",
  263. cause: err,
  264. }
  265. }
  266. }
  267. // no validation rules for UpstreamCluster
  268. for idx, item := range m.GetHeaders() {
  269. _, _ = idx, item
  270. if all {
  271. switch v := interface{}(item).(type) {
  272. case interface{ ValidateAll() error }:
  273. if err := v.ValidateAll(); err != nil {
  274. errors = append(errors, HTTPFaultValidationError{
  275. field: fmt.Sprintf("Headers[%v]", idx),
  276. reason: "embedded message failed validation",
  277. cause: err,
  278. })
  279. }
  280. case interface{ Validate() error }:
  281. if err := v.Validate(); err != nil {
  282. errors = append(errors, HTTPFaultValidationError{
  283. field: fmt.Sprintf("Headers[%v]", idx),
  284. reason: "embedded message failed validation",
  285. cause: err,
  286. })
  287. }
  288. }
  289. } else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  290. if err := v.Validate(); err != nil {
  291. return HTTPFaultValidationError{
  292. field: fmt.Sprintf("Headers[%v]", idx),
  293. reason: "embedded message failed validation",
  294. cause: err,
  295. }
  296. }
  297. }
  298. }
  299. if all {
  300. switch v := interface{}(m.GetMaxActiveFaults()).(type) {
  301. case interface{ ValidateAll() error }:
  302. if err := v.ValidateAll(); err != nil {
  303. errors = append(errors, HTTPFaultValidationError{
  304. field: "MaxActiveFaults",
  305. reason: "embedded message failed validation",
  306. cause: err,
  307. })
  308. }
  309. case interface{ Validate() error }:
  310. if err := v.Validate(); err != nil {
  311. errors = append(errors, HTTPFaultValidationError{
  312. field: "MaxActiveFaults",
  313. reason: "embedded message failed validation",
  314. cause: err,
  315. })
  316. }
  317. }
  318. } else if v, ok := interface{}(m.GetMaxActiveFaults()).(interface{ Validate() error }); ok {
  319. if err := v.Validate(); err != nil {
  320. return HTTPFaultValidationError{
  321. field: "MaxActiveFaults",
  322. reason: "embedded message failed validation",
  323. cause: err,
  324. }
  325. }
  326. }
  327. if all {
  328. switch v := interface{}(m.GetResponseRateLimit()).(type) {
  329. case interface{ ValidateAll() error }:
  330. if err := v.ValidateAll(); err != nil {
  331. errors = append(errors, HTTPFaultValidationError{
  332. field: "ResponseRateLimit",
  333. reason: "embedded message failed validation",
  334. cause: err,
  335. })
  336. }
  337. case interface{ Validate() error }:
  338. if err := v.Validate(); err != nil {
  339. errors = append(errors, HTTPFaultValidationError{
  340. field: "ResponseRateLimit",
  341. reason: "embedded message failed validation",
  342. cause: err,
  343. })
  344. }
  345. }
  346. } else if v, ok := interface{}(m.GetResponseRateLimit()).(interface{ Validate() error }); ok {
  347. if err := v.Validate(); err != nil {
  348. return HTTPFaultValidationError{
  349. field: "ResponseRateLimit",
  350. reason: "embedded message failed validation",
  351. cause: err,
  352. }
  353. }
  354. }
  355. // no validation rules for DelayPercentRuntime
  356. // no validation rules for AbortPercentRuntime
  357. // no validation rules for DelayDurationRuntime
  358. // no validation rules for AbortHttpStatusRuntime
  359. // no validation rules for MaxActiveFaultsRuntime
  360. // no validation rules for ResponseRateLimitPercentRuntime
  361. // no validation rules for AbortGrpcStatusRuntime
  362. // no validation rules for DisableDownstreamClusterStats
  363. if len(errors) > 0 {
  364. return HTTPFaultMultiError(errors)
  365. }
  366. return nil
  367. }
  368. // HTTPFaultMultiError is an error wrapping multiple validation errors returned
  369. // by HTTPFault.ValidateAll() if the designated constraints aren't met.
  370. type HTTPFaultMultiError []error
  371. // Error returns a concatenation of all the error messages it wraps.
  372. func (m HTTPFaultMultiError) Error() string {
  373. var msgs []string
  374. for _, err := range m {
  375. msgs = append(msgs, err.Error())
  376. }
  377. return strings.Join(msgs, "; ")
  378. }
  379. // AllErrors returns a list of validation violation errors.
  380. func (m HTTPFaultMultiError) AllErrors() []error { return m }
  381. // HTTPFaultValidationError is the validation error returned by
  382. // HTTPFault.Validate if the designated constraints aren't met.
  383. type HTTPFaultValidationError struct {
  384. field string
  385. reason string
  386. cause error
  387. key bool
  388. }
  389. // Field function returns field value.
  390. func (e HTTPFaultValidationError) Field() string { return e.field }
  391. // Reason function returns reason value.
  392. func (e HTTPFaultValidationError) Reason() string { return e.reason }
  393. // Cause function returns cause value.
  394. func (e HTTPFaultValidationError) Cause() error { return e.cause }
  395. // Key function returns key value.
  396. func (e HTTPFaultValidationError) Key() bool { return e.key }
  397. // ErrorName returns error name.
  398. func (e HTTPFaultValidationError) ErrorName() string { return "HTTPFaultValidationError" }
  399. // Error satisfies the builtin error interface
  400. func (e HTTPFaultValidationError) Error() string {
  401. cause := ""
  402. if e.cause != nil {
  403. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  404. }
  405. key := ""
  406. if e.key {
  407. key = "key for "
  408. }
  409. return fmt.Sprintf(
  410. "invalid %sHTTPFault.%s: %s%s",
  411. key,
  412. e.field,
  413. e.reason,
  414. cause)
  415. }
  416. var _ error = HTTPFaultValidationError{}
  417. var _ interface {
  418. Field() string
  419. Reason() string
  420. Key() bool
  421. Cause() error
  422. ErrorName() string
  423. } = HTTPFaultValidationError{}
  424. // Validate checks the field values on FaultAbort_HeaderAbort with the rules
  425. // defined in the proto definition for this message. If any rules are
  426. // violated, the first error encountered is returned, or nil if there are no violations.
  427. func (m *FaultAbort_HeaderAbort) Validate() error {
  428. return m.validate(false)
  429. }
  430. // ValidateAll checks the field values on FaultAbort_HeaderAbort with the rules
  431. // defined in the proto definition for this message. If any rules are
  432. // violated, the result is a list of violation errors wrapped in
  433. // FaultAbort_HeaderAbortMultiError, or nil if none found.
  434. func (m *FaultAbort_HeaderAbort) ValidateAll() error {
  435. return m.validate(true)
  436. }
  437. func (m *FaultAbort_HeaderAbort) validate(all bool) error {
  438. if m == nil {
  439. return nil
  440. }
  441. var errors []error
  442. if len(errors) > 0 {
  443. return FaultAbort_HeaderAbortMultiError(errors)
  444. }
  445. return nil
  446. }
  447. // FaultAbort_HeaderAbortMultiError is an error wrapping multiple validation
  448. // errors returned by FaultAbort_HeaderAbort.ValidateAll() if the designated
  449. // constraints aren't met.
  450. type FaultAbort_HeaderAbortMultiError []error
  451. // Error returns a concatenation of all the error messages it wraps.
  452. func (m FaultAbort_HeaderAbortMultiError) Error() string {
  453. var msgs []string
  454. for _, err := range m {
  455. msgs = append(msgs, err.Error())
  456. }
  457. return strings.Join(msgs, "; ")
  458. }
  459. // AllErrors returns a list of validation violation errors.
  460. func (m FaultAbort_HeaderAbortMultiError) AllErrors() []error { return m }
  461. // FaultAbort_HeaderAbortValidationError is the validation error returned by
  462. // FaultAbort_HeaderAbort.Validate if the designated constraints aren't met.
  463. type FaultAbort_HeaderAbortValidationError struct {
  464. field string
  465. reason string
  466. cause error
  467. key bool
  468. }
  469. // Field function returns field value.
  470. func (e FaultAbort_HeaderAbortValidationError) Field() string { return e.field }
  471. // Reason function returns reason value.
  472. func (e FaultAbort_HeaderAbortValidationError) Reason() string { return e.reason }
  473. // Cause function returns cause value.
  474. func (e FaultAbort_HeaderAbortValidationError) Cause() error { return e.cause }
  475. // Key function returns key value.
  476. func (e FaultAbort_HeaderAbortValidationError) Key() bool { return e.key }
  477. // ErrorName returns error name.
  478. func (e FaultAbort_HeaderAbortValidationError) ErrorName() string {
  479. return "FaultAbort_HeaderAbortValidationError"
  480. }
  481. // Error satisfies the builtin error interface
  482. func (e FaultAbort_HeaderAbortValidationError) Error() string {
  483. cause := ""
  484. if e.cause != nil {
  485. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  486. }
  487. key := ""
  488. if e.key {
  489. key = "key for "
  490. }
  491. return fmt.Sprintf(
  492. "invalid %sFaultAbort_HeaderAbort.%s: %s%s",
  493. key,
  494. e.field,
  495. e.reason,
  496. cause)
  497. }
  498. var _ error = FaultAbort_HeaderAbortValidationError{}
  499. var _ interface {
  500. Field() string
  501. Reason() string
  502. Key() bool
  503. Cause() error
  504. ErrorName() string
  505. } = FaultAbort_HeaderAbortValidationError{}