/pkg/api/envoy/extensions/common/dynamic_forward_proxy/v3/dns_cache.pb.validate.go

https://github.com/datawire/ambassador · Go · 270 lines · 195 code · 49 blank · 26 comment · 34 complexity · 2af2043d44fdff2505c33b50e812ad0a MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/extensions/common/dynamic_forward_proxy/v3/dns_cache.proto
  3. package envoy_extensions_common_dynamic_forward_proxy_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. v3 "github.com/datawire/ambassador/pkg/api/envoy/config/cluster/v3"
  17. )
  18. // ensure the imports are used
  19. var (
  20. _ = bytes.MinRead
  21. _ = errors.New("")
  22. _ = fmt.Print
  23. _ = utf8.UTFMax
  24. _ = (*regexp.Regexp)(nil)
  25. _ = (*strings.Reader)(nil)
  26. _ = net.IPv4len
  27. _ = time.Duration(0)
  28. _ = (*url.URL)(nil)
  29. _ = (*mail.Address)(nil)
  30. _ = ptypes.DynamicAny{}
  31. _ = v3.Cluster_DnsLookupFamily(0)
  32. )
  33. // define the regex for a UUID once up-front
  34. var _dns_cache_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}$")
  35. // Validate checks the field values on DnsCacheCircuitBreakers with the rules
  36. // defined in the proto definition for this message. If any rules are
  37. // violated, an error is returned.
  38. func (m *DnsCacheCircuitBreakers) Validate() error {
  39. if m == nil {
  40. return nil
  41. }
  42. if v, ok := interface{}(m.GetMaxPendingRequests()).(interface{ Validate() error }); ok {
  43. if err := v.Validate(); err != nil {
  44. return DnsCacheCircuitBreakersValidationError{
  45. field: "MaxPendingRequests",
  46. reason: "embedded message failed validation",
  47. cause: err,
  48. }
  49. }
  50. }
  51. return nil
  52. }
  53. // DnsCacheCircuitBreakersValidationError is the validation error returned by
  54. // DnsCacheCircuitBreakers.Validate if the designated constraints aren't met.
  55. type DnsCacheCircuitBreakersValidationError struct {
  56. field string
  57. reason string
  58. cause error
  59. key bool
  60. }
  61. // Field function returns field value.
  62. func (e DnsCacheCircuitBreakersValidationError) Field() string { return e.field }
  63. // Reason function returns reason value.
  64. func (e DnsCacheCircuitBreakersValidationError) Reason() string { return e.reason }
  65. // Cause function returns cause value.
  66. func (e DnsCacheCircuitBreakersValidationError) Cause() error { return e.cause }
  67. // Key function returns key value.
  68. func (e DnsCacheCircuitBreakersValidationError) Key() bool { return e.key }
  69. // ErrorName returns error name.
  70. func (e DnsCacheCircuitBreakersValidationError) ErrorName() string {
  71. return "DnsCacheCircuitBreakersValidationError"
  72. }
  73. // Error satisfies the builtin error interface
  74. func (e DnsCacheCircuitBreakersValidationError) Error() string {
  75. cause := ""
  76. if e.cause != nil {
  77. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  78. }
  79. key := ""
  80. if e.key {
  81. key = "key for "
  82. }
  83. return fmt.Sprintf(
  84. "invalid %sDnsCacheCircuitBreakers.%s: %s%s",
  85. key,
  86. e.field,
  87. e.reason,
  88. cause)
  89. }
  90. var _ error = DnsCacheCircuitBreakersValidationError{}
  91. var _ interface {
  92. Field() string
  93. Reason() string
  94. Key() bool
  95. Cause() error
  96. ErrorName() string
  97. } = DnsCacheCircuitBreakersValidationError{}
  98. // Validate checks the field values on DnsCacheConfig with the rules defined in
  99. // the proto definition for this message. If any rules are violated, an error
  100. // is returned.
  101. func (m *DnsCacheConfig) Validate() error {
  102. if m == nil {
  103. return nil
  104. }
  105. if len(m.GetName()) < 1 {
  106. return DnsCacheConfigValidationError{
  107. field: "Name",
  108. reason: "value length must be at least 1 bytes",
  109. }
  110. }
  111. if _, ok := v3.Cluster_DnsLookupFamily_name[int32(m.GetDnsLookupFamily())]; !ok {
  112. return DnsCacheConfigValidationError{
  113. field: "DnsLookupFamily",
  114. reason: "value must be one of the defined enum values",
  115. }
  116. }
  117. if d := m.GetDnsRefreshRate(); d != nil {
  118. dur, err := ptypes.Duration(d)
  119. if err != nil {
  120. return DnsCacheConfigValidationError{
  121. field: "DnsRefreshRate",
  122. reason: "value is not a valid duration",
  123. cause: err,
  124. }
  125. }
  126. gte := time.Duration(0*time.Second + 1000000*time.Nanosecond)
  127. if dur < gte {
  128. return DnsCacheConfigValidationError{
  129. field: "DnsRefreshRate",
  130. reason: "value must be greater than or equal to 1ms",
  131. }
  132. }
  133. }
  134. if d := m.GetHostTtl(); d != nil {
  135. dur, err := ptypes.Duration(d)
  136. if err != nil {
  137. return DnsCacheConfigValidationError{
  138. field: "HostTtl",
  139. reason: "value is not a valid duration",
  140. cause: err,
  141. }
  142. }
  143. gt := time.Duration(0*time.Second + 0*time.Nanosecond)
  144. if dur <= gt {
  145. return DnsCacheConfigValidationError{
  146. field: "HostTtl",
  147. reason: "value must be greater than 0s",
  148. }
  149. }
  150. }
  151. if wrapper := m.GetMaxHosts(); wrapper != nil {
  152. if wrapper.GetValue() <= 0 {
  153. return DnsCacheConfigValidationError{
  154. field: "MaxHosts",
  155. reason: "value must be greater than 0",
  156. }
  157. }
  158. }
  159. if v, ok := interface{}(m.GetDnsFailureRefreshRate()).(interface{ Validate() error }); ok {
  160. if err := v.Validate(); err != nil {
  161. return DnsCacheConfigValidationError{
  162. field: "DnsFailureRefreshRate",
  163. reason: "embedded message failed validation",
  164. cause: err,
  165. }
  166. }
  167. }
  168. if v, ok := interface{}(m.GetDnsCacheCircuitBreaker()).(interface{ Validate() error }); ok {
  169. if err := v.Validate(); err != nil {
  170. return DnsCacheConfigValidationError{
  171. field: "DnsCacheCircuitBreaker",
  172. reason: "embedded message failed validation",
  173. cause: err,
  174. }
  175. }
  176. }
  177. return nil
  178. }
  179. // DnsCacheConfigValidationError is the validation error returned by
  180. // DnsCacheConfig.Validate if the designated constraints aren't met.
  181. type DnsCacheConfigValidationError struct {
  182. field string
  183. reason string
  184. cause error
  185. key bool
  186. }
  187. // Field function returns field value.
  188. func (e DnsCacheConfigValidationError) Field() string { return e.field }
  189. // Reason function returns reason value.
  190. func (e DnsCacheConfigValidationError) Reason() string { return e.reason }
  191. // Cause function returns cause value.
  192. func (e DnsCacheConfigValidationError) Cause() error { return e.cause }
  193. // Key function returns key value.
  194. func (e DnsCacheConfigValidationError) Key() bool { return e.key }
  195. // ErrorName returns error name.
  196. func (e DnsCacheConfigValidationError) ErrorName() string { return "DnsCacheConfigValidationError" }
  197. // Error satisfies the builtin error interface
  198. func (e DnsCacheConfigValidationError) Error() string {
  199. cause := ""
  200. if e.cause != nil {
  201. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  202. }
  203. key := ""
  204. if e.key {
  205. key = "key for "
  206. }
  207. return fmt.Sprintf(
  208. "invalid %sDnsCacheConfig.%s: %s%s",
  209. key,
  210. e.field,
  211. e.reason,
  212. cause)
  213. }
  214. var _ error = DnsCacheConfigValidationError{}
  215. var _ interface {
  216. Field() string
  217. Reason() string
  218. Key() bool
  219. Cause() error
  220. ErrorName() string
  221. } = DnsCacheConfigValidationError{}