Debian Codegraph @

envoy/config/trace/v2/zipkin.pb.validate.go

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