/vendor/github.com/envoyproxy/go-control-plane/envoy/extensions/access_loggers/grpc/v3/als.pb.validate.go

https://github.com/XiaoMi/naftis · Go · 327 lines · 234 code · 56 blank · 37 comment · 39 complexity · 105c72e7df28a75d59f14a7658931927 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/access_loggers/grpc/v3/als.proto
  3. package envoy_extensions_access_loggers_grpc_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 _als_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 HttpGrpcAccessLogConfig 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 *HttpGrpcAccessLogConfig) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if m.GetCommonConfig() == nil {
  41. return HttpGrpcAccessLogConfigValidationError{
  42. field: "CommonConfig",
  43. reason: "value is required",
  44. }
  45. }
  46. if v, ok := interface{}(m.GetCommonConfig()).(interface{ Validate() error }); ok {
  47. if err := v.Validate(); err != nil {
  48. return HttpGrpcAccessLogConfigValidationError{
  49. field: "CommonConfig",
  50. reason: "embedded message failed validation",
  51. cause: err,
  52. }
  53. }
  54. }
  55. return nil
  56. }
  57. // HttpGrpcAccessLogConfigValidationError is the validation error returned by
  58. // HttpGrpcAccessLogConfig.Validate if the designated constraints aren't met.
  59. type HttpGrpcAccessLogConfigValidationError struct {
  60. field string
  61. reason string
  62. cause error
  63. key bool
  64. }
  65. // Field function returns field value.
  66. func (e HttpGrpcAccessLogConfigValidationError) Field() string { return e.field }
  67. // Reason function returns reason value.
  68. func (e HttpGrpcAccessLogConfigValidationError) Reason() string { return e.reason }
  69. // Cause function returns cause value.
  70. func (e HttpGrpcAccessLogConfigValidationError) Cause() error { return e.cause }
  71. // Key function returns key value.
  72. func (e HttpGrpcAccessLogConfigValidationError) Key() bool { return e.key }
  73. // ErrorName returns error name.
  74. func (e HttpGrpcAccessLogConfigValidationError) ErrorName() string {
  75. return "HttpGrpcAccessLogConfigValidationError"
  76. }
  77. // Error satisfies the builtin error interface
  78. func (e HttpGrpcAccessLogConfigValidationError) Error() string {
  79. cause := ""
  80. if e.cause != nil {
  81. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  82. }
  83. key := ""
  84. if e.key {
  85. key = "key for "
  86. }
  87. return fmt.Sprintf(
  88. "invalid %sHttpGrpcAccessLogConfig.%s: %s%s",
  89. key,
  90. e.field,
  91. e.reason,
  92. cause)
  93. }
  94. var _ error = HttpGrpcAccessLogConfigValidationError{}
  95. var _ interface {
  96. Field() string
  97. Reason() string
  98. Key() bool
  99. Cause() error
  100. ErrorName() string
  101. } = HttpGrpcAccessLogConfigValidationError{}
  102. // Validate checks the field values on TcpGrpcAccessLogConfig with the rules
  103. // defined in the proto definition for this message. If any rules are
  104. // violated, an error is returned.
  105. func (m *TcpGrpcAccessLogConfig) Validate() error {
  106. if m == nil {
  107. return nil
  108. }
  109. if m.GetCommonConfig() == nil {
  110. return TcpGrpcAccessLogConfigValidationError{
  111. field: "CommonConfig",
  112. reason: "value is required",
  113. }
  114. }
  115. if v, ok := interface{}(m.GetCommonConfig()).(interface{ Validate() error }); ok {
  116. if err := v.Validate(); err != nil {
  117. return TcpGrpcAccessLogConfigValidationError{
  118. field: "CommonConfig",
  119. reason: "embedded message failed validation",
  120. cause: err,
  121. }
  122. }
  123. }
  124. return nil
  125. }
  126. // TcpGrpcAccessLogConfigValidationError is the validation error returned by
  127. // TcpGrpcAccessLogConfig.Validate if the designated constraints aren't met.
  128. type TcpGrpcAccessLogConfigValidationError struct {
  129. field string
  130. reason string
  131. cause error
  132. key bool
  133. }
  134. // Field function returns field value.
  135. func (e TcpGrpcAccessLogConfigValidationError) Field() string { return e.field }
  136. // Reason function returns reason value.
  137. func (e TcpGrpcAccessLogConfigValidationError) Reason() string { return e.reason }
  138. // Cause function returns cause value.
  139. func (e TcpGrpcAccessLogConfigValidationError) Cause() error { return e.cause }
  140. // Key function returns key value.
  141. func (e TcpGrpcAccessLogConfigValidationError) Key() bool { return e.key }
  142. // ErrorName returns error name.
  143. func (e TcpGrpcAccessLogConfigValidationError) ErrorName() string {
  144. return "TcpGrpcAccessLogConfigValidationError"
  145. }
  146. // Error satisfies the builtin error interface
  147. func (e TcpGrpcAccessLogConfigValidationError) 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 %sTcpGrpcAccessLogConfig.%s: %s%s",
  158. key,
  159. e.field,
  160. e.reason,
  161. cause)
  162. }
  163. var _ error = TcpGrpcAccessLogConfigValidationError{}
  164. var _ interface {
  165. Field() string
  166. Reason() string
  167. Key() bool
  168. Cause() error
  169. ErrorName() string
  170. } = TcpGrpcAccessLogConfigValidationError{}
  171. // Validate checks the field values on CommonGrpcAccessLogConfig with the rules
  172. // defined in the proto definition for this message. If any rules are
  173. // violated, an error is returned.
  174. func (m *CommonGrpcAccessLogConfig) Validate() error {
  175. if m == nil {
  176. return nil
  177. }
  178. if len(m.GetLogName()) < 1 {
  179. return CommonGrpcAccessLogConfigValidationError{
  180. field: "LogName",
  181. reason: "value length must be at least 1 bytes",
  182. }
  183. }
  184. if m.GetGrpcService() == nil {
  185. return CommonGrpcAccessLogConfigValidationError{
  186. field: "GrpcService",
  187. reason: "value is required",
  188. }
  189. }
  190. if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
  191. if err := v.Validate(); err != nil {
  192. return CommonGrpcAccessLogConfigValidationError{
  193. field: "GrpcService",
  194. reason: "embedded message failed validation",
  195. cause: err,
  196. }
  197. }
  198. }
  199. if d := m.GetBufferFlushInterval(); d != nil {
  200. dur, err := ptypes.Duration(d)
  201. if err != nil {
  202. return CommonGrpcAccessLogConfigValidationError{
  203. field: "BufferFlushInterval",
  204. reason: "value is not a valid duration",
  205. cause: err,
  206. }
  207. }
  208. gt := time.Duration(0*time.Second + 0*time.Nanosecond)
  209. if dur <= gt {
  210. return CommonGrpcAccessLogConfigValidationError{
  211. field: "BufferFlushInterval",
  212. reason: "value must be greater than 0s",
  213. }
  214. }
  215. }
  216. if v, ok := interface{}(m.GetBufferSizeBytes()).(interface{ Validate() error }); ok {
  217. if err := v.Validate(); err != nil {
  218. return CommonGrpcAccessLogConfigValidationError{
  219. field: "BufferSizeBytes",
  220. reason: "embedded message failed validation",
  221. cause: err,
  222. }
  223. }
  224. }
  225. return nil
  226. }
  227. // CommonGrpcAccessLogConfigValidationError is the validation error returned by
  228. // CommonGrpcAccessLogConfig.Validate if the designated constraints aren't met.
  229. type CommonGrpcAccessLogConfigValidationError struct {
  230. field string
  231. reason string
  232. cause error
  233. key bool
  234. }
  235. // Field function returns field value.
  236. func (e CommonGrpcAccessLogConfigValidationError) Field() string { return e.field }
  237. // Reason function returns reason value.
  238. func (e CommonGrpcAccessLogConfigValidationError) Reason() string { return e.reason }
  239. // Cause function returns cause value.
  240. func (e CommonGrpcAccessLogConfigValidationError) Cause() error { return e.cause }
  241. // Key function returns key value.
  242. func (e CommonGrpcAccessLogConfigValidationError) Key() bool { return e.key }
  243. // ErrorName returns error name.
  244. func (e CommonGrpcAccessLogConfigValidationError) ErrorName() string {
  245. return "CommonGrpcAccessLogConfigValidationError"
  246. }
  247. // Error satisfies the builtin error interface
  248. func (e CommonGrpcAccessLogConfigValidationError) Error() string {
  249. cause := ""
  250. if e.cause != nil {
  251. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  252. }
  253. key := ""
  254. if e.key {
  255. key = "key for "
  256. }
  257. return fmt.Sprintf(
  258. "invalid %sCommonGrpcAccessLogConfig.%s: %s%s",
  259. key,
  260. e.field,
  261. e.reason,
  262. cause)
  263. }
  264. var _ error = CommonGrpcAccessLogConfigValidationError{}
  265. var _ interface {
  266. Field() string
  267. Reason() string
  268. Key() bool
  269. Cause() error
  270. ErrorName() string
  271. } = CommonGrpcAccessLogConfigValidationError{}