/pkg/api/envoy/config/route/v3/route.pb.validate.go

https://github.com/datawire/ambassador · Go · 310 lines · 223 code · 60 blank · 27 comment · 41 complexity · f1b27ff0632e9a1c8cb0900eb6ca3386 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/route/v3/route.proto
  3. package envoy_config_route_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 _route_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 RouteConfiguration 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 *RouteConfiguration) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. // no validation rules for Name
  41. for idx, item := range m.GetVirtualHosts() {
  42. _, _ = idx, item
  43. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  44. if err := v.Validate(); err != nil {
  45. return RouteConfigurationValidationError{
  46. field: fmt.Sprintf("VirtualHosts[%v]", idx),
  47. reason: "embedded message failed validation",
  48. cause: err,
  49. }
  50. }
  51. }
  52. }
  53. if v, ok := interface{}(m.GetVhds()).(interface{ Validate() error }); ok {
  54. if err := v.Validate(); err != nil {
  55. return RouteConfigurationValidationError{
  56. field: "Vhds",
  57. reason: "embedded message failed validation",
  58. cause: err,
  59. }
  60. }
  61. }
  62. for idx, item := range m.GetInternalOnlyHeaders() {
  63. _, _ = idx, item
  64. if !_RouteConfiguration_InternalOnlyHeaders_Pattern.MatchString(item) {
  65. return RouteConfigurationValidationError{
  66. field: fmt.Sprintf("InternalOnlyHeaders[%v]", idx),
  67. reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
  68. }
  69. }
  70. }
  71. if len(m.GetResponseHeadersToAdd()) > 1000 {
  72. return RouteConfigurationValidationError{
  73. field: "ResponseHeadersToAdd",
  74. reason: "value must contain no more than 1000 item(s)",
  75. }
  76. }
  77. for idx, item := range m.GetResponseHeadersToAdd() {
  78. _, _ = idx, item
  79. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  80. if err := v.Validate(); err != nil {
  81. return RouteConfigurationValidationError{
  82. field: fmt.Sprintf("ResponseHeadersToAdd[%v]", idx),
  83. reason: "embedded message failed validation",
  84. cause: err,
  85. }
  86. }
  87. }
  88. }
  89. for idx, item := range m.GetResponseHeadersToRemove() {
  90. _, _ = idx, item
  91. if !_RouteConfiguration_ResponseHeadersToRemove_Pattern.MatchString(item) {
  92. return RouteConfigurationValidationError{
  93. field: fmt.Sprintf("ResponseHeadersToRemove[%v]", idx),
  94. reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
  95. }
  96. }
  97. }
  98. if len(m.GetRequestHeadersToAdd()) > 1000 {
  99. return RouteConfigurationValidationError{
  100. field: "RequestHeadersToAdd",
  101. reason: "value must contain no more than 1000 item(s)",
  102. }
  103. }
  104. for idx, item := range m.GetRequestHeadersToAdd() {
  105. _, _ = idx, item
  106. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  107. if err := v.Validate(); err != nil {
  108. return RouteConfigurationValidationError{
  109. field: fmt.Sprintf("RequestHeadersToAdd[%v]", idx),
  110. reason: "embedded message failed validation",
  111. cause: err,
  112. }
  113. }
  114. }
  115. }
  116. for idx, item := range m.GetRequestHeadersToRemove() {
  117. _, _ = idx, item
  118. if !_RouteConfiguration_RequestHeadersToRemove_Pattern.MatchString(item) {
  119. return RouteConfigurationValidationError{
  120. field: fmt.Sprintf("RequestHeadersToRemove[%v]", idx),
  121. reason: "value does not match regex pattern \"^[^\\x00\\n\\r]*$\"",
  122. }
  123. }
  124. }
  125. // no validation rules for MostSpecificHeaderMutationsWins
  126. if v, ok := interface{}(m.GetValidateClusters()).(interface{ Validate() error }); ok {
  127. if err := v.Validate(); err != nil {
  128. return RouteConfigurationValidationError{
  129. field: "ValidateClusters",
  130. reason: "embedded message failed validation",
  131. cause: err,
  132. }
  133. }
  134. }
  135. return nil
  136. }
  137. // RouteConfigurationValidationError is the validation error returned by
  138. // RouteConfiguration.Validate if the designated constraints aren't met.
  139. type RouteConfigurationValidationError struct {
  140. field string
  141. reason string
  142. cause error
  143. key bool
  144. }
  145. // Field function returns field value.
  146. func (e RouteConfigurationValidationError) Field() string { return e.field }
  147. // Reason function returns reason value.
  148. func (e RouteConfigurationValidationError) Reason() string { return e.reason }
  149. // Cause function returns cause value.
  150. func (e RouteConfigurationValidationError) Cause() error { return e.cause }
  151. // Key function returns key value.
  152. func (e RouteConfigurationValidationError) Key() bool { return e.key }
  153. // ErrorName returns error name.
  154. func (e RouteConfigurationValidationError) ErrorName() string {
  155. return "RouteConfigurationValidationError"
  156. }
  157. // Error satisfies the builtin error interface
  158. func (e RouteConfigurationValidationError) Error() string {
  159. cause := ""
  160. if e.cause != nil {
  161. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  162. }
  163. key := ""
  164. if e.key {
  165. key = "key for "
  166. }
  167. return fmt.Sprintf(
  168. "invalid %sRouteConfiguration.%s: %s%s",
  169. key,
  170. e.field,
  171. e.reason,
  172. cause)
  173. }
  174. var _ error = RouteConfigurationValidationError{}
  175. var _ interface {
  176. Field() string
  177. Reason() string
  178. Key() bool
  179. Cause() error
  180. ErrorName() string
  181. } = RouteConfigurationValidationError{}
  182. var _RouteConfiguration_InternalOnlyHeaders_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
  183. var _RouteConfiguration_ResponseHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
  184. var _RouteConfiguration_RequestHeadersToRemove_Pattern = regexp.MustCompile("^[^\x00\n\r]*$")
  185. // Validate checks the field values on Vhds with the rules defined in the proto
  186. // definition for this message. If any rules are violated, an error is returned.
  187. func (m *Vhds) Validate() error {
  188. if m == nil {
  189. return nil
  190. }
  191. if m.GetConfigSource() == nil {
  192. return VhdsValidationError{
  193. field: "ConfigSource",
  194. reason: "value is required",
  195. }
  196. }
  197. if v, ok := interface{}(m.GetConfigSource()).(interface{ Validate() error }); ok {
  198. if err := v.Validate(); err != nil {
  199. return VhdsValidationError{
  200. field: "ConfigSource",
  201. reason: "embedded message failed validation",
  202. cause: err,
  203. }
  204. }
  205. }
  206. return nil
  207. }
  208. // VhdsValidationError is the validation error returned by Vhds.Validate if the
  209. // designated constraints aren't met.
  210. type VhdsValidationError struct {
  211. field string
  212. reason string
  213. cause error
  214. key bool
  215. }
  216. // Field function returns field value.
  217. func (e VhdsValidationError) Field() string { return e.field }
  218. // Reason function returns reason value.
  219. func (e VhdsValidationError) Reason() string { return e.reason }
  220. // Cause function returns cause value.
  221. func (e VhdsValidationError) Cause() error { return e.cause }
  222. // Key function returns key value.
  223. func (e VhdsValidationError) Key() bool { return e.key }
  224. // ErrorName returns error name.
  225. func (e VhdsValidationError) ErrorName() string { return "VhdsValidationError" }
  226. // Error satisfies the builtin error interface
  227. func (e VhdsValidationError) Error() string {
  228. cause := ""
  229. if e.cause != nil {
  230. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  231. }
  232. key := ""
  233. if e.key {
  234. key = "key for "
  235. }
  236. return fmt.Sprintf(
  237. "invalid %sVhds.%s: %s%s",
  238. key,
  239. e.field,
  240. e.reason,
  241. cause)
  242. }
  243. var _ error = VhdsValidationError{}
  244. var _ interface {
  245. Field() string
  246. Reason() string
  247. Key() bool
  248. Cause() error
  249. ErrorName() string
  250. } = VhdsValidationError{}