/pkg/api/envoy/config/core/v3/config_source.pb.validate.go

https://github.com/datawire/ambassador · Go · 547 lines · 384 code · 102 blank · 61 comment · 67 complexity · ce9a2b1e9ba1309bd0a2f62ea197053f MD5 · raw file

  1. // Code generated by protoc-gen-validate. DO NOT EDIT.
  2. // source: envoy/config/core/v3/config_source.proto
  3. package envoy_config_core_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 _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. if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
  207. return SelfConfigSourceValidationError{
  208. field: "TransportApiVersion",
  209. reason: "value must be one of the defined enum values",
  210. }
  211. }
  212. return nil
  213. }
  214. // SelfConfigSourceValidationError is the validation error returned by
  215. // SelfConfigSource.Validate if the designated constraints aren't met.
  216. type SelfConfigSourceValidationError struct {
  217. field string
  218. reason string
  219. cause error
  220. key bool
  221. }
  222. // Field function returns field value.
  223. func (e SelfConfigSourceValidationError) Field() string { return e.field }
  224. // Reason function returns reason value.
  225. func (e SelfConfigSourceValidationError) Reason() string { return e.reason }
  226. // Cause function returns cause value.
  227. func (e SelfConfigSourceValidationError) Cause() error { return e.cause }
  228. // Key function returns key value.
  229. func (e SelfConfigSourceValidationError) Key() bool { return e.key }
  230. // ErrorName returns error name.
  231. func (e SelfConfigSourceValidationError) ErrorName() string { return "SelfConfigSourceValidationError" }
  232. // Error satisfies the builtin error interface
  233. func (e SelfConfigSourceValidationError) Error() string {
  234. cause := ""
  235. if e.cause != nil {
  236. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  237. }
  238. key := ""
  239. if e.key {
  240. key = "key for "
  241. }
  242. return fmt.Sprintf(
  243. "invalid %sSelfConfigSource.%s: %s%s",
  244. key,
  245. e.field,
  246. e.reason,
  247. cause)
  248. }
  249. var _ error = SelfConfigSourceValidationError{}
  250. var _ interface {
  251. Field() string
  252. Reason() string
  253. Key() bool
  254. Cause() error
  255. ErrorName() string
  256. } = SelfConfigSourceValidationError{}
  257. // Validate checks the field values on RateLimitSettings with the rules defined
  258. // in the proto definition for this message. If any rules are violated, an
  259. // error is returned.
  260. func (m *RateLimitSettings) Validate() error {
  261. if m == nil {
  262. return nil
  263. }
  264. if v, ok := interface{}(m.GetMaxTokens()).(interface{ Validate() error }); ok {
  265. if err := v.Validate(); err != nil {
  266. return RateLimitSettingsValidationError{
  267. field: "MaxTokens",
  268. reason: "embedded message failed validation",
  269. cause: err,
  270. }
  271. }
  272. }
  273. if wrapper := m.GetFillRate(); wrapper != nil {
  274. if wrapper.GetValue() <= 0 {
  275. return RateLimitSettingsValidationError{
  276. field: "FillRate",
  277. reason: "value must be greater than 0",
  278. }
  279. }
  280. }
  281. return nil
  282. }
  283. // RateLimitSettingsValidationError is the validation error returned by
  284. // RateLimitSettings.Validate if the designated constraints aren't met.
  285. type RateLimitSettingsValidationError struct {
  286. field string
  287. reason string
  288. cause error
  289. key bool
  290. }
  291. // Field function returns field value.
  292. func (e RateLimitSettingsValidationError) Field() string { return e.field }
  293. // Reason function returns reason value.
  294. func (e RateLimitSettingsValidationError) Reason() string { return e.reason }
  295. // Cause function returns cause value.
  296. func (e RateLimitSettingsValidationError) Cause() error { return e.cause }
  297. // Key function returns key value.
  298. func (e RateLimitSettingsValidationError) Key() bool { return e.key }
  299. // ErrorName returns error name.
  300. func (e RateLimitSettingsValidationError) ErrorName() string {
  301. return "RateLimitSettingsValidationError"
  302. }
  303. // Error satisfies the builtin error interface
  304. func (e RateLimitSettingsValidationError) Error() string {
  305. cause := ""
  306. if e.cause != nil {
  307. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  308. }
  309. key := ""
  310. if e.key {
  311. key = "key for "
  312. }
  313. return fmt.Sprintf(
  314. "invalid %sRateLimitSettings.%s: %s%s",
  315. key,
  316. e.field,
  317. e.reason,
  318. cause)
  319. }
  320. var _ error = RateLimitSettingsValidationError{}
  321. var _ interface {
  322. Field() string
  323. Reason() string
  324. Key() bool
  325. Cause() error
  326. ErrorName() string
  327. } = RateLimitSettingsValidationError{}
  328. // Validate checks the field values on ConfigSource with the rules defined in
  329. // the proto definition for this message. If any rules are violated, an error
  330. // is returned.
  331. func (m *ConfigSource) Validate() error {
  332. if m == nil {
  333. return nil
  334. }
  335. for idx, item := range m.GetAuthorities() {
  336. _, _ = idx, item
  337. if v, ok := interface{}(item).(interface{ Validate() error }); ok {
  338. if err := v.Validate(); err != nil {
  339. return ConfigSourceValidationError{
  340. field: fmt.Sprintf("Authorities[%v]", idx),
  341. reason: "embedded message failed validation",
  342. cause: err,
  343. }
  344. }
  345. }
  346. }
  347. if v, ok := interface{}(m.GetInitialFetchTimeout()).(interface{ Validate() error }); ok {
  348. if err := v.Validate(); err != nil {
  349. return ConfigSourceValidationError{
  350. field: "InitialFetchTimeout",
  351. reason: "embedded message failed validation",
  352. cause: err,
  353. }
  354. }
  355. }
  356. if _, ok := ApiVersion_name[int32(m.GetResourceApiVersion())]; !ok {
  357. return ConfigSourceValidationError{
  358. field: "ResourceApiVersion",
  359. reason: "value must be one of the defined enum values",
  360. }
  361. }
  362. switch m.ConfigSourceSpecifier.(type) {
  363. case *ConfigSource_Path:
  364. // no validation rules for Path
  365. case *ConfigSource_ApiConfigSource:
  366. if v, ok := interface{}(m.GetApiConfigSource()).(interface{ Validate() error }); ok {
  367. if err := v.Validate(); err != nil {
  368. return ConfigSourceValidationError{
  369. field: "ApiConfigSource",
  370. reason: "embedded message failed validation",
  371. cause: err,
  372. }
  373. }
  374. }
  375. case *ConfigSource_Ads:
  376. if v, ok := interface{}(m.GetAds()).(interface{ Validate() error }); ok {
  377. if err := v.Validate(); err != nil {
  378. return ConfigSourceValidationError{
  379. field: "Ads",
  380. reason: "embedded message failed validation",
  381. cause: err,
  382. }
  383. }
  384. }
  385. case *ConfigSource_Self:
  386. if v, ok := interface{}(m.GetSelf()).(interface{ Validate() error }); ok {
  387. if err := v.Validate(); err != nil {
  388. return ConfigSourceValidationError{
  389. field: "Self",
  390. reason: "embedded message failed validation",
  391. cause: err,
  392. }
  393. }
  394. }
  395. default:
  396. return ConfigSourceValidationError{
  397. field: "ConfigSourceSpecifier",
  398. reason: "value is required",
  399. }
  400. }
  401. return nil
  402. }
  403. // ConfigSourceValidationError is the validation error returned by
  404. // ConfigSource.Validate if the designated constraints aren't met.
  405. type ConfigSourceValidationError struct {
  406. field string
  407. reason string
  408. cause error
  409. key bool
  410. }
  411. // Field function returns field value.
  412. func (e ConfigSourceValidationError) Field() string { return e.field }
  413. // Reason function returns reason value.
  414. func (e ConfigSourceValidationError) Reason() string { return e.reason }
  415. // Cause function returns cause value.
  416. func (e ConfigSourceValidationError) Cause() error { return e.cause }
  417. // Key function returns key value.
  418. func (e ConfigSourceValidationError) Key() bool { return e.key }
  419. // ErrorName returns error name.
  420. func (e ConfigSourceValidationError) ErrorName() string { return "ConfigSourceValidationError" }
  421. // Error satisfies the builtin error interface
  422. func (e ConfigSourceValidationError) Error() string {
  423. cause := ""
  424. if e.cause != nil {
  425. cause = fmt.Sprintf(" | caused by: %v", e.cause)
  426. }
  427. key := ""
  428. if e.key {
  429. key = "key for "
  430. }
  431. return fmt.Sprintf(
  432. "invalid %sConfigSource.%s: %s%s",
  433. key,
  434. e.field,
  435. e.reason,
  436. cause)
  437. }
  438. var _ error = ConfigSourceValidationError{}
  439. var _ interface {
  440. Field() string
  441. Reason() string
  442. Key() bool
  443. Cause() error
  444. ErrorName() string
  445. } = ConfigSourceValidationError{}