Debian Codegraph @

envoy/config/metrics/v3/metrics_service.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/config/metrics/v3/metrics_service.proto
4
5 package metricsv3
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 v3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
23 )
24
25 // ensure the imports are used
26 var (
27 _ = bytes.MinRead
28 _ = errors.New("")
29 _ = fmt.Print
30 _ = utf8.UTFMax
31 _ = (*regexp.Regexp)(nil)
32 _ = (*strings.Reader)(nil)
33 _ = net.IPv4len
34 _ = time.Duration(0)
35 _ = (*url.URL)(nil)
36 _ = (*mail.Address)(nil)
37 _ = anypb.Any{}
38 _ = sort.Sort
39
40 _ = v3.ApiVersion(0)
41 )
42
43 // Validate checks the field values on MetricsServiceConfig with the rules
44 // defined in the proto definition for this message. If any rules are
45 // violated, the first error encountered is returned, or nil if there are no violations.
46 func (m *MetricsServiceConfig) Validate() error {
47 return m.validate(false)
48 }
49
50 // ValidateAll checks the field values on MetricsServiceConfig with the rules
51 // defined in the proto definition for this message. If any rules are
52 // violated, the result is a list of violation errors wrapped in
53 // MetricsServiceConfigMultiError, or nil if none found.
54 func (m *MetricsServiceConfig) ValidateAll() error {
55 return m.validate(true)
56 }
57
58 func (m *MetricsServiceConfig) validate(all bool) error {
59 if m == nil {
60 return nil
61 }
62
63 var errors []error
64
65 if m.GetGrpcService() == nil {
66 err := MetricsServiceConfigValidationError{
67 field: "GrpcService",
68 reason: "value is required",
69 }
70 if !all {
71 return err
72 }
73 errors = append(errors, err)
74 }
75
76 if all {
77 switch v := interface{}(m.GetGrpcService()).(type) {
78 case interface{ ValidateAll() error }:
79 if err := v.ValidateAll(); err != nil {
80 errors = append(errors, MetricsServiceConfigValidationError{
81 field: "GrpcService",
82 reason: "embedded message failed validation",
83 cause: err,
84 })
85 }
86 case interface{ Validate() error }:
87 if err := v.Validate(); err != nil {
88 errors = append(errors, MetricsServiceConfigValidationError{
89 field: "GrpcService",
90 reason: "embedded message failed validation",
91 cause: err,
92 })
93 }
94 }
95 } else if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
96 if err := v.Validate(); err != nil {
97 return MetricsServiceConfigValidationError{
98 field: "GrpcService",
99 reason: "embedded message failed validation",
100 cause: err,
101 }
102 }
103 }
104
105 if _, ok := v3.ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
106 err := MetricsServiceConfigValidationError{
107 field: "TransportApiVersion",
108 reason: "value must be one of the defined enum values",
109 }
110 if !all {
111 return err
112 }
113 errors = append(errors, err)
114 }
115
116 if all {
117 switch v := interface{}(m.GetReportCountersAsDeltas()).(type) {
118 case interface{ ValidateAll() error }:
119 if err := v.ValidateAll(); err != nil {
120 errors = append(errors, MetricsServiceConfigValidationError{
121 field: "ReportCountersAsDeltas",
122 reason: "embedded message failed validation",
123 cause: err,
124 })
125 }
126 case interface{ Validate() error }:
127 if err := v.Validate(); err != nil {
128 errors = append(errors, MetricsServiceConfigValidationError{
129 field: "ReportCountersAsDeltas",
130 reason: "embedded message failed validation",
131 cause: err,
132 })
133 }
134 }
135 } else if v, ok := interface{}(m.GetReportCountersAsDeltas()).(interface{ Validate() error }); ok {
136 if err := v.Validate(); err != nil {
137 return MetricsServiceConfigValidationError{
138 field: "ReportCountersAsDeltas",
139 reason: "embedded message failed validation",
140 cause: err,
141 }
142 }
143 }
144
145 // no validation rules for EmitTagsAsLabels
146
147 if _, ok := HistogramEmitMode_name[int32(m.GetHistogramEmitMode())]; !ok {
148 err := MetricsServiceConfigValidationError{
149 field: "HistogramEmitMode",
150 reason: "value must be one of the defined enum values",
151 }
152 if !all {
153 return err
154 }
155 errors = append(errors, err)
156 }
157
158 if len(errors) > 0 {
159 return MetricsServiceConfigMultiError(errors)
160 }
161
162 return nil
163 }
164
165 // MetricsServiceConfigMultiError is an error wrapping multiple validation
166 // errors returned by MetricsServiceConfig.ValidateAll() if the designated
167 // constraints aren't met.
168 type MetricsServiceConfigMultiError []error
169
170 // Error returns a concatenation of all the error messages it wraps.
171 func (m MetricsServiceConfigMultiError) Error() string {
172 var msgs []string
173 for _, err := range m {
174 msgs = append(msgs, err.Error())
175 }
176 return strings.Join(msgs, "; ")
177 }
178
179 // AllErrors returns a list of validation violation errors.
180 func (m MetricsServiceConfigMultiError) AllErrors() []error { return m }
181
182 // MetricsServiceConfigValidationError is the validation error returned by
183 // MetricsServiceConfig.Validate if the designated constraints aren't met.
184 type MetricsServiceConfigValidationError struct {
185 field string
186 reason string
187 cause error
188 key bool
189 }
190
191 // Field function returns field value.
192 func (e MetricsServiceConfigValidationError) Field() string { return e.field }
193
194 // Reason function returns reason value.
195 func (e MetricsServiceConfigValidationError) Reason() string { return e.reason }
196
197 // Cause function returns cause value.
198 func (e MetricsServiceConfigValidationError) Cause() error { return e.cause }
199
200 // Key function returns key value.
201 func (e MetricsServiceConfigValidationError) Key() bool { return e.key }
202
203 // ErrorName returns error name.
204 func (e MetricsServiceConfigValidationError) ErrorName() string {
205 return "MetricsServiceConfigValidationError"
206 }
207
208 // Error satisfies the builtin error interface
209 func (e MetricsServiceConfigValidationError) Error() string {
210 cause := ""
211 if e.cause != nil {
212 cause = fmt.Sprintf(" | caused by: %v", e.cause)
213 }
214
215 key := ""
216 if e.key {
217 key = "key for "
218 }
219
220 return fmt.Sprintf(
221 "invalid %sMetricsServiceConfig.%s: %s%s",
222 key,
223 e.field,
224 e.reason,
225 cause)
226 }
227
228 var _ error = MetricsServiceConfigValidationError{}
229
230 var _ interface {
231 Field() string
232 Reason() string
233 Key() bool
234 Cause() error
235 ErrorName() string
236 } = MetricsServiceConfigValidationError{}