1
2
3
4 package v2alpha
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "sort"
15 "strings"
16 "time"
17 "unicode/utf8"
18
19 "google.golang.org/protobuf/types/known/anypb"
20 )
21
22
23 var (
24 _ = bytes.MinRead
25 _ = errors.New("")
26 _ = fmt.Print
27 _ = utf8.UTFMax
28 _ = (*regexp.Regexp)(nil)
29 _ = (*strings.Reader)(nil)
30 _ = net.IPv4len
31 _ = time.Duration(0)
32 _ = (*url.URL)(nil)
33 _ = (*mail.Address)(nil)
34 _ = anypb.Any{}
35 _ = sort.Sort
36 )
37
38
39
40
41 func (m *CommonExtensionConfig) Validate() error {
42 return m.validate(false)
43 }
44
45
46
47
48
49 func (m *CommonExtensionConfig) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *CommonExtensionConfig) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 oneofConfigTypePresent := false
61 switch v := m.ConfigType.(type) {
62 case *CommonExtensionConfig_AdminConfig:
63 if v == nil {
64 err := CommonExtensionConfigValidationError{
65 field: "ConfigType",
66 reason: "oneof value cannot be a typed-nil",
67 }
68 if !all {
69 return err
70 }
71 errors = append(errors, err)
72 }
73 oneofConfigTypePresent = true
74
75 if all {
76 switch v := interface{}(m.GetAdminConfig()).(type) {
77 case interface{ ValidateAll() error }:
78 if err := v.ValidateAll(); err != nil {
79 errors = append(errors, CommonExtensionConfigValidationError{
80 field: "AdminConfig",
81 reason: "embedded message failed validation",
82 cause: err,
83 })
84 }
85 case interface{ Validate() error }:
86 if err := v.Validate(); err != nil {
87 errors = append(errors, CommonExtensionConfigValidationError{
88 field: "AdminConfig",
89 reason: "embedded message failed validation",
90 cause: err,
91 })
92 }
93 }
94 } else if v, ok := interface{}(m.GetAdminConfig()).(interface{ Validate() error }); ok {
95 if err := v.Validate(); err != nil {
96 return CommonExtensionConfigValidationError{
97 field: "AdminConfig",
98 reason: "embedded message failed validation",
99 cause: err,
100 }
101 }
102 }
103
104 case *CommonExtensionConfig_StaticConfig:
105 if v == nil {
106 err := CommonExtensionConfigValidationError{
107 field: "ConfigType",
108 reason: "oneof value cannot be a typed-nil",
109 }
110 if !all {
111 return err
112 }
113 errors = append(errors, err)
114 }
115 oneofConfigTypePresent = true
116
117 if all {
118 switch v := interface{}(m.GetStaticConfig()).(type) {
119 case interface{ ValidateAll() error }:
120 if err := v.ValidateAll(); err != nil {
121 errors = append(errors, CommonExtensionConfigValidationError{
122 field: "StaticConfig",
123 reason: "embedded message failed validation",
124 cause: err,
125 })
126 }
127 case interface{ Validate() error }:
128 if err := v.Validate(); err != nil {
129 errors = append(errors, CommonExtensionConfigValidationError{
130 field: "StaticConfig",
131 reason: "embedded message failed validation",
132 cause: err,
133 })
134 }
135 }
136 } else if v, ok := interface{}(m.GetStaticConfig()).(interface{ Validate() error }); ok {
137 if err := v.Validate(); err != nil {
138 return CommonExtensionConfigValidationError{
139 field: "StaticConfig",
140 reason: "embedded message failed validation",
141 cause: err,
142 }
143 }
144 }
145
146 default:
147 _ = v
148 }
149 if !oneofConfigTypePresent {
150 err := CommonExtensionConfigValidationError{
151 field: "ConfigType",
152 reason: "value is required",
153 }
154 if !all {
155 return err
156 }
157 errors = append(errors, err)
158 }
159
160 if len(errors) > 0 {
161 return CommonExtensionConfigMultiError(errors)
162 }
163
164 return nil
165 }
166
167
168
169
170 type CommonExtensionConfigMultiError []error
171
172
173 func (m CommonExtensionConfigMultiError) Error() string {
174 var msgs []string
175 for _, err := range m {
176 msgs = append(msgs, err.Error())
177 }
178 return strings.Join(msgs, "; ")
179 }
180
181
182 func (m CommonExtensionConfigMultiError) AllErrors() []error { return m }
183
184
185
186 type CommonExtensionConfigValidationError struct {
187 field string
188 reason string
189 cause error
190 key bool
191 }
192
193
194 func (e CommonExtensionConfigValidationError) Field() string { return e.field }
195
196
197 func (e CommonExtensionConfigValidationError) Reason() string { return e.reason }
198
199
200 func (e CommonExtensionConfigValidationError) Cause() error { return e.cause }
201
202
203 func (e CommonExtensionConfigValidationError) Key() bool { return e.key }
204
205
206 func (e CommonExtensionConfigValidationError) ErrorName() string {
207 return "CommonExtensionConfigValidationError"
208 }
209
210
211 func (e CommonExtensionConfigValidationError) Error() string {
212 cause := ""
213 if e.cause != nil {
214 cause = fmt.Sprintf(" | caused by: %v", e.cause)
215 }
216
217 key := ""
218 if e.key {
219 key = "key for "
220 }
221
222 return fmt.Sprintf(
223 "invalid %sCommonExtensionConfig.%s: %s%s",
224 key,
225 e.field,
226 e.reason,
227 cause)
228 }
229
230 var _ error = CommonExtensionConfigValidationError{}
231
232 var _ interface {
233 Field() string
234 Reason() string
235 Key() bool
236 Cause() error
237 ErrorName() string
238 } = CommonExtensionConfigValidationError{}
239
240
241
242
243 func (m *AdminConfig) Validate() error {
244 return m.validate(false)
245 }
246
247
248
249
250
251 func (m *AdminConfig) ValidateAll() error {
252 return m.validate(true)
253 }
254
255 func (m *AdminConfig) validate(all bool) error {
256 if m == nil {
257 return nil
258 }
259
260 var errors []error
261
262 if len(m.GetConfigId()) < 1 {
263 err := AdminConfigValidationError{
264 field: "ConfigId",
265 reason: "value length must be at least 1 bytes",
266 }
267 if !all {
268 return err
269 }
270 errors = append(errors, err)
271 }
272
273 if len(errors) > 0 {
274 return AdminConfigMultiError(errors)
275 }
276
277 return nil
278 }
279
280
281
282 type AdminConfigMultiError []error
283
284
285 func (m AdminConfigMultiError) Error() string {
286 var msgs []string
287 for _, err := range m {
288 msgs = append(msgs, err.Error())
289 }
290 return strings.Join(msgs, "; ")
291 }
292
293
294 func (m AdminConfigMultiError) AllErrors() []error { return m }
295
296
297
298 type AdminConfigValidationError struct {
299 field string
300 reason string
301 cause error
302 key bool
303 }
304
305
306 func (e AdminConfigValidationError) Field() string { return e.field }
307
308
309 func (e AdminConfigValidationError) Reason() string { return e.reason }
310
311
312 func (e AdminConfigValidationError) Cause() error { return e.cause }
313
314
315 func (e AdminConfigValidationError) Key() bool { return e.key }
316
317
318 func (e AdminConfigValidationError) ErrorName() string { return "AdminConfigValidationError" }
319
320
321 func (e AdminConfigValidationError) Error() string {
322 cause := ""
323 if e.cause != nil {
324 cause = fmt.Sprintf(" | caused by: %v", e.cause)
325 }
326
327 key := ""
328 if e.key {
329 key = "key for "
330 }
331
332 return fmt.Sprintf(
333 "invalid %sAdminConfig.%s: %s%s",
334 key,
335 e.field,
336 e.reason,
337 cause)
338 }
339
340 var _ error = AdminConfigValidationError{}
341
342 var _ interface {
343 Field() string
344 Reason() string
345 Key() bool
346 Cause() error
347 ErrorName() string
348 } = AdminConfigValidationError{}
349
View as plain text