/pkg/api/envoy/data/cluster/v2alpha/outlier_detection_event.pb.validate.go

https://github.com/datawire/ambassador · Go · 432 lines · 303 code · 78 blank · 51 comment · 44 complexity · 9f723f7a7d4900b48b8f897bb68d5473 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/data/cluster/v2alpha/outlier_detection_event.proto
  3. package envoy_data_cluster_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 _outlier_detection_event_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 OutlierDetectionEvent 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 *OutlierDetectionEvent) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if _, ok := OutlierEjectionType_name[int32(m.GetType())]; !ok {
  41. return OutlierDetectionEventValidationError{
  42. field: "Type",
  43. reason: "value must be one of the defined enum values",
  44. }
  45. }
  46. if v, ok := interface{}(m.GetTimestamp()).(interface{ Validate() error }); ok {
  47. if err := v.Validate(); err != nil {
  48. return OutlierDetectionEventValidationError{
  49. field: "Timestamp",
  50. reason: "embedded message failed validation",
  51. cause: err,
  52. }
  53. }
  54. }
  55. if v, ok := interface{}(m.GetSecsSinceLastAction()).(interface{ Validate() error }); ok {
  56. if err := v.Validate(); err != nil {
  57. return OutlierDetectionEventValidationError{
  58. field: "SecsSinceLastAction",
  59. reason: "embedded message failed validation",
  60. cause: err,
  61. }
  62. }
  63. }
  64. if len(m.GetClusterName()) < 1 {
  65. return OutlierDetectionEventValidationError{
  66. field: "ClusterName",
  67. reason: "value length must be at least 1 bytes",
  68. }
  69. }
  70. if len(m.GetUpstreamUrl()) < 1 {
  71. return OutlierDetectionEventValidationError{
  72. field: "UpstreamUrl",
  73. reason: "value length must be at least 1 bytes",
  74. }
  75. }
  76. if _, ok := Action_name[int32(m.GetAction())]; !ok {
  77. return OutlierDetectionEventValidationError{
  78. field: "Action",
  79. reason: "value must be one of the defined enum values",
  80. }
  81. }
  82. // no validation rules for NumEjections
  83. // no validation rules for Enforced
  84. switch m.Event.(type) {
  85. case *OutlierDetectionEvent_EjectSuccessRateEvent:
  86. if v, ok := interface{}(m.GetEjectSuccessRateEvent()).(interface{ Validate() error }); ok {
  87. if err := v.Validate(); err != nil {
  88. return OutlierDetectionEventValidationError{
  89. field: "EjectSuccessRateEvent",
  90. reason: "embedded message failed validation",
  91. cause: err,
  92. }
  93. }
  94. }
  95. case *OutlierDetectionEvent_EjectConsecutiveEvent:
  96. if v, ok := interface{}(m.GetEjectConsecutiveEvent()).(interface{ Validate() error }); ok {
  97. if err := v.Validate(); err != nil {
  98. return OutlierDetectionEventValidationError{
  99. field: "EjectConsecutiveEvent",
  100. reason: "embedded message failed validation",
  101. cause: err,
  102. }
  103. }
  104. }
  105. case *OutlierDetectionEvent_EjectFailurePercentageEvent:
  106. if v, ok := interface{}(m.GetEjectFailurePercentageEvent()).(interface{ Validate() error }); ok {
  107. if err := v.Validate(); err != nil {
  108. return OutlierDetectionEventValidationError{
  109. field: "EjectFailurePercentageEvent",
  110. reason: "embedded message failed validation",
  111. cause: err,
  112. }
  113. }
  114. }
  115. default:
  116. return OutlierDetectionEventValidationError{
  117. field: "Event",
  118. reason: "value is required",
  119. }
  120. }
  121. return nil
  122. }
  123. // OutlierDetectionEventValidationError is the validation error returned by
  124. // OutlierDetectionEvent.Validate if the designated constraints aren't met.
  125. type OutlierDetectionEventValidationError struct {
  126. field string
  127. reason string
  128. cause error
  129. key bool
  130. }
  131. // Field function returns field value.
  132. func (e OutlierDetectionEventValidationError) Field() string { return e.field }
  133. // Reason function returns reason value.
  134. func (e OutlierDetectionEventValidationError) Reason() string { return e.reason }
  135. // Cause function returns cause value.
  136. func (e OutlierDetectionEventValidationError) Cause() error { return e.cause }
  137. // Key function returns key value.
  138. func (e OutlierDetectionEventValidationError) Key() bool { return e.key }
  139. // ErrorName returns error name.
  140. func (e OutlierDetectionEventValidationError) ErrorName() string {
  141. return "OutlierDetectionEventValidationError"
  142. }
  143. // Error satisfies the builtin error interface
  144. func (e OutlierDetectionEventValidationError) Error() string {
  145. cause := ""
  146. if e.cause != nil {
  147. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  148. }
  149. key := ""
  150. if e.key {
  151. key = "key for "
  152. }
  153. return fmt.Sprintf(
  154. "invalid %sOutlierDetectionEvent.%s: %s%s",
  155. key,
  156. e.field,
  157. e.reason,
  158. cause)
  159. }
  160. var _ error = OutlierDetectionEventValidationError{}
  161. var _ interface {
  162. Field() string
  163. Reason() string
  164. Key() bool
  165. Cause() error
  166. ErrorName() string
  167. } = OutlierDetectionEventValidationError{}
  168. // Validate checks the field values on OutlierEjectSuccessRate with the rules
  169. // defined in the proto definition for this message. If any rules are
  170. // violated, an error is returned.
  171. func (m *OutlierEjectSuccessRate) Validate() error {
  172. if m == nil {
  173. return nil
  174. }
  175. if m.GetHostSuccessRate() > 100 {
  176. return OutlierEjectSuccessRateValidationError{
  177. field: "HostSuccessRate",
  178. reason: "value must be less than or equal to 100",
  179. }
  180. }
  181. if m.GetClusterAverageSuccessRate() > 100 {
  182. return OutlierEjectSuccessRateValidationError{
  183. field: "ClusterAverageSuccessRate",
  184. reason: "value must be less than or equal to 100",
  185. }
  186. }
  187. if m.GetClusterSuccessRateEjectionThreshold() > 100 {
  188. return OutlierEjectSuccessRateValidationError{
  189. field: "ClusterSuccessRateEjectionThreshold",
  190. reason: "value must be less than or equal to 100",
  191. }
  192. }
  193. return nil
  194. }
  195. // OutlierEjectSuccessRateValidationError is the validation error returned by
  196. // OutlierEjectSuccessRate.Validate if the designated constraints aren't met.
  197. type OutlierEjectSuccessRateValidationError struct {
  198. field string
  199. reason string
  200. cause error
  201. key bool
  202. }
  203. // Field function returns field value.
  204. func (e OutlierEjectSuccessRateValidationError) Field() string { return e.field }
  205. // Reason function returns reason value.
  206. func (e OutlierEjectSuccessRateValidationError) Reason() string { return e.reason }
  207. // Cause function returns cause value.
  208. func (e OutlierEjectSuccessRateValidationError) Cause() error { return e.cause }
  209. // Key function returns key value.
  210. func (e OutlierEjectSuccessRateValidationError) Key() bool { return e.key }
  211. // ErrorName returns error name.
  212. func (e OutlierEjectSuccessRateValidationError) ErrorName() string {
  213. return "OutlierEjectSuccessRateValidationError"
  214. }
  215. // Error satisfies the builtin error interface
  216. func (e OutlierEjectSuccessRateValidationError) Error() string {
  217. cause := ""
  218. if e.cause != nil {
  219. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  220. }
  221. key := ""
  222. if e.key {
  223. key = "key for "
  224. }
  225. return fmt.Sprintf(
  226. "invalid %sOutlierEjectSuccessRate.%s: %s%s",
  227. key,
  228. e.field,
  229. e.reason,
  230. cause)
  231. }
  232. var _ error = OutlierEjectSuccessRateValidationError{}
  233. var _ interface {
  234. Field() string
  235. Reason() string
  236. Key() bool
  237. Cause() error
  238. ErrorName() string
  239. } = OutlierEjectSuccessRateValidationError{}
  240. // Validate checks the field values on OutlierEjectConsecutive with the rules
  241. // defined in the proto definition for this message. If any rules are
  242. // violated, an error is returned.
  243. func (m *OutlierEjectConsecutive) Validate() error {
  244. if m == nil {
  245. return nil
  246. }
  247. return nil
  248. }
  249. // OutlierEjectConsecutiveValidationError is the validation error returned by
  250. // OutlierEjectConsecutive.Validate if the designated constraints aren't met.
  251. type OutlierEjectConsecutiveValidationError struct {
  252. field string
  253. reason string
  254. cause error
  255. key bool
  256. }
  257. // Field function returns field value.
  258. func (e OutlierEjectConsecutiveValidationError) Field() string { return e.field }
  259. // Reason function returns reason value.
  260. func (e OutlierEjectConsecutiveValidationError) Reason() string { return e.reason }
  261. // Cause function returns cause value.
  262. func (e OutlierEjectConsecutiveValidationError) Cause() error { return e.cause }
  263. // Key function returns key value.
  264. func (e OutlierEjectConsecutiveValidationError) Key() bool { return e.key }
  265. // ErrorName returns error name.
  266. func (e OutlierEjectConsecutiveValidationError) ErrorName() string {
  267. return "OutlierEjectConsecutiveValidationError"
  268. }
  269. // Error satisfies the builtin error interface
  270. func (e OutlierEjectConsecutiveValidationError) Error() string {
  271. cause := ""
  272. if e.cause != nil {
  273. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  274. }
  275. key := ""
  276. if e.key {
  277. key = "key for "
  278. }
  279. return fmt.Sprintf(
  280. "invalid %sOutlierEjectConsecutive.%s: %s%s",
  281. key,
  282. e.field,
  283. e.reason,
  284. cause)
  285. }
  286. var _ error = OutlierEjectConsecutiveValidationError{}
  287. var _ interface {
  288. Field() string
  289. Reason() string
  290. Key() bool
  291. Cause() error
  292. ErrorName() string
  293. } = OutlierEjectConsecutiveValidationError{}
  294. // Validate checks the field values on OutlierEjectFailurePercentage with the
  295. // rules defined in the proto definition for this message. If any rules are
  296. // violated, an error is returned.
  297. func (m *OutlierEjectFailurePercentage) Validate() error {
  298. if m == nil {
  299. return nil
  300. }
  301. if m.GetHostSuccessRate() > 100 {
  302. return OutlierEjectFailurePercentageValidationError{
  303. field: "HostSuccessRate",
  304. reason: "value must be less than or equal to 100",
  305. }
  306. }
  307. return nil
  308. }
  309. // OutlierEjectFailurePercentageValidationError is the validation error
  310. // returned by OutlierEjectFailurePercentage.Validate if the designated
  311. // constraints aren't met.
  312. type OutlierEjectFailurePercentageValidationError struct {
  313. field string
  314. reason string
  315. cause error
  316. key bool
  317. }
  318. // Field function returns field value.
  319. func (e OutlierEjectFailurePercentageValidationError) Field() string { return e.field }
  320. // Reason function returns reason value.
  321. func (e OutlierEjectFailurePercentageValidationError) Reason() string { return e.reason }
  322. // Cause function returns cause value.
  323. func (e OutlierEjectFailurePercentageValidationError) Cause() error { return e.cause }
  324. // Key function returns key value.
  325. func (e OutlierEjectFailurePercentageValidationError) Key() bool { return e.key }
  326. // ErrorName returns error name.
  327. func (e OutlierEjectFailurePercentageValidationError) ErrorName() string {
  328. return "OutlierEjectFailurePercentageValidationError"
  329. }
  330. // Error satisfies the builtin error interface
  331. func (e OutlierEjectFailurePercentageValidationError) Error() string {
  332. cause := ""
  333. if e.cause != nil {
  334. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  335. }
  336. key := ""
  337. if e.key {
  338. key = "key for "
  339. }
  340. return fmt.Sprintf(
  341. "invalid %sOutlierEjectFailurePercentage.%s: %s%s",
  342. key,
  343. e.field,
  344. e.reason,
  345. cause)
  346. }
  347. var _ error = OutlierEjectFailurePercentageValidationError{}
  348. var _ interface {
  349. Field() string
  350. Reason() string
  351. Key() bool
  352. Cause() error
  353. ErrorName() string
  354. } = OutlierEjectFailurePercentageValidationError{}