Debian Codegraph @

envoy/config/trace/v2alpha/xray.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/trace/v2alpha/xray.proto
4
5 package v2alpha
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 XRayConfig with the rules defined in the
40 // proto definition for this message. If any rules are violated, the first
41 // error encountered is returned, or nil if there are no violations.
42 func (m *XRayConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on XRayConfig with the rules defined in
47 // the proto definition for this message. If any rules are violated, the
48 // result is a list of violation errors wrapped in XRayConfigMultiError, or
49 // nil if none found.
50 func (m *XRayConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *XRayConfig) 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.GetDaemonEndpoint()).(type) {
63 case interface{ ValidateAll() error }:
64 if err := v.ValidateAll(); err != nil {
65 errors = append(errors, XRayConfigValidationError{
66 field: "DaemonEndpoint",
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, XRayConfigValidationError{
74 field: "DaemonEndpoint",
75 reason: "embedded message failed validation",
76 cause: err,
77 })
78 }
79 }
80 } else if v, ok := interface{}(m.GetDaemonEndpoint()).(interface{ Validate() error }); ok {
81 if err := v.Validate(); err != nil {
82 return XRayConfigValidationError{
83 field: "DaemonEndpoint",
84 reason: "embedded message failed validation",
85 cause: err,
86 }
87 }
88 }
89
90 if utf8.RuneCountInString(m.GetSegmentName()) < 1 {
91 err := XRayConfigValidationError{
92 field: "SegmentName",
93 reason: "value length must be at least 1 runes",
94 }
95 if !all {
96 return err
97 }
98 errors = append(errors, err)
99 }
100
101 if all {
102 switch v := interface{}(m.GetSamplingRuleManifest()).(type) {
103 case interface{ ValidateAll() error }:
104 if err := v.ValidateAll(); err != nil {
105 errors = append(errors, XRayConfigValidationError{
106 field: "SamplingRuleManifest",
107 reason: "embedded message failed validation",
108 cause: err,
109 })
110 }
111 case interface{ Validate() error }:
112 if err := v.Validate(); err != nil {
113 errors = append(errors, XRayConfigValidationError{
114 field: "SamplingRuleManifest",
115 reason: "embedded message failed validation",
116 cause: err,
117 })
118 }
119 }
120 } else if v, ok := interface{}(m.GetSamplingRuleManifest()).(interface{ Validate() error }); ok {
121 if err := v.Validate(); err != nil {
122 return XRayConfigValidationError{
123 field: "SamplingRuleManifest",
124 reason: "embedded message failed validation",
125 cause: err,
126 }
127 }
128 }
129
130 if len(errors) > 0 {
131 return XRayConfigMultiError(errors)
132 }
133
134 return nil
135 }
136
137 // XRayConfigMultiError is an error wrapping multiple validation errors
138 // returned by XRayConfig.ValidateAll() if the designated constraints aren't met.
139 type XRayConfigMultiError []error
140
141 // Error returns a concatenation of all the error messages it wraps.
142 func (m XRayConfigMultiError) Error() string {
143 var msgs []string
144 for _, err := range m {
145 msgs = append(msgs, err.Error())
146 }
147 return strings.Join(msgs, "; ")
148 }
149
150 // AllErrors returns a list of validation violation errors.
151 func (m XRayConfigMultiError) AllErrors() []error { return m }
152
153 // XRayConfigValidationError is the validation error returned by
154 // XRayConfig.Validate if the designated constraints aren't met.
155 type XRayConfigValidationError struct {
156 field string
157 reason string
158 cause error
159 key bool
160 }
161
162 // Field function returns field value.
163 func (e XRayConfigValidationError) Field() string { return e.field }
164
165 // Reason function returns reason value.
166 func (e XRayConfigValidationError) Reason() string { return e.reason }
167
168 // Cause function returns cause value.
169 func (e XRayConfigValidationError) Cause() error { return e.cause }
170
171 // Key function returns key value.
172 func (e XRayConfigValidationError) Key() bool { return e.key }
173
174 // ErrorName returns error name.
175 func (e XRayConfigValidationError) ErrorName() string { return "XRayConfigValidationError" }
176
177 // Error satisfies the builtin error interface
178 func (e XRayConfigValidationError) Error() string {
179 cause := ""
180 if e.cause != nil {
181 cause = fmt.Sprintf(" | caused by: %v", e.cause)
182 }
183
184 key := ""
185 if e.key {
186 key = "key for "
187 }
188
189 return fmt.Sprintf(
190 "invalid %sXRayConfig.%s: %s%s",
191 key,
192 e.field,
193 e.reason,
194 cause)
195 }
196
197 var _ error = XRayConfigValidationError{}
198
199 var _ interface {
200 Field() string
201 Reason() string
202 Key() bool
203 Cause() error
204 ErrorName() string
205 } = XRayConfigValidationError{}