1
2
3
4 package envoy_config_endpoint_v3
5
6 import (
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
22 var (
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
37
38
39 func (m *ClusterLoadAssignment) Validate() error {
40 if m == nil {
41 return nil
42 }
43
44 if utf8.RuneCountInString(m.GetClusterName()) < 1 {
45 return ClusterLoadAssignmentValidationError{
46 field: "ClusterName",
47 reason: "value length must be at least 1 runes",
48 }
49 }
50
51 for idx, item := range m.GetEndpoints() {
52 _, _ = idx, item
53
54 if v, ok := interface{}(item).(interface{ Validate() error }); ok {
55 if err := v.Validate(); err != nil {
56 return ClusterLoadAssignmentValidationError{
57 field: fmt.Sprintf("Endpoints[%v]", idx),
58 reason: "embedded message failed validation",
59 cause: err,
60 }
61 }
62 }
63
64 }
65
66 for key, val := range m.GetNamedEndpoints() {
67 _ = val
68
69
70
71 if v, ok := interface{}(val).(interface{ Validate() error }); ok {
72 if err := v.Validate(); err != nil {
73 return ClusterLoadAssignmentValidationError{
74 field: fmt.Sprintf("NamedEndpoints[%v]", key),
75 reason: "embedded message failed validation",
76 cause: err,
77 }
78 }
79 }
80
81 }
82
83 if v, ok := interface{}(m.GetPolicy()).(interface{ Validate() error }); ok {
84 if err := v.Validate(); err != nil {
85 return ClusterLoadAssignmentValidationError{
86 field: "Policy",
87 reason: "embedded message failed validation",
88 cause: err,
89 }
90 }
91 }
92
93 return nil
94 }
95
96
97
98 type ClusterLoadAssignmentValidationError struct {
99 field string
100 reason string
101 cause error
102 key bool
103 }
104
105
106 func (e ClusterLoadAssignmentValidationError) Field() string { return e.field }
107
108
109 func (e ClusterLoadAssignmentValidationError) Reason() string { return e.reason }
110
111
112 func (e ClusterLoadAssignmentValidationError) Cause() error { return e.cause }
113
114
115 func (e ClusterLoadAssignmentValidationError) Key() bool { return e.key }
116
117
118 func (e ClusterLoadAssignmentValidationError) ErrorName() string {
119 return "ClusterLoadAssignmentValidationError"
120 }
121
122
123 func (e ClusterLoadAssignmentValidationError) Error() string {
124 cause := ""
125 if e.cause != nil {
126 cause = fmt.Sprintf(" | caused by: %v", e.cause)
127 }
128
129 key := ""
130 if e.key {
131 key = "key for "
132 }
133
134 return fmt.Sprintf(
135 "invalid %sClusterLoadAssignment.%s: %s%s",
136 key,
137 e.field,
138 e.reason,
139 cause)
140 }
141
142 var _ error = ClusterLoadAssignmentValidationError{}
143
144 var _ interface {
145 Field() string
146 Reason() string
147 Key() bool
148 Cause() error
149 ErrorName() string
150 } = ClusterLoadAssignmentValidationError{}
151
152
153
154
155 func (m *ClusterLoadAssignment_Policy) Validate() error {
156 if m == nil {
157 return nil
158 }
159
160 for idx, item := range m.GetDropOverloads() {
161 _, _ = idx, item
162
163 if v, ok := interface{}(item).(interface{ Validate() error }); ok {
164 if err := v.Validate(); err != nil {
165 return ClusterLoadAssignment_PolicyValidationError{
166 field: fmt.Sprintf("DropOverloads[%v]", idx),
167 reason: "embedded message failed validation",
168 cause: err,
169 }
170 }
171 }
172
173 }
174
175 if wrapper := m.GetOverprovisioningFactor(); wrapper != nil {
176
177 if wrapper.GetValue() <= 0 {
178 return ClusterLoadAssignment_PolicyValidationError{
179 field: "OverprovisioningFactor",
180 reason: "value must be greater than 0",
181 }
182 }
183
184 }
185
186 if d := m.GetEndpointStaleAfter(); d != nil {
187 dur, err := ptypes.Duration(d)
188 if err != nil {
189 return ClusterLoadAssignment_PolicyValidationError{
190 field: "EndpointStaleAfter",
191 reason: "value is not a valid duration",
192 cause: err,
193 }
194 }
195
196 gt := time.Duration(0*time.Second + 0*time.Nanosecond)
197
198 if dur <= gt {
199 return ClusterLoadAssignment_PolicyValidationError{
200 field: "EndpointStaleAfter",
201 reason: "value must be greater than 0s",
202 }
203 }
204
205 }
206
207
208
209 return nil
210 }
211
212
213
214
215 type ClusterLoadAssignment_PolicyValidationError struct {
216 field string
217 reason string
218 cause error
219 key bool
220 }
221
222
223 func (e ClusterLoadAssignment_PolicyValidationError) Field() string { return e.field }
224
225
226 func (e ClusterLoadAssignment_PolicyValidationError) Reason() string { return e.reason }
227
228
229 func (e ClusterLoadAssignment_PolicyValidationError) Cause() error { return e.cause }
230
231
232 func (e ClusterLoadAssignment_PolicyValidationError) Key() bool { return e.key }
233
234
235 func (e ClusterLoadAssignment_PolicyValidationError) ErrorName() string {
236 return "ClusterLoadAssignment_PolicyValidationError"
237 }
238
239
240 func (e ClusterLoadAssignment_PolicyValidationError) Error() string {
241 cause := ""
242 if e.cause != nil {
243 cause = fmt.Sprintf(" | caused by: %v", e.cause)
244 }
245
246 key := ""
247 if e.key {
248 key = "key for "
249 }
250
251 return fmt.Sprintf(
252 "invalid %sClusterLoadAssignment_Policy.%s: %s%s",
253 key,
254 e.field,
255 e.reason,
256 cause)
257 }
258
259 var _ error = ClusterLoadAssignment_PolicyValidationError{}
260
261 var _ interface {
262 Field() string
263 Reason() string
264 Key() bool
265 Cause() error
266 ErrorName() string
267 } = ClusterLoadAssignment_PolicyValidationError{}
268
269
270
271
272 func (m *ClusterLoadAssignment_Policy_DropOverload) Validate() error {
273 if m == nil {
274 return nil
275 }
276
277 if utf8.RuneCountInString(m.GetCategory()) < 1 {
278 return ClusterLoadAssignment_Policy_DropOverloadValidationError{
279 field: "Category",
280 reason: "value length must be at least 1 runes",
281 }
282 }
283
284 if v, ok := interface{}(m.GetDropPercentage()).(interface{ Validate() error }); ok {
285 if err := v.Validate(); err != nil {
286 return ClusterLoadAssignment_Policy_DropOverloadValidationError{
287 field: "DropPercentage",
288 reason: "embedded message failed validation",
289 cause: err,
290 }
291 }
292 }
293
294 return nil
295 }
296
297
298
299
300 type ClusterLoadAssignment_Policy_DropOverloadValidationError struct {
301 field string
302 reason string
303 cause error
304 key bool
305 }
306
307
308 func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Field() string { return e.field }
309
310
311 func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Reason() string { return e.reason }
312
313
314 func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Cause() error { return e.cause }
315
316
317 func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Key() bool { return e.key }
318
319
320 func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) ErrorName() string {
321 return "ClusterLoadAssignment_Policy_DropOverloadValidationError"
322 }
323
324
325 func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Error() string {
326 cause := ""
327 if e.cause != nil {
328 cause = fmt.Sprintf(" | caused by: %v", e.cause)
329 }
330
331 key := ""
332 if e.key {
333 key = "key for "
334 }
335
336 return fmt.Sprintf(
337 "invalid %sClusterLoadAssignment_Policy_DropOverload.%s: %s%s",
338 key,
339 e.field,
340 e.reason,
341 cause)
342 }
343
344 var _ error = ClusterLoadAssignment_Policy_DropOverloadValidationError{}
345
346 var _ interface {
347 Field() string
348 Reason() string
349 Key() bool
350 Cause() error
351 ErrorName() string
352 } = ClusterLoadAssignment_Policy_DropOverloadValidationError{}
353
View as plain text