Debian Codegraph @

envoy/extensions/transport_sockets/proxy_protocol/v3/upstream_proxy_protocol.pb.validate.go

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