Debian Codegraph @

envoy/config/trace/v3/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/v3/zipkin.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 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 utf8.RuneCountInString(m.GetCollectorCluster()) < 1 {
62 err := ZipkinConfigValidationError{
63 field: "CollectorCluster",
64 reason: "value length must be at least 1 runes",
65 }
66 if !all {
67 return err
68 }
69 errors = append(errors, err)
70 }
71
72 if utf8.RuneCountInString(m.GetCollectorEndpoint()) < 1 {
73 err := ZipkinConfigValidationError{
74 field: "CollectorEndpoint",
75 reason: "value length must be at least 1 runes",
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 // no validation rules for CollectorHostname
117
118 // no validation rules for SplitSpansForRequest
119
120 if len(errors) > 0 {
121 return ZipkinConfigMultiError(errors)
122 }
123
124 return nil
125 }
126
127 // ZipkinConfigMultiError is an error wrapping multiple validation errors
128 // returned by ZipkinConfig.ValidateAll() if the designated constraints aren't met.
129 type ZipkinConfigMultiError []error
130
131 // Error returns a concatenation of all the error messages it wraps.
132 func (m ZipkinConfigMultiError) Error() string {
133 var msgs []string
134 for _, err := range m {
135 msgs = append(msgs, err.Error())
136 }
137 return strings.Join(msgs, "; ")
138 }
139
140 // AllErrors returns a list of validation violation errors.
141 func (m ZipkinConfigMultiError) AllErrors() []error { return m }
142
143 // ZipkinConfigValidationError is the validation error returned by
144 // ZipkinConfig.Validate if the designated constraints aren't met.
145 type ZipkinConfigValidationError struct {
146 field string
147 reason string
148 cause error
149 key bool
150 }
151
152 // Field function returns field value.
153 func (e ZipkinConfigValidationError) Field() string { return e.field }
154
155 // Reason function returns reason value.
156 func (e ZipkinConfigValidationError) Reason() string { return e.reason }
157
158 // Cause function returns cause value.
159 func (e ZipkinConfigValidationError) Cause() error { return e.cause }
160
161 // Key function returns key value.
162 func (e ZipkinConfigValidationError) Key() bool { return e.key }
163
164 // ErrorName returns error name.
165 func (e ZipkinConfigValidationError) ErrorName() string { return "ZipkinConfigValidationError" }
166
167 // Error satisfies the builtin error interface
168 func (e ZipkinConfigValidationError) Error() string {
169 cause := ""
170 if e.cause != nil {
171 cause = fmt.Sprintf(" | caused by: %v", e.cause)
172 }
173
174 key := ""
175 if e.key {
176 key = "key for "
177 }
178
179 return fmt.Sprintf(
180 "invalid %sZipkinConfig.%s: %s%s",
181 key,
182 e.field,
183 e.reason,
184 cause)
185 }
186
187 var _ error = ZipkinConfigValidationError{}
188
189 var _ interface {
190 Field() string
191 Reason() string
192 Key() bool
193 Cause() error
194 ErrorName() string
195 } = ZipkinConfigValidationError{}