/pkg/api/envoy/config/overload/v2alpha/overload.pb.validate.go

https://github.com/datawire/ambassador · Go · 508 lines · 353 code · 97 blank · 58 comment · 58 complexity · cbe4ddf6dd85e22bc52bc9eca87915a8 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/overload/v2alpha/overload.proto
  3. package envoy_config_overload_v2alpha
  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 _overload_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 ResourceMonitor with the rules defined
  34. // in the proto definition for this message. If any rules are violated, an
  35. // error is returned.
  36. func (m *ResourceMonitor) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if len(m.GetName()) < 1 {
  41. return ResourceMonitorValidationError{
  42. field: "Name",
  43. reason: "value length must be at least 1 bytes",
  44. }
  45. }
  46. switch m.ConfigType.(type) {
  47. case *ResourceMonitor_Config:
  48. if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
  49. if err := v.Validate(); err != nil {
  50. return ResourceMonitorValidationError{
  51. field: "Config",
  52. reason: "embedded message failed validation",
  53. cause: err,
  54. }
  55. }
  56. }
  57. case *ResourceMonitor_TypedConfig:
  58. if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
  59. if err := v.Validate(); err != nil {
  60. return ResourceMonitorValidationError{
  61. field: "TypedConfig",
  62. reason: "embedded message failed validation",
  63. cause: err,
  64. }
  65. }
  66. }
  67. }
  68. return nil
  69. }
  70. // ResourceMonitorValidationError is the validation error returned by
  71. // ResourceMonitor.Validate if the designated constraints aren't met.
  72. type ResourceMonitorValidationError struct {
  73. field string
  74. reason string
  75. cause error
  76. key bool
  77. }
  78. // Field function returns field value.
  79. func (e ResourceMonitorValidationError) Field() string { return e.field }
  80. // Reason function returns reason value.
  81. func (e ResourceMonitorValidationError) Reason() string { return e.reason }
  82. // Cause function returns cause value.
  83. func (e ResourceMonitorValidationError) Cause() error { return e.cause }
  84. // Key function returns key value.
  85. func (e ResourceMonitorValidationError) Key() bool { return e.key }
  86. // ErrorName returns error name.
  87. func (e ResourceMonitorValidationError) ErrorName() string { return "ResourceMonitorValidationError" }
  88. // Error satisfies the builtin error interface
  89. func (e ResourceMonitorValidationError) Error() string {
  90. cause := ""
  91. if e.cause != nil {
  92. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  93. }
  94. key := ""
  95. if e.key {
  96. key = "key for "
  97. }
  98. return fmt.Sprintf(
  99. "invalid %sResourceMonitor.%s: %s%s",
  100. key,
  101. e.field,
  102. e.reason,
  103. cause)
  104. }
  105. var _ error = ResourceMonitorValidationError{}
  106. var _ interface {
  107. Field() string
  108. Reason() string
  109. Key() bool
  110. Cause() error
  111. ErrorName() string
  112. } = ResourceMonitorValidationError{}
  113. // Validate checks the field values on ThresholdTrigger with the rules defined
  114. // in the proto definition for this message. If any rules are violated, an
  115. // error is returned.
  116. func (m *ThresholdTrigger) Validate() error {
  117. if m == nil {
  118. return nil
  119. }
  120. if val := m.GetValue(); val < 0 || val > 1 {
  121. return ThresholdTriggerValidationError{
  122. field: "Value",
  123. reason: "value must be inside range [0, 1]",
  124. }
  125. }
  126. return nil
  127. }
  128. // ThresholdTriggerValidationError is the validation error returned by
  129. // ThresholdTrigger.Validate if the designated constraints aren't met.
  130. type ThresholdTriggerValidationError struct {
  131. field string
  132. reason string
  133. cause error
  134. key bool
  135. }
  136. // Field function returns field value.
  137. func (e ThresholdTriggerValidationError) Field() string { return e.field }
  138. // Reason function returns reason value.
  139. func (e ThresholdTriggerValidationError) Reason() string { return e.reason }
  140. // Cause function returns cause value.
  141. func (e ThresholdTriggerValidationError) Cause() error { return e.cause }
  142. // Key function returns key value.
  143. func (e ThresholdTriggerValidationError) Key() bool { return e.key }
  144. // ErrorName returns error name.
  145. func (e ThresholdTriggerValidationError) ErrorName() string { return "ThresholdTriggerValidationError" }
  146. // Error satisfies the builtin error interface
  147. func (e ThresholdTriggerValidationError) Error() string {
  148. cause := ""
  149. if e.cause != nil {
  150. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  151. }
  152. key := ""
  153. if e.key {
  154. key = "key for "
  155. }
  156. return fmt.Sprintf(
  157. "invalid %sThresholdTrigger.%s: %s%s",
  158. key,
  159. e.field,
  160. e.reason,
  161. cause)
  162. }
  163. var _ error = ThresholdTriggerValidationError{}
  164. var _ interface {
  165. Field() string
  166. Reason() string
  167. Key() bool
  168. Cause() error
  169. ErrorName() string
  170. } = ThresholdTriggerValidationError{}
  171. // Validate checks the field values on Trigger with the rules defined in the
  172. // proto definition for this message. If any rules are violated, an error is returned.
  173. func (m *Trigger) Validate() error {
  174. if m == nil {
  175. return nil
  176. }
  177. if len(m.GetName()) < 1 {
  178. return TriggerValidationError{
  179. field: "Name",
  180. reason: "value length must be at least 1 bytes",
  181. }
  182. }
  183. switch m.TriggerOneof.(type) {
  184. case *Trigger_Threshold:
  185. if v, ok := interface{}(m.GetThreshold()).(interface{ Validate() error }); ok {
  186. if err := v.Validate(); err != nil {
  187. return TriggerValidationError{
  188. field: "Threshold",
  189. reason: "embedded message failed validation",
  190. cause: err,
  191. }
  192. }
  193. }
  194. default:
  195. return TriggerValidationError{
  196. field: "TriggerOneof",
  197. reason: "value is required",
  198. }
  199. }
  200. return nil
  201. }
  202. // TriggerValidationError is the validation error returned by Trigger.Validate
  203. // if the designated constraints aren't met.
  204. type TriggerValidationError struct {
  205. field string
  206. reason string
  207. cause error
  208. key bool
  209. }
  210. // Field function returns field value.
  211. func (e TriggerValidationError) Field() string { return e.field }
  212. // Reason function returns reason value.
  213. func (e TriggerValidationError) Reason() string { return e.reason }
  214. // Cause function returns cause value.
  215. func (e TriggerValidationError) Cause() error { return e.cause }
  216. // Key function returns key value.
  217. func (e TriggerValidationError) Key() bool { return e.key }
  218. // ErrorName returns error name.
  219. func (e TriggerValidationError) ErrorName() string { return "TriggerValidationError" }
  220. // Error satisfies the builtin error interface
  221. func (e TriggerValidationError) Error() string {
  222. cause := ""
  223. if e.cause != nil {
  224. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  225. }
  226. key := ""
  227. if e.key {
  228. key = "key for "
  229. }
  230. return fmt.Sprintf(
  231. "invalid %sTrigger.%s: %s%s",
  232. key,
  233. e.field,
  234. e.reason,
  235. cause)
  236. }
  237. var _ error = TriggerValidationError{}
  238. var _ interface {
  239. Field() string
  240. Reason() string
  241. Key() bool
  242. Cause() error
  243. ErrorName() string
  244. } = TriggerValidationError{}
  245. // Validate checks the field values on OverloadAction with the rules defined in
  246. // the proto definition for this message. If any rules are violated, an error
  247. // is returned.
  248. func (m *OverloadAction) Validate() error {
  249. if m == nil {
  250. return nil
  251. }
  252. if len(m.GetName()) < 1 {
  253. return OverloadActionValidationError{
  254. field: "Name",
  255. reason: "value length must be at least 1 bytes",
  256. }
  257. }
  258. if len(m.GetTriggers()) < 1 {
  259. return OverloadActionValidationError{
  260. field: "Triggers",
  261. reason: "value must contain at least 1 item(s)",
  262. }
  263. }
  264. for idx, item := range m.GetTriggers() {
  265. _, _ = idx, item
  266. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  267. if err := v.Validate(); err != nil {
  268. return OverloadActionValidationError{
  269. field: fmt.Sprintf("Triggers[%v]", idx),
  270. reason: "embedded message failed validation",
  271. cause: err,
  272. }
  273. }
  274. }
  275. }
  276. return nil
  277. }
  278. // OverloadActionValidationError is the validation error returned by
  279. // OverloadAction.Validate if the designated constraints aren't met.
  280. type OverloadActionValidationError struct {
  281. field string
  282. reason string
  283. cause error
  284. key bool
  285. }
  286. // Field function returns field value.
  287. func (e OverloadActionValidationError) Field() string { return e.field }
  288. // Reason function returns reason value.
  289. func (e OverloadActionValidationError) Reason() string { return e.reason }
  290. // Cause function returns cause value.
  291. func (e OverloadActionValidationError) Cause() error { return e.cause }
  292. // Key function returns key value.
  293. func (e OverloadActionValidationError) Key() bool { return e.key }
  294. // ErrorName returns error name.
  295. func (e OverloadActionValidationError) ErrorName() string { return "OverloadActionValidationError" }
  296. // Error satisfies the builtin error interface
  297. func (e OverloadActionValidationError) Error() string {
  298. cause := ""
  299. if e.cause != nil {
  300. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  301. }
  302. key := ""
  303. if e.key {
  304. key = "key for "
  305. }
  306. return fmt.Sprintf(
  307. "invalid %sOverloadAction.%s: %s%s",
  308. key,
  309. e.field,
  310. e.reason,
  311. cause)
  312. }
  313. var _ error = OverloadActionValidationError{}
  314. var _ interface {
  315. Field() string
  316. Reason() string
  317. Key() bool
  318. Cause() error
  319. ErrorName() string
  320. } = OverloadActionValidationError{}
  321. // Validate checks the field values on OverloadManager with the rules defined
  322. // in the proto definition for this message. If any rules are violated, an
  323. // error is returned.
  324. func (m *OverloadManager) Validate() error {
  325. if m == nil {
  326. return nil
  327. }
  328. if v, ok := interface{}(m.GetRefreshInterval()).(interface{ Validate() error }); ok {
  329. if err := v.Validate(); err != nil {
  330. return OverloadManagerValidationError{
  331. field: "RefreshInterval",
  332. reason: "embedded message failed validation",
  333. cause: err,
  334. }
  335. }
  336. }
  337. if len(m.GetResourceMonitors()) < 1 {
  338. return OverloadManagerValidationError{
  339. field: "ResourceMonitors",
  340. reason: "value must contain at least 1 item(s)",
  341. }
  342. }
  343. for idx, item := range m.GetResourceMonitors() {
  344. _, _ = idx, item
  345. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  346. if err := v.Validate(); err != nil {
  347. return OverloadManagerValidationError{
  348. field: fmt.Sprintf("ResourceMonitors[%v]", idx),
  349. reason: "embedded message failed validation",
  350. cause: err,
  351. }
  352. }
  353. }
  354. }
  355. for idx, item := range m.GetActions() {
  356. _, _ = idx, item
  357. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  358. if err := v.Validate(); err != nil {
  359. return OverloadManagerValidationError{
  360. field: fmt.Sprintf("Actions[%v]", idx),
  361. reason: "embedded message failed validation",
  362. cause: err,
  363. }
  364. }
  365. }
  366. }
  367. return nil
  368. }
  369. // OverloadManagerValidationError is the validation error returned by
  370. // OverloadManager.Validate if the designated constraints aren't met.
  371. type OverloadManagerValidationError struct {
  372. field string
  373. reason string
  374. cause error
  375. key bool
  376. }
  377. // Field function returns field value.
  378. func (e OverloadManagerValidationError) Field() string { return e.field }
  379. // Reason function returns reason value.
  380. func (e OverloadManagerValidationError) Reason() string { return e.reason }
  381. // Cause function returns cause value.
  382. func (e OverloadManagerValidationError) Cause() error { return e.cause }
  383. // Key function returns key value.
  384. func (e OverloadManagerValidationError) Key() bool { return e.key }
  385. // ErrorName returns error name.
  386. func (e OverloadManagerValidationError) ErrorName() string { return "OverloadManagerValidationError" }
  387. // Error satisfies the builtin error interface
  388. func (e OverloadManagerValidationError) Error() string {
  389. cause := ""
  390. if e.cause != nil {
  391. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  392. }
  393. key := ""
  394. if e.key {
  395. key = "key for "
  396. }
  397. return fmt.Sprintf(
  398. "invalid %sOverloadManager.%s: %s%s",
  399. key,
  400. e.field,
  401. e.reason,
  402. cause)
  403. }
  404. var _ error = OverloadManagerValidationError{}
  405. var _ interface {
  406. Field() string
  407. Reason() string
  408. Key() bool
  409. Cause() error
  410. ErrorName() string
  411. } = OverloadManagerValidationError{}