github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/trace/v3/lightstep.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/config/trace/v3/lightstep.proto 3 4 package envoy_config_trace_v3 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 LightstepConfig with the rules defined 37 // in the proto definition for this message. If any rules are violated, an 38 // error is returned. 39 func (m *LightstepConfig) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if utf8.RuneCountInString(m.GetCollectorCluster()) < 1 { 45 return LightstepConfigValidationError{ 46 field: "CollectorCluster", 47 reason: "value length must be at least 1 runes", 48 } 49 } 50 51 // no validation rules for AccessTokenFile 52 53 if v, ok := interface{}(m.GetAccessToken()).(interface{ Validate() error }); ok { 54 if err := v.Validate(); err != nil { 55 return LightstepConfigValidationError{ 56 field: "AccessToken", 57 reason: "embedded message failed validation", 58 cause: err, 59 } 60 } 61 } 62 63 for idx, item := range m.GetPropagationModes() { 64 _, _ = idx, item 65 66 if _, ok := LightstepConfig_PropagationMode_name[int32(item)]; !ok { 67 return LightstepConfigValidationError{ 68 field: fmt.Sprintf("PropagationModes[%v]", idx), 69 reason: "value must be one of the defined enum values", 70 } 71 } 72 73 } 74 75 return nil 76 } 77 78 // LightstepConfigValidationError is the validation error returned by 79 // LightstepConfig.Validate if the designated constraints aren't met. 80 type LightstepConfigValidationError struct { 81 field string 82 reason string 83 cause error 84 key bool 85 } 86 87 // Field function returns field value. 88 func (e LightstepConfigValidationError) Field() string { return e.field } 89 90 // Reason function returns reason value. 91 func (e LightstepConfigValidationError) Reason() string { return e.reason } 92 93 // Cause function returns cause value. 94 func (e LightstepConfigValidationError) Cause() error { return e.cause } 95 96 // Key function returns key value. 97 func (e LightstepConfigValidationError) Key() bool { return e.key } 98 99 // ErrorName returns error name. 100 func (e LightstepConfigValidationError) ErrorName() string { return "LightstepConfigValidationError" } 101 102 // Error satisfies the builtin error interface 103 func (e LightstepConfigValidationError) 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 %sLightstepConfig.%s: %s%s", 116 key, 117 e.field, 118 e.reason, 119 cause) 120 } 121 122 var _ error = LightstepConfigValidationError{} 123 124 var _ interface { 125 Field() string 126 Reason() string 127 Key() bool 128 Cause() error 129 ErrorName() string 130 } = LightstepConfigValidationError{}