1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: envoy/config/core/v3/config_source.proto
3
4package envoy_config_core_v3
5
6import (
7	"bytes"
8	"errors"
9	"fmt"
10	"net"
11	"net/mail"
12	"net/url"
13	"regexp"
14	"strings"
15	"time"
16	"unicode/utf8"
17
18	"github.com/golang/protobuf/ptypes"
19)
20
21// ensure the imports are used
22var (
23	_ = bytes.MinRead
24	_ = errors.New("")
25	_ = fmt.Print
26	_ = utf8.UTFMax
27	_ = (*regexp.Regexp)(nil)
28	_ = (*strings.Reader)(nil)
29	_ = net.IPv4len
30	_ = time.Duration(0)
31	_ = (*url.URL)(nil)
32	_ = (*mail.Address)(nil)
33	_ = ptypes.DynamicAny{}
34)
35
36// define the regex for a UUID once up-front
37var _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}$")
38
39// Validate checks the field values on ApiConfigSource with the rules defined
40// in the proto definition for this message. If any rules are violated, an
41// error is returned.
42func (m *ApiConfigSource) Validate() error {
43	if m == nil {
44		return nil
45	}
46
47	if _, ok := ApiConfigSource_ApiType_name[int32(m.GetApiType())]; !ok {
48		return ApiConfigSourceValidationError{
49			field:  "ApiType",
50			reason: "value must be one of the defined enum values",
51		}
52	}
53
54	if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
55		return ApiConfigSourceValidationError{
56			field:  "TransportApiVersion",
57			reason: "value must be one of the defined enum values",
58		}
59	}
60
61	for idx, item := range m.GetGrpcServices() {
62		_, _ = idx, item
63
64		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
65			if err := v.Validate(); err != nil {
66				return ApiConfigSourceValidationError{
67					field:  fmt.Sprintf("GrpcServices[%v]", idx),
68					reason: "embedded message failed validation",
69					cause:  err,
70				}
71			}
72		}
73
74	}
75
76	if v, ok := interface{}(m.GetRefreshDelay()).(interface{ Validate() error }); ok {
77		if err := v.Validate(); err != nil {
78			return ApiConfigSourceValidationError{
79				field:  "RefreshDelay",
80				reason: "embedded message failed validation",
81				cause:  err,
82			}
83		}
84	}
85
86	if d := m.GetRequestTimeout(); d != nil {
87		dur, err := ptypes.Duration(d)
88		if err != nil {
89			return ApiConfigSourceValidationError{
90				field:  "RequestTimeout",
91				reason: "value is not a valid duration",
92				cause:  err,
93			}
94		}
95
96		gt := time.Duration(0*time.Second + 0*time.Nanosecond)
97
98		if dur <= gt {
99			return ApiConfigSourceValidationError{
100				field:  "RequestTimeout",
101				reason: "value must be greater than 0s",
102			}
103		}
104
105	}
106
107	if v, ok := interface{}(m.GetRateLimitSettings()).(interface{ Validate() error }); ok {
108		if err := v.Validate(); err != nil {
109			return ApiConfigSourceValidationError{
110				field:  "RateLimitSettings",
111				reason: "embedded message failed validation",
112				cause:  err,
113			}
114		}
115	}
116
117	// no validation rules for SetNodeOnFirstMessageOnly
118
119	return nil
120}
121
122// ApiConfigSourceValidationError is the validation error returned by
123// ApiConfigSource.Validate if the designated constraints aren't met.
124type ApiConfigSourceValidationError struct {
125	field  string
126	reason string
127	cause  error
128	key    bool
129}
130
131// Field function returns field value.
132func (e ApiConfigSourceValidationError) Field() string { return e.field }
133
134// Reason function returns reason value.
135func (e ApiConfigSourceValidationError) Reason() string { return e.reason }
136
137// Cause function returns cause value.
138func (e ApiConfigSourceValidationError) Cause() error { return e.cause }
139
140// Key function returns key value.
141func (e ApiConfigSourceValidationError) Key() bool { return e.key }
142
143// ErrorName returns error name.
144func (e ApiConfigSourceValidationError) ErrorName() string { return "ApiConfigSourceValidationError" }
145
146// Error satisfies the builtin error interface
147func (e ApiConfigSourceValidationError) Error() string {
148	cause := ""
149	if e.cause != nil {
150		cause = fmt.Sprintf(" | caused by: %v", e.cause)
151	}
152
153	key := ""
154	if e.key {
155		key = "key for "
156	}
157
158	return fmt.Sprintf(
159		"invalid %sApiConfigSource.%s: %s%s",
160		key,
161		e.field,
162		e.reason,
163		cause)
164}
165
166var _ error = ApiConfigSourceValidationError{}
167
168var _ interface {
169	Field() string
170	Reason() string
171	Key() bool
172	Cause() error
173	ErrorName() string
174} = ApiConfigSourceValidationError{}
175
176// Validate checks the field values on AggregatedConfigSource with the rules
177// defined in the proto definition for this message. If any rules are
178// violated, an error is returned.
179func (m *AggregatedConfigSource) Validate() error {
180	if m == nil {
181		return nil
182	}
183
184	return nil
185}
186
187// AggregatedConfigSourceValidationError is the validation error returned by
188// AggregatedConfigSource.Validate if the designated constraints aren't met.
189type AggregatedConfigSourceValidationError struct {
190	field  string
191	reason string
192	cause  error
193	key    bool
194}
195
196// Field function returns field value.
197func (e AggregatedConfigSourceValidationError) Field() string { return e.field }
198
199// Reason function returns reason value.
200func (e AggregatedConfigSourceValidationError) Reason() string { return e.reason }
201
202// Cause function returns cause value.
203func (e AggregatedConfigSourceValidationError) Cause() error { return e.cause }
204
205// Key function returns key value.
206func (e AggregatedConfigSourceValidationError) Key() bool { return e.key }
207
208// ErrorName returns error name.
209func (e AggregatedConfigSourceValidationError) ErrorName() string {
210	return "AggregatedConfigSourceValidationError"
211}
212
213// Error satisfies the builtin error interface
214func (e AggregatedConfigSourceValidationError) Error() string {
215	cause := ""
216	if e.cause != nil {
217		cause = fmt.Sprintf(" | caused by: %v", e.cause)
218	}
219
220	key := ""
221	if e.key {
222		key = "key for "
223	}
224
225	return fmt.Sprintf(
226		"invalid %sAggregatedConfigSource.%s: %s%s",
227		key,
228		e.field,
229		e.reason,
230		cause)
231}
232
233var _ error = AggregatedConfigSourceValidationError{}
234
235var _ interface {
236	Field() string
237	Reason() string
238	Key() bool
239	Cause() error
240	ErrorName() string
241} = AggregatedConfigSourceValidationError{}
242
243// Validate checks the field values on SelfConfigSource with the rules defined
244// in the proto definition for this message. If any rules are violated, an
245// error is returned.
246func (m *SelfConfigSource) Validate() error {
247	if m == nil {
248		return nil
249	}
250
251	return nil
252}
253
254// SelfConfigSourceValidationError is the validation error returned by
255// SelfConfigSource.Validate if the designated constraints aren't met.
256type SelfConfigSourceValidationError struct {
257	field  string
258	reason string
259	cause  error
260	key    bool
261}
262
263// Field function returns field value.
264func (e SelfConfigSourceValidationError) Field() string { return e.field }
265
266// Reason function returns reason value.
267func (e SelfConfigSourceValidationError) Reason() string { return e.reason }
268
269// Cause function returns cause value.
270func (e SelfConfigSourceValidationError) Cause() error { return e.cause }
271
272// Key function returns key value.
273func (e SelfConfigSourceValidationError) Key() bool { return e.key }
274
275// ErrorName returns error name.
276func (e SelfConfigSourceValidationError) ErrorName() string { return "SelfConfigSourceValidationError" }
277
278// Error satisfies the builtin error interface
279func (e SelfConfigSourceValidationError) Error() string {
280	cause := ""
281	if e.cause != nil {
282		cause = fmt.Sprintf(" | caused by: %v", e.cause)
283	}
284
285	key := ""
286	if e.key {
287		key = "key for "
288	}
289
290	return fmt.Sprintf(
291		"invalid %sSelfConfigSource.%s: %s%s",
292		key,
293		e.field,
294		e.reason,
295		cause)
296}
297
298var _ error = SelfConfigSourceValidationError{}
299
300var _ interface {
301	Field() string
302	Reason() string
303	Key() bool
304	Cause() error
305	ErrorName() string
306} = SelfConfigSourceValidationError{}
307
308// Validate checks the field values on RateLimitSettings with the rules defined
309// in the proto definition for this message. If any rules are violated, an
310// error is returned.
311func (m *RateLimitSettings) Validate() error {
312	if m == nil {
313		return nil
314	}
315
316	if v, ok := interface{}(m.GetMaxTokens()).(interface{ Validate() error }); ok {
317		if err := v.Validate(); err != nil {
318			return RateLimitSettingsValidationError{
319				field:  "MaxTokens",
320				reason: "embedded message failed validation",
321				cause:  err,
322			}
323		}
324	}
325
326	if wrapper := m.GetFillRate(); wrapper != nil {
327
328		if wrapper.GetValue() <= 0 {
329			return RateLimitSettingsValidationError{
330				field:  "FillRate",
331				reason: "value must be greater than 0",
332			}
333		}
334
335	}
336
337	return nil
338}
339
340// RateLimitSettingsValidationError is the validation error returned by
341// RateLimitSettings.Validate if the designated constraints aren't met.
342type RateLimitSettingsValidationError struct {
343	field  string
344	reason string
345	cause  error
346	key    bool
347}
348
349// Field function returns field value.
350func (e RateLimitSettingsValidationError) Field() string { return e.field }
351
352// Reason function returns reason value.
353func (e RateLimitSettingsValidationError) Reason() string { return e.reason }
354
355// Cause function returns cause value.
356func (e RateLimitSettingsValidationError) Cause() error { return e.cause }
357
358// Key function returns key value.
359func (e RateLimitSettingsValidationError) Key() bool { return e.key }
360
361// ErrorName returns error name.
362func (e RateLimitSettingsValidationError) ErrorName() string {
363	return "RateLimitSettingsValidationError"
364}
365
366// Error satisfies the builtin error interface
367func (e RateLimitSettingsValidationError) Error() string {
368	cause := ""
369	if e.cause != nil {
370		cause = fmt.Sprintf(" | caused by: %v", e.cause)
371	}
372
373	key := ""
374	if e.key {
375		key = "key for "
376	}
377
378	return fmt.Sprintf(
379		"invalid %sRateLimitSettings.%s: %s%s",
380		key,
381		e.field,
382		e.reason,
383		cause)
384}
385
386var _ error = RateLimitSettingsValidationError{}
387
388var _ interface {
389	Field() string
390	Reason() string
391	Key() bool
392	Cause() error
393	ErrorName() string
394} = RateLimitSettingsValidationError{}
395
396// Validate checks the field values on ConfigSource with the rules defined in
397// the proto definition for this message. If any rules are violated, an error
398// is returned.
399func (m *ConfigSource) Validate() error {
400	if m == nil {
401		return nil
402	}
403
404	if v, ok := interface{}(m.GetInitialFetchTimeout()).(interface{ Validate() error }); ok {
405		if err := v.Validate(); err != nil {
406			return ConfigSourceValidationError{
407				field:  "InitialFetchTimeout",
408				reason: "embedded message failed validation",
409				cause:  err,
410			}
411		}
412	}
413
414	if _, ok := ApiVersion_name[int32(m.GetResourceApiVersion())]; !ok {
415		return ConfigSourceValidationError{
416			field:  "ResourceApiVersion",
417			reason: "value must be one of the defined enum values",
418		}
419	}
420
421	switch m.ConfigSourceSpecifier.(type) {
422
423	case *ConfigSource_Path:
424		// no validation rules for Path
425
426	case *ConfigSource_ApiConfigSource:
427
428		if v, ok := interface{}(m.GetApiConfigSource()).(interface{ Validate() error }); ok {
429			if err := v.Validate(); err != nil {
430				return ConfigSourceValidationError{
431					field:  "ApiConfigSource",
432					reason: "embedded message failed validation",
433					cause:  err,
434				}
435			}
436		}
437
438	case *ConfigSource_Ads:
439
440		if v, ok := interface{}(m.GetAds()).(interface{ Validate() error }); ok {
441			if err := v.Validate(); err != nil {
442				return ConfigSourceValidationError{
443					field:  "Ads",
444					reason: "embedded message failed validation",
445					cause:  err,
446				}
447			}
448		}
449
450	case *ConfigSource_Self:
451
452		if v, ok := interface{}(m.GetSelf()).(interface{ Validate() error }); ok {
453			if err := v.Validate(); err != nil {
454				return ConfigSourceValidationError{
455					field:  "Self",
456					reason: "embedded message failed validation",
457					cause:  err,
458				}
459			}
460		}
461
462	default:
463		return ConfigSourceValidationError{
464			field:  "ConfigSourceSpecifier",
465			reason: "value is required",
466		}
467
468	}
469
470	return nil
471}
472
473// ConfigSourceValidationError is the validation error returned by
474// ConfigSource.Validate if the designated constraints aren't met.
475type ConfigSourceValidationError struct {
476	field  string
477	reason string
478	cause  error
479	key    bool
480}
481
482// Field function returns field value.
483func (e ConfigSourceValidationError) Field() string { return e.field }
484
485// Reason function returns reason value.
486func (e ConfigSourceValidationError) Reason() string { return e.reason }
487
488// Cause function returns cause value.
489func (e ConfigSourceValidationError) Cause() error { return e.cause }
490
491// Key function returns key value.
492func (e ConfigSourceValidationError) Key() bool { return e.key }
493
494// ErrorName returns error name.
495func (e ConfigSourceValidationError) ErrorName() string { return "ConfigSourceValidationError" }
496
497// Error satisfies the builtin error interface
498func (e ConfigSourceValidationError) Error() string {
499	cause := ""
500	if e.cause != nil {
501		cause = fmt.Sprintf(" | caused by: %v", e.cause)
502	}
503
504	key := ""
505	if e.key {
506		key = "key for "
507	}
508
509	return fmt.Sprintf(
510		"invalid %sConfigSource.%s: %s%s",
511		key,
512		e.field,
513		e.reason,
514		cause)
515}
516
517var _ error = ConfigSourceValidationError{}
518
519var _ interface {
520	Field() string
521	Reason() string
522	Key() bool
523	Cause() error
524	ErrorName() string
525} = ConfigSourceValidationError{}
526