/pkg/api/envoy/extensions/filters/http/adaptive_concurrency/v3/adaptive_concurrency.pb.validate.go

https://github.com/datawire/ambassador · Go · 517 lines · 373 code · 90 blank · 54 comment · 71 complexity · 02d92a4ec1e941f0d375cfcc876ec7fe MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/filters/http/adaptive_concurrency/v3/adaptive_concurrency.proto
  3. package envoy_extensions_filters_http_adaptive_concurrency_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 _adaptive_concurrency_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 GradientControllerConfig 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 *GradientControllerConfig) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if v, ok := interface{}(m.GetSampleAggregatePercentile()).(interface{ Validate() error }); ok {
  41. if err := v.Validate(); err != nil {
  42. return GradientControllerConfigValidationError{
  43. field: "SampleAggregatePercentile",
  44. reason: "embedded message failed validation",
  45. cause: err,
  46. }
  47. }
  48. }
  49. if m.GetConcurrencyLimitParams() == nil {
  50. return GradientControllerConfigValidationError{
  51. field: "ConcurrencyLimitParams",
  52. reason: "value is required",
  53. }
  54. }
  55. if v, ok := interface{}(m.GetConcurrencyLimitParams()).(interface{ Validate() error }); ok {
  56. if err := v.Validate(); err != nil {
  57. return GradientControllerConfigValidationError{
  58. field: "ConcurrencyLimitParams",
  59. reason: "embedded message failed validation",
  60. cause: err,
  61. }
  62. }
  63. }
  64. if m.GetMinRttCalcParams() == nil {
  65. return GradientControllerConfigValidationError{
  66. field: "MinRttCalcParams",
  67. reason: "value is required",
  68. }
  69. }
  70. if v, ok := interface{}(m.GetMinRttCalcParams()).(interface{ Validate() error }); ok {
  71. if err := v.Validate(); err != nil {
  72. return GradientControllerConfigValidationError{
  73. field: "MinRttCalcParams",
  74. reason: "embedded message failed validation",
  75. cause: err,
  76. }
  77. }
  78. }
  79. return nil
  80. }
  81. // GradientControllerConfigValidationError is the validation error returned by
  82. // GradientControllerConfig.Validate if the designated constraints aren't met.
  83. type GradientControllerConfigValidationError struct {
  84. field string
  85. reason string
  86. cause error
  87. key bool
  88. }
  89. // Field function returns field value.
  90. func (e GradientControllerConfigValidationError) Field() string { return e.field }
  91. // Reason function returns reason value.
  92. func (e GradientControllerConfigValidationError) Reason() string { return e.reason }
  93. // Cause function returns cause value.
  94. func (e GradientControllerConfigValidationError) Cause() error { return e.cause }
  95. // Key function returns key value.
  96. func (e GradientControllerConfigValidationError) Key() bool { return e.key }
  97. // ErrorName returns error name.
  98. func (e GradientControllerConfigValidationError) ErrorName() string {
  99. return "GradientControllerConfigValidationError"
  100. }
  101. // Error satisfies the builtin error interface
  102. func (e GradientControllerConfigValidationError) Error() string {
  103. cause := ""
  104. if e.cause != nil {
  105. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  106. }
  107. key := ""
  108. if e.key {
  109. key = "key for "
  110. }
  111. return fmt.Sprintf(
  112. "invalid %sGradientControllerConfig.%s: %s%s",
  113. key,
  114. e.field,
  115. e.reason,
  116. cause)
  117. }
  118. var _ error = GradientControllerConfigValidationError{}
  119. var _ interface {
  120. Field() string
  121. Reason() string
  122. Key() bool
  123. Cause() error
  124. ErrorName() string
  125. } = GradientControllerConfigValidationError{}
  126. // Validate checks the field values on AdaptiveConcurrency with the rules
  127. // defined in the proto definition for this message. If any rules are
  128. // violated, an error is returned.
  129. func (m *AdaptiveConcurrency) Validate() error {
  130. if m == nil {
  131. return nil
  132. }
  133. if v, ok := interface{}(m.GetEnabled()).(interface{ Validate() error }); ok {
  134. if err := v.Validate(); err != nil {
  135. return AdaptiveConcurrencyValidationError{
  136. field: "Enabled",
  137. reason: "embedded message failed validation",
  138. cause: err,
  139. }
  140. }
  141. }
  142. switch m.ConcurrencyControllerConfig.(type) {
  143. case *AdaptiveConcurrency_GradientControllerConfig:
  144. if m.GetGradientControllerConfig() == nil {
  145. return AdaptiveConcurrencyValidationError{
  146. field: "GradientControllerConfig",
  147. reason: "value is required",
  148. }
  149. }
  150. if v, ok := interface{}(m.GetGradientControllerConfig()).(interface{ Validate() error }); ok {
  151. if err := v.Validate(); err != nil {
  152. return AdaptiveConcurrencyValidationError{
  153. field: "GradientControllerConfig",
  154. reason: "embedded message failed validation",
  155. cause: err,
  156. }
  157. }
  158. }
  159. default:
  160. return AdaptiveConcurrencyValidationError{
  161. field: "ConcurrencyControllerConfig",
  162. reason: "value is required",
  163. }
  164. }
  165. return nil
  166. }
  167. // AdaptiveConcurrencyValidationError is the validation error returned by
  168. // AdaptiveConcurrency.Validate if the designated constraints aren't met.
  169. type AdaptiveConcurrencyValidationError struct {
  170. field string
  171. reason string
  172. cause error
  173. key bool
  174. }
  175. // Field function returns field value.
  176. func (e AdaptiveConcurrencyValidationError) Field() string { return e.field }
  177. // Reason function returns reason value.
  178. func (e AdaptiveConcurrencyValidationError) Reason() string { return e.reason }
  179. // Cause function returns cause value.
  180. func (e AdaptiveConcurrencyValidationError) Cause() error { return e.cause }
  181. // Key function returns key value.
  182. func (e AdaptiveConcurrencyValidationError) Key() bool { return e.key }
  183. // ErrorName returns error name.
  184. func (e AdaptiveConcurrencyValidationError) ErrorName() string {
  185. return "AdaptiveConcurrencyValidationError"
  186. }
  187. // Error satisfies the builtin error interface
  188. func (e AdaptiveConcurrencyValidationError) Error() string {
  189. cause := ""
  190. if e.cause != nil {
  191. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  192. }
  193. key := ""
  194. if e.key {
  195. key = "key for "
  196. }
  197. return fmt.Sprintf(
  198. "invalid %sAdaptiveConcurrency.%s: %s%s",
  199. key,
  200. e.field,
  201. e.reason,
  202. cause)
  203. }
  204. var _ error = AdaptiveConcurrencyValidationError{}
  205. var _ interface {
  206. Field() string
  207. Reason() string
  208. Key() bool
  209. Cause() error
  210. ErrorName() string
  211. } = AdaptiveConcurrencyValidationError{}
  212. // Validate checks the field values on
  213. // GradientControllerConfig_ConcurrencyLimitCalculationParams with the rules
  214. // defined in the proto definition for this message. If any rules are
  215. // violated, an error is returned.
  216. func (m *GradientControllerConfig_ConcurrencyLimitCalculationParams) Validate() error {
  217. if m == nil {
  218. return nil
  219. }
  220. if wrapper := m.GetMaxConcurrencyLimit(); wrapper != nil {
  221. if wrapper.GetValue() <= 0 {
  222. return GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError{
  223. field: "MaxConcurrencyLimit",
  224. reason: "value must be greater than 0",
  225. }
  226. }
  227. }
  228. if m.GetConcurrencyUpdateInterval() == nil {
  229. return GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError{
  230. field: "ConcurrencyUpdateInterval",
  231. reason: "value is required",
  232. }
  233. }
  234. if d := m.GetConcurrencyUpdateInterval(); d != nil {
  235. dur, err := ptypes.Duration(d)
  236. if err != nil {
  237. return GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError{
  238. field: "ConcurrencyUpdateInterval",
  239. reason: "value is not a valid duration",
  240. cause: err,
  241. }
  242. }
  243. gt := time.Duration(0*time.Second + 0*time.Nanosecond)
  244. if dur <= gt {
  245. return GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError{
  246. field: "ConcurrencyUpdateInterval",
  247. reason: "value must be greater than 0s",
  248. }
  249. }
  250. }
  251. return nil
  252. }
  253. // GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError is
  254. // the validation error returned by
  255. // GradientControllerConfig_ConcurrencyLimitCalculationParams.Validate if the
  256. // designated constraints aren't met.
  257. type GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError struct {
  258. field string
  259. reason string
  260. cause error
  261. key bool
  262. }
  263. // Field function returns field value.
  264. func (e GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError) Field() string {
  265. return e.field
  266. }
  267. // Reason function returns reason value.
  268. func (e GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError) Reason() string {
  269. return e.reason
  270. }
  271. // Cause function returns cause value.
  272. func (e GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError) Cause() error {
  273. return e.cause
  274. }
  275. // Key function returns key value.
  276. func (e GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError) Key() bool {
  277. return e.key
  278. }
  279. // ErrorName returns error name.
  280. func (e GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError) ErrorName() string {
  281. return "GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError"
  282. }
  283. // Error satisfies the builtin error interface
  284. func (e GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError) Error() string {
  285. cause := ""
  286. if e.cause != nil {
  287. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  288. }
  289. key := ""
  290. if e.key {
  291. key = "key for "
  292. }
  293. return fmt.Sprintf(
  294. "invalid %sGradientControllerConfig_ConcurrencyLimitCalculationParams.%s: %s%s",
  295. key,
  296. e.field,
  297. e.reason,
  298. cause)
  299. }
  300. var _ error = GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError{}
  301. var _ interface {
  302. Field() string
  303. Reason() string
  304. Key() bool
  305. Cause() error
  306. ErrorName() string
  307. } = GradientControllerConfig_ConcurrencyLimitCalculationParamsValidationError{}
  308. // Validate checks the field values on
  309. // GradientControllerConfig_MinimumRTTCalculationParams with the rules defined
  310. // in the proto definition for this message. If any rules are violated, an
  311. // error is returned.
  312. func (m *GradientControllerConfig_MinimumRTTCalculationParams) Validate() error {
  313. if m == nil {
  314. return nil
  315. }
  316. if m.GetInterval() == nil {
  317. return GradientControllerConfig_MinimumRTTCalculationParamsValidationError{
  318. field: "Interval",
  319. reason: "value is required",
  320. }
  321. }
  322. if d := m.GetInterval(); d != nil {
  323. dur, err := ptypes.Duration(d)
  324. if err != nil {
  325. return GradientControllerConfig_MinimumRTTCalculationParamsValidationError{
  326. field: "Interval",
  327. reason: "value is not a valid duration",
  328. cause: err,
  329. }
  330. }
  331. gt := time.Duration(0*time.Second + 0*time.Nanosecond)
  332. if dur <= gt {
  333. return GradientControllerConfig_MinimumRTTCalculationParamsValidationError{
  334. field: "Interval",
  335. reason: "value must be greater than 0s",
  336. }
  337. }
  338. }
  339. if wrapper := m.GetRequestCount(); wrapper != nil {
  340. if wrapper.GetValue() <= 0 {
  341. return GradientControllerConfig_MinimumRTTCalculationParamsValidationError{
  342. field: "RequestCount",
  343. reason: "value must be greater than 0",
  344. }
  345. }
  346. }
  347. if v, ok := interface{}(m.GetJitter()).(interface{ Validate() error }); ok {
  348. if err := v.Validate(); err != nil {
  349. return GradientControllerConfig_MinimumRTTCalculationParamsValidationError{
  350. field: "Jitter",
  351. reason: "embedded message failed validation",
  352. cause: err,
  353. }
  354. }
  355. }
  356. if wrapper := m.GetMinConcurrency(); wrapper != nil {
  357. if wrapper.GetValue() <= 0 {
  358. return GradientControllerConfig_MinimumRTTCalculationParamsValidationError{
  359. field: "MinConcurrency",
  360. reason: "value must be greater than 0",
  361. }
  362. }
  363. }
  364. if v, ok := interface{}(m.GetBuffer()).(interface{ Validate() error }); ok {
  365. if err := v.Validate(); err != nil {
  366. return GradientControllerConfig_MinimumRTTCalculationParamsValidationError{
  367. field: "Buffer",
  368. reason: "embedded message failed validation",
  369. cause: err,
  370. }
  371. }
  372. }
  373. return nil
  374. }
  375. // GradientControllerConfig_MinimumRTTCalculationParamsValidationError is the
  376. // validation error returned by
  377. // GradientControllerConfig_MinimumRTTCalculationParams.Validate if the
  378. // designated constraints aren't met.
  379. type GradientControllerConfig_MinimumRTTCalculationParamsValidationError struct {
  380. field string
  381. reason string
  382. cause error
  383. key bool
  384. }
  385. // Field function returns field value.
  386. func (e GradientControllerConfig_MinimumRTTCalculationParamsValidationError) Field() string {
  387. return e.field
  388. }
  389. // Reason function returns reason value.
  390. func (e GradientControllerConfig_MinimumRTTCalculationParamsValidationError) Reason() string {
  391. return e.reason
  392. }
  393. // Cause function returns cause value.
  394. func (e GradientControllerConfig_MinimumRTTCalculationParamsValidationError) Cause() error {
  395. return e.cause
  396. }
  397. // Key function returns key value.
  398. func (e GradientControllerConfig_MinimumRTTCalculationParamsValidationError) Key() bool { return e.key }
  399. // ErrorName returns error name.
  400. func (e GradientControllerConfig_MinimumRTTCalculationParamsValidationError) ErrorName() string {
  401. return "GradientControllerConfig_MinimumRTTCalculationParamsValidationError"
  402. }
  403. // Error satisfies the builtin error interface
  404. func (e GradientControllerConfig_MinimumRTTCalculationParamsValidationError) Error() string {
  405. cause := ""
  406. if e.cause != nil {
  407. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  408. }
  409. key := ""
  410. if e.key {
  411. key = "key for "
  412. }
  413. return fmt.Sprintf(
  414. "invalid %sGradientControllerConfig_MinimumRTTCalculationParams.%s: %s%s",
  415. key,
  416. e.field,
  417. e.reason,
  418. cause)
  419. }
  420. var _ error = GradientControllerConfig_MinimumRTTCalculationParamsValidationError{}
  421. var _ interface {
  422. Field() string
  423. Reason() string
  424. Key() bool
  425. Cause() error
  426. ErrorName() string
  427. } = GradientControllerConfig_MinimumRTTCalculationParamsValidationError{}