/api/mesh/v1alpha1/health_check.pb.validate.go

https://github.com/Kong/kuma · Go · 291 lines · 213 code · 52 blank · 26 comment · 39 complexity · 93e396e2730996d0e6ad27094280b797 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: mesh/v1alpha1/health_check.proto
  3. package v1alpha1
  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 _health_check_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 HealthCheck with the rules defined in
  34. // the proto definition for this message. If any rules are violated, an error
  35. // is returned.
  36. func (m *HealthCheck) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if len(m.GetSources()) < 1 {
  41. return HealthCheckValidationError{
  42. field: "Sources",
  43. reason: "value must contain at least 1 item(s)",
  44. }
  45. }
  46. for idx, item := range m.GetSources() {
  47. _, _ = idx, item
  48. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  49. if err := v.Validate(); err != nil {
  50. return HealthCheckValidationError{
  51. field: fmt.Sprintf("Sources[%v]", idx),
  52. reason: "embedded message failed validation",
  53. cause: err,
  54. }
  55. }
  56. }
  57. }
  58. if len(m.GetDestinations()) < 1 {
  59. return HealthCheckValidationError{
  60. field: "Destinations",
  61. reason: "value must contain at least 1 item(s)",
  62. }
  63. }
  64. for idx, item := range m.GetDestinations() {
  65. _, _ = idx, item
  66. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  67. if err := v.Validate(); err != nil {
  68. return HealthCheckValidationError{
  69. field: fmt.Sprintf("Destinations[%v]", idx),
  70. reason: "embedded message failed validation",
  71. cause: err,
  72. }
  73. }
  74. }
  75. }
  76. if v, ok := interface{}(m.GetConf()).(interface{ Validate() error }); ok {
  77. if err := v.Validate(); err != nil {
  78. return HealthCheckValidationError{
  79. field: "Conf",
  80. reason: "embedded message failed validation",
  81. cause: err,
  82. }
  83. }
  84. }
  85. return nil
  86. }
  87. // HealthCheckValidationError is the validation error returned by
  88. // HealthCheck.Validate if the designated constraints aren't met.
  89. type HealthCheckValidationError struct {
  90. field string
  91. reason string
  92. cause error
  93. key bool
  94. }
  95. // Field function returns field value.
  96. func (e HealthCheckValidationError) Field() string { return e.field }
  97. // Reason function returns reason value.
  98. func (e HealthCheckValidationError) Reason() string { return e.reason }
  99. // Cause function returns cause value.
  100. func (e HealthCheckValidationError) Cause() error { return e.cause }
  101. // Key function returns key value.
  102. func (e HealthCheckValidationError) Key() bool { return e.key }
  103. // ErrorName returns error name.
  104. func (e HealthCheckValidationError) ErrorName() string { return "HealthCheckValidationError" }
  105. // Error satisfies the builtin error interface
  106. func (e HealthCheckValidationError) Error() string {
  107. cause := ""
  108. if e.cause != nil {
  109. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  110. }
  111. key := ""
  112. if e.key {
  113. key = "key for "
  114. }
  115. return fmt.Sprintf(
  116. "invalid %sHealthCheck.%s: %s%s",
  117. key,
  118. e.field,
  119. e.reason,
  120. cause)
  121. }
  122. var _ error = HealthCheckValidationError{}
  123. var _ interface {
  124. Field() string
  125. Reason() string
  126. Key() bool
  127. Cause() error
  128. ErrorName() string
  129. } = HealthCheckValidationError{}
  130. // Validate checks the field values on HealthCheck_Conf with the rules defined
  131. // in the proto definition for this message. If any rules are violated, an
  132. // error is returned.
  133. func (m *HealthCheck_Conf) Validate() error {
  134. if m == nil {
  135. return nil
  136. }
  137. if m.GetInterval() == nil {
  138. return HealthCheck_ConfValidationError{
  139. field: "Interval",
  140. reason: "value is required",
  141. }
  142. }
  143. if d := m.GetInterval(); d != nil {
  144. dur, err := ptypes.Duration(d)
  145. if err != nil {
  146. return HealthCheck_ConfValidationError{
  147. field: "Interval",
  148. reason: "value is not a valid duration",
  149. cause: err,
  150. }
  151. }
  152. gt := time.Duration(0*time.Second + 0*time.Nanosecond)
  153. if dur <= gt {
  154. return HealthCheck_ConfValidationError{
  155. field: "Interval",
  156. reason: "value must be greater than 0s",
  157. }
  158. }
  159. }
  160. if m.GetTimeout() == nil {
  161. return HealthCheck_ConfValidationError{
  162. field: "Timeout",
  163. reason: "value is required",
  164. }
  165. }
  166. if d := m.GetTimeout(); d != nil {
  167. dur, err := ptypes.Duration(d)
  168. if err != nil {
  169. return HealthCheck_ConfValidationError{
  170. field: "Timeout",
  171. reason: "value is not a valid duration",
  172. cause: err,
  173. }
  174. }
  175. gt := time.Duration(0*time.Second + 0*time.Nanosecond)
  176. if dur <= gt {
  177. return HealthCheck_ConfValidationError{
  178. field: "Timeout",
  179. reason: "value must be greater than 0s",
  180. }
  181. }
  182. }
  183. if m.GetUnhealthyThreshold() <= 0 {
  184. return HealthCheck_ConfValidationError{
  185. field: "UnhealthyThreshold",
  186. reason: "value must be greater than 0",
  187. }
  188. }
  189. if m.GetHealthyThreshold() <= 0 {
  190. return HealthCheck_ConfValidationError{
  191. field: "HealthyThreshold",
  192. reason: "value must be greater than 0",
  193. }
  194. }
  195. return nil
  196. }
  197. // HealthCheck_ConfValidationError is the validation error returned by
  198. // HealthCheck_Conf.Validate if the designated constraints aren't met.
  199. type HealthCheck_ConfValidationError struct {
  200. field string
  201. reason string
  202. cause error
  203. key bool
  204. }
  205. // Field function returns field value.
  206. func (e HealthCheck_ConfValidationError) Field() string { return e.field }
  207. // Reason function returns reason value.
  208. func (e HealthCheck_ConfValidationError) Reason() string { return e.reason }
  209. // Cause function returns cause value.
  210. func (e HealthCheck_ConfValidationError) Cause() error { return e.cause }
  211. // Key function returns key value.
  212. func (e HealthCheck_ConfValidationError) Key() bool { return e.key }
  213. // ErrorName returns error name.
  214. func (e HealthCheck_ConfValidationError) ErrorName() string { return "HealthCheck_ConfValidationError" }
  215. // Error satisfies the builtin error interface
  216. func (e HealthCheck_ConfValidationError) 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 %sHealthCheck_Conf.%s: %s%s",
  227. key,
  228. e.field,
  229. e.reason,
  230. cause)
  231. }
  232. var _ error = HealthCheck_ConfValidationError{}
  233. var _ interface {
  234. Field() string
  235. Reason() string
  236. Key() bool
  237. Cause() error
  238. ErrorName() string
  239. } = HealthCheck_ConfValidationError{}