Debian Codegraph @

envoy/config/trace/v3/datadog.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/trace/v3/datadog.proto
4
5 package tracev3
6
7 import (
8 "bytes"
9 "errors"
10 "fmt"
11 "net"
12 "net/mail"
13 "net/url"
14 "regexp"
15 "sort"
16 "strings"
17 "time"
18 "unicode/utf8"
19
20 "google.golang.org/protobuf/types/known/anypb"
21 )
22
23 // ensure the imports are used
24 var (
25 _ = bytes.MinRead
26 _ = errors.New("")
27 _ = fmt.Print
28 _ = utf8.UTFMax
29 _ = (*regexp.Regexp)(nil)
30 _ = (*strings.Reader)(nil)
31 _ = net.IPv4len
32 _ = time.Duration(0)
33 _ = (*url.URL)(nil)
34 _ = (*mail.Address)(nil)
35 _ = anypb.Any{}
36 _ = sort.Sort
37 )
38
39 // Validate checks the field values on DatadogRemoteConfig with the rules
40 // defined in the proto definition for this message. If any rules are
41 // violated, the first error encountered is returned, or nil if there are no violations.
42 func (m *DatadogRemoteConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on DatadogRemoteConfig with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // DatadogRemoteConfigMultiError, or nil if none found.
50 func (m *DatadogRemoteConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *DatadogRemoteConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 if all {
62 switch v := interface{}(m.GetPollingInterval()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, DatadogRemoteConfigValidationError{
66 field: "PollingInterval",
67 reason: "embedded message failed validation",
68 cause: err,
69 })
70 }
71 case interface{ Validate() error }:
72 if err := v.Validate(); err != nil {
73 errors = append(errors, DatadogRemoteConfigValidationError{
74 field: "PollingInterval",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetPollingInterval()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return DatadogRemoteConfigValidationError{
83 field: "PollingInterval",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if len(errors) > 0 {
91 return DatadogRemoteConfigMultiError(errors)
92 }
93
94 return nil
95 }
96
97 // DatadogRemoteConfigMultiError is an error wrapping multiple validation
98 // errors returned by DatadogRemoteConfig.ValidateAll() if the designated
99 // constraints aren't met.
100 type DatadogRemoteConfigMultiError []error
101
102 // Error returns a concatenation of all the error messages it wraps.
103 func (m DatadogRemoteConfigMultiError) Error() string {
104 var msgs []string
105 for _, err := range m {
106 msgs = append(msgs, err.Error())
107 }
108 return strings.Join(msgs, "; ")
109 }
110
111 // AllErrors returns a list of validation violation errors.
112 func (m DatadogRemoteConfigMultiError) AllErrors() []error { return m }
113
114 // DatadogRemoteConfigValidationError is the validation error returned by
115 // DatadogRemoteConfig.Validate if the designated constraints aren't met.
116 type DatadogRemoteConfigValidationError struct {
117 field string
118 reason string
119 cause error
120 key bool
121 }
122
123 // Field function returns field value.
124 func (e DatadogRemoteConfigValidationError) Field() string { return e.field }
125
126 // Reason function returns reason value.
127 func (e DatadogRemoteConfigValidationError) Reason() string { return e.reason }
128
129 // Cause function returns cause value.
130 func (e DatadogRemoteConfigValidationError) Cause() error { return e.cause }
131
132 // Key function returns key value.
133 func (e DatadogRemoteConfigValidationError) Key() bool { return e.key }
134
135 // ErrorName returns error name.
136 func (e DatadogRemoteConfigValidationError) ErrorName() string {
137 return "DatadogRemoteConfigValidationError"
138 }
139
140 // Error satisfies the builtin error interface
141 func (e DatadogRemoteConfigValidationError) Error() string {
142 cause := ""
143 if e.cause != nil {
144 cause = fmt.Sprintf(" | caused by: %v", e.cause)
145 }
146
147 key := ""
148 if e.key {
149 key = "key for "
150 }
151
152 return fmt.Sprintf(
153 "invalid %sDatadogRemoteConfig.%s: %s%s",
154 key,
155 e.field,
156 e.reason,
157 cause)
158 }
159
160 var _ error = DatadogRemoteConfigValidationError{}
161
162 var _ interface {
163 Field() string
164 Reason() string
165 Key() bool
166 Cause() error
167 ErrorName() string
168 } = DatadogRemoteConfigValidationError{}
169
170 // Validate checks the field values on DatadogConfig with the rules defined in
171 // the proto definition for this message. If any rules are violated, the first
172 // error encountered is returned, or nil if there are no violations.
173 func (m *DatadogConfig) Validate() error {
174 return m.validate(false)
175 }
176
177 // ValidateAll checks the field values on DatadogConfig with the rules defined
178 // in the proto definition for this message. If any rules are violated, the
179 // result is a list of violation errors wrapped in DatadogConfigMultiError, or
180 // nil if none found.
181 func (m *DatadogConfig) ValidateAll() error {
182 return m.validate(true)
183 }
184
185 func (m *DatadogConfig) validate(all bool) error {
186 if m == nil {
187 return nil
188 }
189
190 var errors []error
191
192 if utf8.RuneCountInString(m.GetCollectorCluster()) < 1 {
193 err := DatadogConfigValidationError{
194 field: "CollectorCluster",
195 reason: "value length must be at least 1 runes",
196 }
197 if !all {
198 return err
199 }
200 errors = append(errors, err)
201 }
202
203 if utf8.RuneCountInString(m.GetServiceName()) < 1 {
204 err := DatadogConfigValidationError{
205 field: "ServiceName",
206 reason: "value length must be at least 1 runes",
207 }
208 if !all {
209 return err
210 }
211 errors = append(errors, err)
212 }
213
214 // no validation rules for CollectorHostname
215
216 if all {
217 switch v := interface{}(m.GetRemoteConfig()).(type) {
218 case interface{ ValidateAll() error }:
219 if err := v.ValidateAll(); err != nil {
220 errors = append(errors, DatadogConfigValidationError{
221 field: "RemoteConfig",
222 reason: "embedded message failed validation",
223 cause: err,
224 })
225 }
226 case interface{ Validate() error }:
227 if err := v.Validate(); err != nil {
228 errors = append(errors, DatadogConfigValidationError{
229 field: "RemoteConfig",
230 reason: "embedded message failed validation",
231 cause: err,
232 })
233 }
234 }
235 } else if v, ok := interface{}(m.GetRemoteConfig()).(interface{ Validate() error }); ok {
236 if err := v.Validate(); err != nil {
237 return DatadogConfigValidationError{
238 field: "RemoteConfig",
239 reason: "embedded message failed validation",
240 cause: err,
241 }
242 }
243 }
244
245 if len(errors) > 0 {
246 return DatadogConfigMultiError(errors)
247 }
248
249 return nil
250 }
251
252 // DatadogConfigMultiError is an error wrapping multiple validation errors
253 // returned by DatadogConfig.ValidateAll() if the designated constraints
254 // aren't met.
255 type DatadogConfigMultiError []error
256
257 // Error returns a concatenation of all the error messages it wraps.
258 func (m DatadogConfigMultiError) Error() string {
259 var msgs []string
260 for _, err := range m {
261 msgs = append(msgs, err.Error())
262 }
263 return strings.Join(msgs, "; ")
264 }
265
266 // AllErrors returns a list of validation violation errors.
267 func (m DatadogConfigMultiError) AllErrors() []error { return m }
268
269 // DatadogConfigValidationError is the validation error returned by
270 // DatadogConfig.Validate if the designated constraints aren't met.
271 type DatadogConfigValidationError struct {
272 field string
273 reason string
274 cause error
275 key bool
276 }
277
278 // Field function returns field value.
279 func (e DatadogConfigValidationError) Field() string { return e.field }
280
281 // Reason function returns reason value.
282 func (e DatadogConfigValidationError) Reason() string { return e.reason }
283
284 // Cause function returns cause value.
285 func (e DatadogConfigValidationError) Cause() error { return e.cause }
286
287 // Key function returns key value.
288 func (e DatadogConfigValidationError) Key() bool { return e.key }
289
290 // ErrorName returns error name.
291 func (e DatadogConfigValidationError) ErrorName() string { return "DatadogConfigValidationError" }
292
293 // Error satisfies the builtin error interface
294 func (e DatadogConfigValidationError) Error() string {
295 cause := ""
296 if e.cause != nil {
297 cause = fmt.Sprintf(" | caused by: %v", e.cause)
298 }
299
300 key := ""
301 if e.key {
302 key = "key for "
303 }
304
305 return fmt.Sprintf(
306 "invalid %sDatadogConfig.%s: %s%s",
307 key,
308 e.field,
309 e.reason,
310 cause)
311 }
312
313 var _ error = DatadogConfigValidationError{}
314
315 var _ interface {
316 Field() string
317 Reason() string
318 Key() bool
319 Cause() error
320 ErrorName() string
321 } = DatadogConfigValidationError{}