/vendor/github.com/envoyproxy/go-control-plane/envoy/api/v2/core/config_source.pb.validate.go

https://github.com/rancher/rio · Go · 525 lines · 366 code · 98 blank · 61 comment · 62 complexity · 138e8316729ac79b369312971b9afee3 MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/api/v2/core/config_source.proto
  3. package envoy_api_v2_core
  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 _config_source_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 ApiConfigSource with the rules defined
  34. // in the proto definition for this message. If any rules are violated, an
  35. // error is returned.
  36. func (m *ApiConfigSource) Validate() error {
  37. if m == nil {
  38. return nil
  39. }
  40. if _, ok := ApiConfigSource_ApiType_name[int32(m.GetApiType())]; !ok {
  41. return ApiConfigSourceValidationError{
  42. field: "ApiType",
  43. reason: "value must be one of the defined enum values",
  44. }
  45. }
  46. if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
  47. return ApiConfigSourceValidationError{
  48. field: "TransportApiVersion",
  49. reason: "value must be one of the defined enum values",
  50. }
  51. }
  52. for idx, item := range m.GetGrpcServices() {
  53. _, _ = idx, item
  54. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  55. if err := v.Validate(); err != nil {
  56. return ApiConfigSourceValidationError{
  57. field: fmt.Sprintf("GrpcServices[%v]", idx),
  58. reason: "embedded message failed validation",
  59. cause: err,
  60. }
  61. }
  62. }
  63. }
  64. if v, ok := interface{}(m.GetRefreshDelay()).(interface{ Validate() error }); ok {
  65. if err := v.Validate(); err != nil {
  66. return ApiConfigSourceValidationError{
  67. field: "RefreshDelay",
  68. reason: "embedded message failed validation",
  69. cause: err,
  70. }
  71. }
  72. }
  73. if d := m.GetRequestTimeout(); d != nil {
  74. dur, err := ptypes.Duration(d)
  75. if err != nil {
  76. return ApiConfigSourceValidationError{
  77. field: "RequestTimeout",
  78. reason: "value is not a valid duration",
  79. cause: err,
  80. }
  81. }
  82. gt := time.Duration(0*time.Second + 0*time.Nanosecond)
  83. if dur <= gt {
  84. return ApiConfigSourceValidationError{
  85. field: "RequestTimeout",
  86. reason: "value must be greater than 0s",
  87. }
  88. }
  89. }
  90. if v, ok := interface{}(m.GetRateLimitSettings()).(interface{ Validate() error }); ok {
  91. if err := v.Validate(); err != nil {
  92. return ApiConfigSourceValidationError{
  93. field: "RateLimitSettings",
  94. reason: "embedded message failed validation",
  95. cause: err,
  96. }
  97. }
  98. }
  99. // no validation rules for SetNodeOnFirstMessageOnly
  100. return nil
  101. }
  102. // ApiConfigSourceValidationError is the validation error returned by
  103. // ApiConfigSource.Validate if the designated constraints aren't met.
  104. type ApiConfigSourceValidationError struct {
  105. field string
  106. reason string
  107. cause error
  108. key bool
  109. }
  110. // Field function returns field value.
  111. func (e ApiConfigSourceValidationError) Field() string { return e.field }
  112. // Reason function returns reason value.
  113. func (e ApiConfigSourceValidationError) Reason() string { return e.reason }
  114. // Cause function returns cause value.
  115. func (e ApiConfigSourceValidationError) Cause() error { return e.cause }
  116. // Key function returns key value.
  117. func (e ApiConfigSourceValidationError) Key() bool { return e.key }
  118. // ErrorName returns error name.
  119. func (e ApiConfigSourceValidationError) ErrorName() string { return "ApiConfigSourceValidationError" }
  120. // Error satisfies the builtin error interface
  121. func (e ApiConfigSourceValidationError) Error() string {
  122. cause := ""
  123. if e.cause != nil {
  124. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  125. }
  126. key := ""
  127. if e.key {
  128. key = "key for "
  129. }
  130. return fmt.Sprintf(
  131. "invalid %sApiConfigSource.%s: %s%s",
  132. key,
  133. e.field,
  134. e.reason,
  135. cause)
  136. }
  137. var _ error = ApiConfigSourceValidationError{}
  138. var _ interface {
  139. Field() string
  140. Reason() string
  141. Key() bool
  142. Cause() error
  143. ErrorName() string
  144. } = ApiConfigSourceValidationError{}
  145. // Validate checks the field values on AggregatedConfigSource with the rules
  146. // defined in the proto definition for this message. If any rules are
  147. // violated, an error is returned.
  148. func (m *AggregatedConfigSource) Validate() error {
  149. if m == nil {
  150. return nil
  151. }
  152. return nil
  153. }
  154. // AggregatedConfigSourceValidationError is the validation error returned by
  155. // AggregatedConfigSource.Validate if the designated constraints aren't met.
  156. type AggregatedConfigSourceValidationError struct {
  157. field string
  158. reason string
  159. cause error
  160. key bool
  161. }
  162. // Field function returns field value.
  163. func (e AggregatedConfigSourceValidationError) Field() string { return e.field }
  164. // Reason function returns reason value.
  165. func (e AggregatedConfigSourceValidationError) Reason() string { return e.reason }
  166. // Cause function returns cause value.
  167. func (e AggregatedConfigSourceValidationError) Cause() error { return e.cause }
  168. // Key function returns key value.
  169. func (e AggregatedConfigSourceValidationError) Key() bool { return e.key }
  170. // ErrorName returns error name.
  171. func (e AggregatedConfigSourceValidationError) ErrorName() string {
  172. return "AggregatedConfigSourceValidationError"
  173. }
  174. // Error satisfies the builtin error interface
  175. func (e AggregatedConfigSourceValidationError) Error() string {
  176. cause := ""
  177. if e.cause != nil {
  178. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  179. }
  180. key := ""
  181. if e.key {
  182. key = "key for "
  183. }
  184. return fmt.Sprintf(
  185. "invalid %sAggregatedConfigSource.%s: %s%s",
  186. key,
  187. e.field,
  188. e.reason,
  189. cause)
  190. }
  191. var _ error = AggregatedConfigSourceValidationError{}
  192. var _ interface {
  193. Field() string
  194. Reason() string
  195. Key() bool
  196. Cause() error
  197. ErrorName() string
  198. } = AggregatedConfigSourceValidationError{}
  199. // Validate checks the field values on SelfConfigSource with the rules defined
  200. // in the proto definition for this message. If any rules are violated, an
  201. // error is returned.
  202. func (m *SelfConfigSource) Validate() error {
  203. if m == nil {
  204. return nil
  205. }
  206. return nil
  207. }
  208. // SelfConfigSourceValidationError is the validation error returned by
  209. // SelfConfigSource.Validate if the designated constraints aren't met.
  210. type SelfConfigSourceValidationError struct {
  211. field string
  212. reason string
  213. cause error
  214. key bool
  215. }
  216. // Field function returns field value.
  217. func (e SelfConfigSourceValidationError) Field() string { return e.field }
  218. // Reason function returns reason value.
  219. func (e SelfConfigSourceValidationError) Reason() string { return e.reason }
  220. // Cause function returns cause value.
  221. func (e SelfConfigSourceValidationError) Cause() error { return e.cause }
  222. // Key function returns key value.
  223. func (e SelfConfigSourceValidationError) Key() bool { return e.key }
  224. // ErrorName returns error name.
  225. func (e SelfConfigSourceValidationError) ErrorName() string { return "SelfConfigSourceValidationError" }
  226. // Error satisfies the builtin error interface
  227. func (e SelfConfigSourceValidationError) 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 %sSelfConfigSource.%s: %s%s",
  238. key,
  239. e.field,
  240. e.reason,
  241. cause)
  242. }
  243. var _ error = SelfConfigSourceValidationError{}
  244. var _ interface {
  245. Field() string
  246. Reason() string
  247. Key() bool
  248. Cause() error
  249. ErrorName() string
  250. } = SelfConfigSourceValidationError{}
  251. // Validate checks the field values on RateLimitSettings with the rules defined
  252. // in the proto definition for this message. If any rules are violated, an
  253. // error is returned.
  254. func (m *RateLimitSettings) Validate() error {
  255. if m == nil {
  256. return nil
  257. }
  258. if v, ok := interface{}(m.GetMaxTokens()).(interface{ Validate() error }); ok {
  259. if err := v.Validate(); err != nil {
  260. return RateLimitSettingsValidationError{
  261. field: "MaxTokens",
  262. reason: "embedded message failed validation",
  263. cause: err,
  264. }
  265. }
  266. }
  267. if wrapper := m.GetFillRate(); wrapper != nil {
  268. if wrapper.GetValue() <= 0 {
  269. return RateLimitSettingsValidationError{
  270. field: "FillRate",
  271. reason: "value must be greater than 0",
  272. }
  273. }
  274. }
  275. return nil
  276. }
  277. // RateLimitSettingsValidationError is the validation error returned by
  278. // RateLimitSettings.Validate if the designated constraints aren't met.
  279. type RateLimitSettingsValidationError struct {
  280. field string
  281. reason string
  282. cause error
  283. key bool
  284. }
  285. // Field function returns field value.
  286. func (e RateLimitSettingsValidationError) Field() string { return e.field }
  287. // Reason function returns reason value.
  288. func (e RateLimitSettingsValidationError) Reason() string { return e.reason }
  289. // Cause function returns cause value.
  290. func (e RateLimitSettingsValidationError) Cause() error { return e.cause }
  291. // Key function returns key value.
  292. func (e RateLimitSettingsValidationError) Key() bool { return e.key }
  293. // ErrorName returns error name.
  294. func (e RateLimitSettingsValidationError) ErrorName() string {
  295. return "RateLimitSettingsValidationError"
  296. }
  297. // Error satisfies the builtin error interface
  298. func (e RateLimitSettingsValidationError) Error() string {
  299. cause := ""
  300. if e.cause != nil {
  301. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  302. }
  303. key := ""
  304. if e.key {
  305. key = "key for "
  306. }
  307. return fmt.Sprintf(
  308. "invalid %sRateLimitSettings.%s: %s%s",
  309. key,
  310. e.field,
  311. e.reason,
  312. cause)
  313. }
  314. var _ error = RateLimitSettingsValidationError{}
  315. var _ interface {
  316. Field() string
  317. Reason() string
  318. Key() bool
  319. Cause() error
  320. ErrorName() string
  321. } = RateLimitSettingsValidationError{}
  322. // Validate checks the field values on ConfigSource with the rules defined in
  323. // the proto definition for this message. If any rules are violated, an error
  324. // is returned.
  325. func (m *ConfigSource) Validate() error {
  326. if m == nil {
  327. return nil
  328. }
  329. if v, ok := interface{}(m.GetInitialFetchTimeout()).(interface{ Validate() error }); ok {
  330. if err := v.Validate(); err != nil {
  331. return ConfigSourceValidationError{
  332. field: "InitialFetchTimeout",
  333. reason: "embedded message failed validation",
  334. cause: err,
  335. }
  336. }
  337. }
  338. if _, ok := ApiVersion_name[int32(m.GetResourceApiVersion())]; !ok {
  339. return ConfigSourceValidationError{
  340. field: "ResourceApiVersion",
  341. reason: "value must be one of the defined enum values",
  342. }
  343. }
  344. switch m.ConfigSourceSpecifier.(type) {
  345. case *ConfigSource_Path:
  346. // no validation rules for Path
  347. case *ConfigSource_ApiConfigSource:
  348. if v, ok := interface{}(m.GetApiConfigSource()).(interface{ Validate() error }); ok {
  349. if err := v.Validate(); err != nil {
  350. return ConfigSourceValidationError{
  351. field: "ApiConfigSource",
  352. reason: "embedded message failed validation",
  353. cause: err,
  354. }
  355. }
  356. }
  357. case *ConfigSource_Ads:
  358. if v, ok := interface{}(m.GetAds()).(interface{ Validate() error }); ok {
  359. if err := v.Validate(); err != nil {
  360. return ConfigSourceValidationError{
  361. field: "Ads",
  362. reason: "embedded message failed validation",
  363. cause: err,
  364. }
  365. }
  366. }
  367. case *ConfigSource_Self:
  368. if v, ok := interface{}(m.GetSelf()).(interface{ Validate() error }); ok {
  369. if err := v.Validate(); err != nil {
  370. return ConfigSourceValidationError{
  371. field: "Self",
  372. reason: "embedded message failed validation",
  373. cause: err,
  374. }
  375. }
  376. }
  377. default:
  378. return ConfigSourceValidationError{
  379. field: "ConfigSourceSpecifier",
  380. reason: "value is required",
  381. }
  382. }
  383. return nil
  384. }
  385. // ConfigSourceValidationError is the validation error returned by
  386. // ConfigSource.Validate if the designated constraints aren't met.
  387. type ConfigSourceValidationError struct {
  388. field string
  389. reason string
  390. cause error
  391. key bool
  392. }
  393. // Field function returns field value.
  394. func (e ConfigSourceValidationError) Field() string { return e.field }
  395. // Reason function returns reason value.
  396. func (e ConfigSourceValidationError) Reason() string { return e.reason }
  397. // Cause function returns cause value.
  398. func (e ConfigSourceValidationError) Cause() error { return e.cause }
  399. // Key function returns key value.
  400. func (e ConfigSourceValidationError) Key() bool { return e.key }
  401. // ErrorName returns error name.
  402. func (e ConfigSourceValidationError) ErrorName() string { return "ConfigSourceValidationError" }
  403. // Error satisfies the builtin error interface
  404. func (e ConfigSourceValidationError) Error() string {
  405. cause := ""
  406. if e.cause != nil {
  407. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  408. }
  409. key := ""
  410. if e.key {
  411. key = "key for "
  412. }
  413. return fmt.Sprintf(
  414. "invalid %sConfigSource.%s: %s%s",
  415. key,
  416. e.field,
  417. e.reason,
  418. cause)
  419. }
  420. var _ error = ConfigSourceValidationError{}
  421. var _ interface {
  422. Field() string
  423. Reason() string
  424. Key() bool
  425. Cause() error
  426. ErrorName() string
  427. } = ConfigSourceValidationError{}