| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/extensions/stat_sinks/open_telemetry/v3/open_telemetry.proto |
| 4 |
|
| 5 |
package open_telemetryv3 |
| 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 SinkConfig 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 *SinkConfig) Validate() error { |
| 43 |
return m.validate(false) |
| 44 |
} |
| 45 |
|
| 46 |
// ValidateAll checks the field values on SinkConfig 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 SinkConfigMultiError, or |
| 49 |
// nil if none found. |
| 50 |
func (m *SinkConfig) ValidateAll() error { |
| 51 |
return m.validate(true) |
| 52 |
} |
| 53 |
|
| 54 |
func (m *SinkConfig) validate(all bool) error { |
| 55 |
if m == nil { |
| 56 |
return nil |
| 57 |
} |
| 58 |
|
| 59 |
var errors []error |
| 60 |
|
| 61 |
// no validation rules for ReportCountersAsDeltas |
| 62 |
|
| 63 |
// no validation rules for ReportHistogramsAsDeltas |
| 64 |
|
| 65 |
if all { |
| 66 |
switch v := interface{}(m.GetEmitTagsAsAttributes()).(type) { |
| 67 |
case interface{ ValidateAll() error }: |
| 68 |
if err := v.ValidateAll(); err != nil { |
| 69 |
errors = append(errors, SinkConfigValidationError{ |
| 70 |
field: "EmitTagsAsAttributes", |
| 71 |
reason: "embedded message failed validation", |
| 72 |
cause: err, |
| 73 |
}) |
| 74 |
} |
| 75 |
case interface{ Validate() error }: |
| 76 |
if err := v.Validate(); err != nil { |
| 77 |
errors = append(errors, SinkConfigValidationError{ |
| 78 |
field: "EmitTagsAsAttributes", |
| 79 |
reason: "embedded message failed validation", |
| 80 |
cause: err, |
| 81 |
}) |
| 82 |
} |
| 83 |
} |
| 84 |
} else if v, ok := interface{}(m.GetEmitTagsAsAttributes()).(interface{ Validate() error }); ok { |
| 85 |
if err := v.Validate(); err != nil { |
| 86 |
return SinkConfigValidationError{ |
| 87 |
field: "EmitTagsAsAttributes", |
| 88 |
reason: "embedded message failed validation", |
| 89 |
cause: err, |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
if all { |
| 95 |
switch v := interface{}(m.GetUseTagExtractedName()).(type) { |
| 96 |
case interface{ ValidateAll() error }: |
| 97 |
if err := v.ValidateAll(); err != nil { |
| 98 |
errors = append(errors, SinkConfigValidationError{ |
| 99 |
field: "UseTagExtractedName", |
| 100 |
reason: "embedded message failed validation", |
| 101 |
cause: err, |
| 102 |
}) |
| 103 |
} |
| 104 |
case interface{ Validate() error }: |
| 105 |
if err := v.Validate(); err != nil { |
| 106 |
errors = append(errors, SinkConfigValidationError{ |
| 107 |
field: "UseTagExtractedName", |
| 108 |
reason: "embedded message failed validation", |
| 109 |
cause: err, |
| 110 |
}) |
| 111 |
} |
| 112 |
} |
| 113 |
} else if v, ok := interface{}(m.GetUseTagExtractedName()).(interface{ Validate() error }); ok { |
| 114 |
if err := v.Validate(); err != nil { |
| 115 |
return SinkConfigValidationError{ |
| 116 |
field: "UseTagExtractedName", |
| 117 |
reason: "embedded message failed validation", |
| 118 |
cause: err, |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
// no validation rules for Prefix |
| 124 |
|
| 125 |
oneofProtocolSpecifierPresent := false |
| 126 |
switch v := m.ProtocolSpecifier.(type) { |
| 127 |
case *SinkConfig_GrpcService: |
| 128 |
if v == nil { |
| 129 |
err := SinkConfigValidationError{ |
| 130 |
field: "ProtocolSpecifier", |
| 131 |
reason: "oneof value cannot be a typed-nil", |
| 132 |
} |
| 133 |
if !all { |
| 134 |
return err |
| 135 |
} |
| 136 |
errors = append(errors, err) |
| 137 |
} |
| 138 |
oneofProtocolSpecifierPresent = true |
| 139 |
|
| 140 |
if m.GetGrpcService() == nil { |
| 141 |
err := SinkConfigValidationError{ |
| 142 |
field: "GrpcService", |
| 143 |
reason: "value is required", |
| 144 |
} |
| 145 |
if !all { |
| 146 |
return err |
| 147 |
} |
| 148 |
errors = append(errors, err) |
| 149 |
} |
| 150 |
|
| 151 |
if all { |
| 152 |
switch v := interface{}(m.GetGrpcService()).(type) { |
| 153 |
case interface{ ValidateAll() error }: |
| 154 |
if err := v.ValidateAll(); err != nil { |
| 155 |
errors = append(errors, SinkConfigValidationError{ |
| 156 |
field: "GrpcService", |
| 157 |
reason: "embedded message failed validation", |
| 158 |
cause: err, |
| 159 |
}) |
| 160 |
} |
| 161 |
case interface{ Validate() error }: |
| 162 |
if err := v.Validate(); err != nil { |
| 163 |
errors = append(errors, SinkConfigValidationError{ |
| 164 |
field: "GrpcService", |
| 165 |
reason: "embedded message failed validation", |
| 166 |
cause: err, |
| 167 |
}) |
| 168 |
} |
| 169 |
} |
| 170 |
} else if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok { |
| 171 |
if err := v.Validate(); err != nil { |
| 172 |
return SinkConfigValidationError{ |
| 173 |
field: "GrpcService", |
| 174 |
reason: "embedded message failed validation", |
| 175 |
cause: err, |
| 176 |
} |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
default: |
| 181 |
_ = v // ensures v is used |
| 182 |
} |
| 183 |
if !oneofProtocolSpecifierPresent { |
| 184 |
err := SinkConfigValidationError{ |
| 185 |
field: "ProtocolSpecifier", |
| 186 |
reason: "value is required", |
| 187 |
} |
| 188 |
if !all { |
| 189 |
return err |
| 190 |
} |
| 191 |
errors = append(errors, err) |
| 192 |
} |
| 193 |
|
| 194 |
if len(errors) > 0 { |
| 195 |
return SinkConfigMultiError(errors) |
| 196 |
} |
| 197 |
|
| 198 |
return nil |
| 199 |
} |
| 200 |
|
| 201 |
// SinkConfigMultiError is an error wrapping multiple validation errors |
| 202 |
// returned by SinkConfig.ValidateAll() if the designated constraints aren't met. |
| 203 |
type SinkConfigMultiError []error |
| 204 |
|
| 205 |
// Error returns a concatenation of all the error messages it wraps. |
| 206 |
func (m SinkConfigMultiError) Error() string { |
| 207 |
var msgs []string |
| 208 |
for _, err := range m { |
| 209 |
msgs = append(msgs, err.Error()) |
| 210 |
} |
| 211 |
return strings.Join(msgs, "; ") |
| 212 |
} |
| 213 |
|
| 214 |
// AllErrors returns a list of validation violation errors. |
| 215 |
func (m SinkConfigMultiError) AllErrors() []error { return m } |
| 216 |
|
| 217 |
// SinkConfigValidationError is the validation error returned by |
| 218 |
// SinkConfig.Validate if the designated constraints aren't met. |
| 219 |
type SinkConfigValidationError struct { |
| 220 |
field string |
| 221 |
reason string |
| 222 |
cause error |
| 223 |
key bool |
| 224 |
} |
| 225 |
|
| 226 |
// Field function returns field value. |
| 227 |
func (e SinkConfigValidationError) Field() string { return e.field } |
| 228 |
|
| 229 |
// Reason function returns reason value. |
| 230 |
func (e SinkConfigValidationError) Reason() string { return e.reason } |
| 231 |
|
| 232 |
// Cause function returns cause value. |
| 233 |
func (e SinkConfigValidationError) Cause() error { return e.cause } |
| 234 |
|
| 235 |
// Key function returns key value. |
| 236 |
func (e SinkConfigValidationError) Key() bool { return e.key } |
| 237 |
|
| 238 |
// ErrorName returns error name. |
| 239 |
func (e SinkConfigValidationError) ErrorName() string { return "SinkConfigValidationError" } |
| 240 |
|
| 241 |
// Error satisfies the builtin error interface |
| 242 |
func (e SinkConfigValidationError) Error() string { |
| 243 |
cause := "" |
| 244 |
if e.cause != nil { |
| 245 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 246 |
} |
| 247 |
|
| 248 |
key := "" |
| 249 |
if e.key { |
| 250 |
key = "key for " |
| 251 |
} |
| 252 |
|
| 253 |
return fmt.Sprintf( |
| 254 |
"invalid %sSinkConfig.%s: %s%s", |
| 255 |
key, |
| 256 |
e.field, |
| 257 |
e.reason, |
| 258 |
cause) |
| 259 |
} |
| 260 |
|
| 261 |
var _ error = SinkConfigValidationError{} |
| 262 |
|
| 263 |
var _ interface { |
| 264 |
Field() string |
| 265 |
Reason() string |
| 266 |
Key() bool |
| 267 |
Cause() error |
| 268 |
ErrorName() string |
| 269 |
} = SinkConfigValidationError{} |