github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/api/v2/auth/tls.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/api/v2/auth/tls.proto 3 4 package envoy_api_v2_auth 5 6 import ( 7 "bytes" 8 "errors" 9 "fmt" 10 "net" 11 "net/mail" 12 "net/url" 13 "regexp" 14 "strings" 15 "time" 16 "unicode/utf8" 17 18 "google.golang.org/protobuf/types/known/anypb" 19 ) 20 21 // ensure the imports are used 22 var ( 23 _ = bytes.MinRead 24 _ = errors.New("") 25 _ = fmt.Print 26 _ = utf8.UTFMax 27 _ = (*regexp.Regexp)(nil) 28 _ = (*strings.Reader)(nil) 29 _ = net.IPv4len 30 _ = time.Duration(0) 31 _ = (*url.URL)(nil) 32 _ = (*mail.Address)(nil) 33 _ = anypb.Any{} 34 ) 35 36 // Validate checks the field values on UpstreamTlsContext with the rules 37 // defined in the proto definition for this message. If any rules are 38 // violated, an error is returned. 39 func (m *UpstreamTlsContext) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if v, ok := interface{}(m.GetCommonTlsContext()).(interface{ Validate() error }); ok { 45 if err := v.Validate(); err != nil { 46 return UpstreamTlsContextValidationError{ 47 field: "CommonTlsContext", 48 reason: "embedded message failed validation", 49 cause: err, 50 } 51 } 52 } 53 54 if len(m.GetSni()) > 255 { 55 return UpstreamTlsContextValidationError{ 56 field: "Sni", 57 reason: "value length must be at most 255 bytes", 58 } 59 } 60 61 // no validation rules for AllowRenegotiation 62 63 if v, ok := interface{}(m.GetMaxSessionKeys()).(interface{ Validate() error }); ok { 64 if err := v.Validate(); err != nil { 65 return UpstreamTlsContextValidationError{ 66 field: "MaxSessionKeys", 67 reason: "embedded message failed validation", 68 cause: err, 69 } 70 } 71 } 72 73 return nil 74 } 75 76 // UpstreamTlsContextValidationError is the validation error returned by 77 // UpstreamTlsContext.Validate if the designated constraints aren't met. 78 type UpstreamTlsContextValidationError struct { 79 field string 80 reason string 81 cause error 82 key bool 83 } 84 85 // Field function returns field value. 86 func (e UpstreamTlsContextValidationError) Field() string { return e.field } 87 88 // Reason function returns reason value. 89 func (e UpstreamTlsContextValidationError) Reason() string { return e.reason } 90 91 // Cause function returns cause value. 92 func (e UpstreamTlsContextValidationError) Cause() error { return e.cause } 93 94 // Key function returns key value. 95 func (e UpstreamTlsContextValidationError) Key() bool { return e.key } 96 97 // ErrorName returns error name. 98 func (e UpstreamTlsContextValidationError) ErrorName() string { 99 return "UpstreamTlsContextValidationError" 100 } 101 102 // Error satisfies the builtin error interface 103 func (e UpstreamTlsContextValidationError) Error() string { 104 cause := "" 105 if e.cause != nil { 106 cause = fmt.Sprintf(" | caused by: %v", e.cause) 107 } 108 109 key := "" 110 if e.key { 111 key = "key for " 112 } 113 114 return fmt.Sprintf( 115 "invalid %sUpstreamTlsContext.%s: %s%s", 116 key, 117 e.field, 118 e.reason, 119 cause) 120 } 121 122 var _ error = UpstreamTlsContextValidationError{} 123 124 var _ interface { 125 Field() string 126 Reason() string 127 Key() bool 128 Cause() error 129 ErrorName() string 130 } = UpstreamTlsContextValidationError{} 131 132 // Validate checks the field values on DownstreamTlsContext with the rules 133 // defined in the proto definition for this message. If any rules are 134 // violated, an error is returned. 135 func (m *DownstreamTlsContext) Validate() error { 136 if m == nil { 137 return nil 138 } 139 140 if v, ok := interface{}(m.GetCommonTlsContext()).(interface{ Validate() error }); ok { 141 if err := v.Validate(); err != nil { 142 return DownstreamTlsContextValidationError{ 143 field: "CommonTlsContext", 144 reason: "embedded message failed validation", 145 cause: err, 146 } 147 } 148 } 149 150 if v, ok := interface{}(m.GetRequireClientCertificate()).(interface{ Validate() error }); ok { 151 if err := v.Validate(); err != nil { 152 return DownstreamTlsContextValidationError{ 153 field: "RequireClientCertificate", 154 reason: "embedded message failed validation", 155 cause: err, 156 } 157 } 158 } 159 160 if v, ok := interface{}(m.GetRequireSni()).(interface{ Validate() error }); ok { 161 if err := v.Validate(); err != nil { 162 return DownstreamTlsContextValidationError{ 163 field: "RequireSni", 164 reason: "embedded message failed validation", 165 cause: err, 166 } 167 } 168 } 169 170 if d := m.GetSessionTimeout(); d != nil { 171 dur, err := d.AsDuration(), d.CheckValid() 172 if err != nil { 173 return DownstreamTlsContextValidationError{ 174 field: "SessionTimeout", 175 reason: "value is not a valid duration", 176 cause: err, 177 } 178 } 179 180 lt := time.Duration(4294967296*time.Second + 0*time.Nanosecond) 181 gte := time.Duration(0*time.Second + 0*time.Nanosecond) 182 183 if dur < gte || dur >= lt { 184 return DownstreamTlsContextValidationError{ 185 field: "SessionTimeout", 186 reason: "value must be inside range [0s, 1193046h28m16s)", 187 } 188 } 189 190 } 191 192 switch m.SessionTicketKeysType.(type) { 193 194 case *DownstreamTlsContext_SessionTicketKeys: 195 196 if v, ok := interface{}(m.GetSessionTicketKeys()).(interface{ Validate() error }); ok { 197 if err := v.Validate(); err != nil { 198 return DownstreamTlsContextValidationError{ 199 field: "SessionTicketKeys", 200 reason: "embedded message failed validation", 201 cause: err, 202 } 203 } 204 } 205 206 case *DownstreamTlsContext_SessionTicketKeysSdsSecretConfig: 207 208 if v, ok := interface{}(m.GetSessionTicketKeysSdsSecretConfig()).(interface{ Validate() error }); ok { 209 if err := v.Validate(); err != nil { 210 return DownstreamTlsContextValidationError{ 211 field: "SessionTicketKeysSdsSecretConfig", 212 reason: "embedded message failed validation", 213 cause: err, 214 } 215 } 216 } 217 218 case *DownstreamTlsContext_DisableStatelessSessionResumption: 219 // no validation rules for DisableStatelessSessionResumption 220 221 } 222 223 return nil 224 } 225 226 // DownstreamTlsContextValidationError is the validation error returned by 227 // DownstreamTlsContext.Validate if the designated constraints aren't met. 228 type DownstreamTlsContextValidationError struct { 229 field string 230 reason string 231 cause error 232 key bool 233 } 234 235 // Field function returns field value. 236 func (e DownstreamTlsContextValidationError) Field() string { return e.field } 237 238 // Reason function returns reason value. 239 func (e DownstreamTlsContextValidationError) Reason() string { return e.reason } 240 241 // Cause function returns cause value. 242 func (e DownstreamTlsContextValidationError) Cause() error { return e.cause } 243 244 // Key function returns key value. 245 func (e DownstreamTlsContextValidationError) Key() bool { return e.key } 246 247 // ErrorName returns error name. 248 func (e DownstreamTlsContextValidationError) ErrorName() string { 249 return "DownstreamTlsContextValidationError" 250 } 251 252 // Error satisfies the builtin error interface 253 func (e DownstreamTlsContextValidationError) Error() string { 254 cause := "" 255 if e.cause != nil { 256 cause = fmt.Sprintf(" | caused by: %v", e.cause) 257 } 258 259 key := "" 260 if e.key { 261 key = "key for " 262 } 263 264 return fmt.Sprintf( 265 "invalid %sDownstreamTlsContext.%s: %s%s", 266 key, 267 e.field, 268 e.reason, 269 cause) 270 } 271 272 var _ error = DownstreamTlsContextValidationError{} 273 274 var _ interface { 275 Field() string 276 Reason() string 277 Key() bool 278 Cause() error 279 ErrorName() string 280 } = DownstreamTlsContextValidationError{} 281 282 // Validate checks the field values on CommonTlsContext with the rules defined 283 // in the proto definition for this message. If any rules are violated, an 284 // error is returned. 285 func (m *CommonTlsContext) Validate() error { 286 if m == nil { 287 return nil 288 } 289 290 if v, ok := interface{}(m.GetTlsParams()).(interface{ Validate() error }); ok { 291 if err := v.Validate(); err != nil { 292 return CommonTlsContextValidationError{ 293 field: "TlsParams", 294 reason: "embedded message failed validation", 295 cause: err, 296 } 297 } 298 } 299 300 for idx, item := range m.GetTlsCertificates() { 301 _, _ = idx, item 302 303 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 304 if err := v.Validate(); err != nil { 305 return CommonTlsContextValidationError{ 306 field: fmt.Sprintf("TlsCertificates[%v]", idx), 307 reason: "embedded message failed validation", 308 cause: err, 309 } 310 } 311 } 312 313 } 314 315 if len(m.GetTlsCertificateSdsSecretConfigs()) > 1 { 316 return CommonTlsContextValidationError{ 317 field: "TlsCertificateSdsSecretConfigs", 318 reason: "value must contain no more than 1 item(s)", 319 } 320 } 321 322 for idx, item := range m.GetTlsCertificateSdsSecretConfigs() { 323 _, _ = idx, item 324 325 if v, ok := interface{}(item).(interface{ Validate() error }); ok { 326 if err := v.Validate(); err != nil { 327 return CommonTlsContextValidationError{ 328 field: fmt.Sprintf("TlsCertificateSdsSecretConfigs[%v]", idx), 329 reason: "embedded message failed validation", 330 cause: err, 331 } 332 } 333 } 334 335 } 336 337 switch m.ValidationContextType.(type) { 338 339 case *CommonTlsContext_ValidationContext: 340 341 if v, ok := interface{}(m.GetValidationContext()).(interface{ Validate() error }); ok { 342 if err := v.Validate(); err != nil { 343 return CommonTlsContextValidationError{ 344 field: "ValidationContext", 345 reason: "embedded message failed validation", 346 cause: err, 347 } 348 } 349 } 350 351 case *CommonTlsContext_ValidationContextSdsSecretConfig: 352 353 if v, ok := interface{}(m.GetValidationContextSdsSecretConfig()).(interface{ Validate() error }); ok { 354 if err := v.Validate(); err != nil { 355 return CommonTlsContextValidationError{ 356 field: "ValidationContextSdsSecretConfig", 357 reason: "embedded message failed validation", 358 cause: err, 359 } 360 } 361 } 362 363 case *CommonTlsContext_CombinedValidationContext: 364 365 if v, ok := interface{}(m.GetCombinedValidationContext()).(interface{ Validate() error }); ok { 366 if err := v.Validate(); err != nil { 367 return CommonTlsContextValidationError{ 368 field: "CombinedValidationContext", 369 reason: "embedded message failed validation", 370 cause: err, 371 } 372 } 373 } 374 375 } 376 377 return nil 378 } 379 380 // CommonTlsContextValidationError is the validation error returned by 381 // CommonTlsContext.Validate if the designated constraints aren't met. 382 type CommonTlsContextValidationError struct { 383 field string 384 reason string 385 cause error 386 key bool 387 } 388 389 // Field function returns field value. 390 func (e CommonTlsContextValidationError) Field() string { return e.field } 391 392 // Reason function returns reason value. 393 func (e CommonTlsContextValidationError) Reason() string { return e.reason } 394 395 // Cause function returns cause value. 396 func (e CommonTlsContextValidationError) Cause() error { return e.cause } 397 398 // Key function returns key value. 399 func (e CommonTlsContextValidationError) Key() bool { return e.key } 400 401 // ErrorName returns error name. 402 func (e CommonTlsContextValidationError) ErrorName() string { return "CommonTlsContextValidationError" } 403 404 // Error satisfies the builtin error interface 405 func (e CommonTlsContextValidationError) Error() string { 406 cause := "" 407 if e.cause != nil { 408 cause = fmt.Sprintf(" | caused by: %v", e.cause) 409 } 410 411 key := "" 412 if e.key { 413 key = "key for " 414 } 415 416 return fmt.Sprintf( 417 "invalid %sCommonTlsContext.%s: %s%s", 418 key, 419 e.field, 420 e.reason, 421 cause) 422 } 423 424 var _ error = CommonTlsContextValidationError{} 425 426 var _ interface { 427 Field() string 428 Reason() string 429 Key() bool 430 Cause() error 431 ErrorName() string 432 } = CommonTlsContextValidationError{} 433 434 // Validate checks the field values on 435 // CommonTlsContext_CombinedCertificateValidationContext with the rules 436 // defined in the proto definition for this message. If any rules are 437 // violated, an error is returned. 438 func (m *CommonTlsContext_CombinedCertificateValidationContext) Validate() error { 439 if m == nil { 440 return nil 441 } 442 443 if m.GetDefaultValidationContext() == nil { 444 return CommonTlsContext_CombinedCertificateValidationContextValidationError{ 445 field: "DefaultValidationContext", 446 reason: "value is required", 447 } 448 } 449 450 if v, ok := interface{}(m.GetDefaultValidationContext()).(interface{ Validate() error }); ok { 451 if err := v.Validate(); err != nil { 452 return CommonTlsContext_CombinedCertificateValidationContextValidationError{ 453 field: "DefaultValidationContext", 454 reason: "embedded message failed validation", 455 cause: err, 456 } 457 } 458 } 459 460 if m.GetValidationContextSdsSecretConfig() == nil { 461 return CommonTlsContext_CombinedCertificateValidationContextValidationError{ 462 field: "ValidationContextSdsSecretConfig", 463 reason: "value is required", 464 } 465 } 466 467 if v, ok := interface{}(m.GetValidationContextSdsSecretConfig()).(interface{ Validate() error }); ok { 468 if err := v.Validate(); err != nil { 469 return CommonTlsContext_CombinedCertificateValidationContextValidationError{ 470 field: "ValidationContextSdsSecretConfig", 471 reason: "embedded message failed validation", 472 cause: err, 473 } 474 } 475 } 476 477 return nil 478 } 479 480 // CommonTlsContext_CombinedCertificateValidationContextValidationError is the 481 // validation error returned by 482 // CommonTlsContext_CombinedCertificateValidationContext.Validate if the 483 // designated constraints aren't met. 484 type CommonTlsContext_CombinedCertificateValidationContextValidationError struct { 485 field string 486 reason string 487 cause error 488 key bool 489 } 490 491 // Field function returns field value. 492 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Field() string { 493 return e.field 494 } 495 496 // Reason function returns reason value. 497 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Reason() string { 498 return e.reason 499 } 500 501 // Cause function returns cause value. 502 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Cause() error { 503 return e.cause 504 } 505 506 // Key function returns key value. 507 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Key() bool { 508 return e.key 509 } 510 511 // ErrorName returns error name. 512 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) ErrorName() string { 513 return "CommonTlsContext_CombinedCertificateValidationContextValidationError" 514 } 515 516 // Error satisfies the builtin error interface 517 func (e CommonTlsContext_CombinedCertificateValidationContextValidationError) Error() string { 518 cause := "" 519 if e.cause != nil { 520 cause = fmt.Sprintf(" | caused by: %v", e.cause) 521 } 522 523 key := "" 524 if e.key { 525 key = "key for " 526 } 527 528 return fmt.Sprintf( 529 "invalid %sCommonTlsContext_CombinedCertificateValidationContext.%s: %s%s", 530 key, 531 e.field, 532 e.reason, 533 cause) 534 } 535 536 var _ error = CommonTlsContext_CombinedCertificateValidationContextValidationError{} 537 538 var _ interface { 539 Field() string 540 Reason() string 541 Key() bool 542 Cause() error 543 ErrorName() string 544 } = CommonTlsContext_CombinedCertificateValidationContextValidationError{}