gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/config/metrics/v3/metrics_service.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/config/metrics/v3/metrics_service.proto 3 4 package envoy_config_metrics_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 v3 "gitee.com/ks-custle/core-gm/go-control-plane/envoy/config/core/v3" 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 37 _ = v3.ApiVersion(0) 38 ) 39 40 // Validate checks the field values on MetricsServiceConfig with the rules 41 // defined in the proto definition for this message. If any rules are 42 // violated, an error is returned. 43 func (m *MetricsServiceConfig) Validate() error { 44 if m == nil { 45 return nil 46 } 47 48 if m.GetGrpcService() == nil { 49 return MetricsServiceConfigValidationError{ 50 field: "GrpcService", 51 reason: "value is required", 52 } 53 } 54 55 if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok { 56 if err := v.Validate(); err != nil { 57 return MetricsServiceConfigValidationError{ 58 field: "GrpcService", 59 reason: "embedded message failed validation", 60 cause: err, 61 } 62 } 63 } 64 65 if _, ok := v3.ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok { 66 return MetricsServiceConfigValidationError{ 67 field: "TransportApiVersion", 68 reason: "value must be one of the defined enum values", 69 } 70 } 71 72 if v, ok := interface{}(m.GetReportCountersAsDeltas()).(interface{ Validate() error }); ok { 73 if err := v.Validate(); err != nil { 74 return MetricsServiceConfigValidationError{ 75 field: "ReportCountersAsDeltas", 76 reason: "embedded message failed validation", 77 cause: err, 78 } 79 } 80 } 81 82 // no validation rules for EmitTagsAsLabels 83 84 return nil 85 } 86 87 // MetricsServiceConfigValidationError is the validation error returned by 88 // MetricsServiceConfig.Validate if the designated constraints aren't met. 89 type MetricsServiceConfigValidationError struct { 90 field string 91 reason string 92 cause error 93 key bool 94 } 95 96 // Field function returns field value. 97 func (e MetricsServiceConfigValidationError) Field() string { return e.field } 98 99 // Reason function returns reason value. 100 func (e MetricsServiceConfigValidationError) Reason() string { return e.reason } 101 102 // Cause function returns cause value. 103 func (e MetricsServiceConfigValidationError) Cause() error { return e.cause } 104 105 // Key function returns key value. 106 func (e MetricsServiceConfigValidationError) Key() bool { return e.key } 107 108 // ErrorName returns error name. 109 func (e MetricsServiceConfigValidationError) ErrorName() string { 110 return "MetricsServiceConfigValidationError" 111 } 112 113 // Error satisfies the builtin error interface 114 func (e MetricsServiceConfigValidationError) Error() string { 115 cause := "" 116 if e.cause != nil { 117 cause = fmt.Sprintf(" | caused by: %v", e.cause) 118 } 119 120 key := "" 121 if e.key { 122 key = "key for " 123 } 124 125 return fmt.Sprintf( 126 "invalid %sMetricsServiceConfig.%s: %s%s", 127 key, 128 e.field, 129 e.reason, 130 cause) 131 } 132 133 var _ error = MetricsServiceConfigValidationError{} 134 135 var _ interface { 136 Field() string 137 Reason() string 138 Key() bool 139 Cause() error 140 ErrorName() string 141 } = MetricsServiceConfigValidationError{}