gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/config/cluster/v3/outlier_detection.pb.validate.go (about) 1 // Code generated by protoc-gen-validate. DO NOT EDIT. 2 // source: envoy/config/cluster/v3/outlier_detection.proto 3 4 package envoy_config_cluster_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 OutlierDetection 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 *OutlierDetection) Validate() error { 40 if m == nil { 41 return nil 42 } 43 44 if v, ok := interface{}(m.GetConsecutive_5Xx()).(interface{ Validate() error }); ok { 45 if err := v.Validate(); err != nil { 46 return OutlierDetectionValidationError{ 47 field: "Consecutive_5Xx", 48 reason: "embedded message failed validation", 49 cause: err, 50 } 51 } 52 } 53 54 if d := m.GetInterval(); d != nil { 55 dur, err := d.AsDuration(), d.CheckValid() 56 if err != nil { 57 return OutlierDetectionValidationError{ 58 field: "Interval", 59 reason: "value is not a valid duration", 60 cause: err, 61 } 62 } 63 64 gt := time.Duration(0*time.Second + 0*time.Nanosecond) 65 66 if dur <= gt { 67 return OutlierDetectionValidationError{ 68 field: "Interval", 69 reason: "value must be greater than 0s", 70 } 71 } 72 73 } 74 75 if d := m.GetBaseEjectionTime(); d != nil { 76 dur, err := d.AsDuration(), d.CheckValid() 77 if err != nil { 78 return OutlierDetectionValidationError{ 79 field: "BaseEjectionTime", 80 reason: "value is not a valid duration", 81 cause: err, 82 } 83 } 84 85 gt := time.Duration(0*time.Second + 0*time.Nanosecond) 86 87 if dur <= gt { 88 return OutlierDetectionValidationError{ 89 field: "BaseEjectionTime", 90 reason: "value must be greater than 0s", 91 } 92 } 93 94 } 95 96 if wrapper := m.GetMaxEjectionPercent(); wrapper != nil { 97 98 if wrapper.GetValue() > 100 { 99 return OutlierDetectionValidationError{ 100 field: "MaxEjectionPercent", 101 reason: "value must be less than or equal to 100", 102 } 103 } 104 105 } 106 107 if wrapper := m.GetEnforcingConsecutive_5Xx(); wrapper != nil { 108 109 if wrapper.GetValue() > 100 { 110 return OutlierDetectionValidationError{ 111 field: "EnforcingConsecutive_5Xx", 112 reason: "value must be less than or equal to 100", 113 } 114 } 115 116 } 117 118 if wrapper := m.GetEnforcingSuccessRate(); wrapper != nil { 119 120 if wrapper.GetValue() > 100 { 121 return OutlierDetectionValidationError{ 122 field: "EnforcingSuccessRate", 123 reason: "value must be less than or equal to 100", 124 } 125 } 126 127 } 128 129 if v, ok := interface{}(m.GetSuccessRateMinimumHosts()).(interface{ Validate() error }); ok { 130 if err := v.Validate(); err != nil { 131 return OutlierDetectionValidationError{ 132 field: "SuccessRateMinimumHosts", 133 reason: "embedded message failed validation", 134 cause: err, 135 } 136 } 137 } 138 139 if v, ok := interface{}(m.GetSuccessRateRequestVolume()).(interface{ Validate() error }); ok { 140 if err := v.Validate(); err != nil { 141 return OutlierDetectionValidationError{ 142 field: "SuccessRateRequestVolume", 143 reason: "embedded message failed validation", 144 cause: err, 145 } 146 } 147 } 148 149 if v, ok := interface{}(m.GetSuccessRateStdevFactor()).(interface{ Validate() error }); ok { 150 if err := v.Validate(); err != nil { 151 return OutlierDetectionValidationError{ 152 field: "SuccessRateStdevFactor", 153 reason: "embedded message failed validation", 154 cause: err, 155 } 156 } 157 } 158 159 if v, ok := interface{}(m.GetConsecutiveGatewayFailure()).(interface{ Validate() error }); ok { 160 if err := v.Validate(); err != nil { 161 return OutlierDetectionValidationError{ 162 field: "ConsecutiveGatewayFailure", 163 reason: "embedded message failed validation", 164 cause: err, 165 } 166 } 167 } 168 169 if wrapper := m.GetEnforcingConsecutiveGatewayFailure(); wrapper != nil { 170 171 if wrapper.GetValue() > 100 { 172 return OutlierDetectionValidationError{ 173 field: "EnforcingConsecutiveGatewayFailure", 174 reason: "value must be less than or equal to 100", 175 } 176 } 177 178 } 179 180 // no validation rules for SplitExternalLocalOriginErrors 181 182 if v, ok := interface{}(m.GetConsecutiveLocalOriginFailure()).(interface{ Validate() error }); ok { 183 if err := v.Validate(); err != nil { 184 return OutlierDetectionValidationError{ 185 field: "ConsecutiveLocalOriginFailure", 186 reason: "embedded message failed validation", 187 cause: err, 188 } 189 } 190 } 191 192 if wrapper := m.GetEnforcingConsecutiveLocalOriginFailure(); wrapper != nil { 193 194 if wrapper.GetValue() > 100 { 195 return OutlierDetectionValidationError{ 196 field: "EnforcingConsecutiveLocalOriginFailure", 197 reason: "value must be less than or equal to 100", 198 } 199 } 200 201 } 202 203 if wrapper := m.GetEnforcingLocalOriginSuccessRate(); wrapper != nil { 204 205 if wrapper.GetValue() > 100 { 206 return OutlierDetectionValidationError{ 207 field: "EnforcingLocalOriginSuccessRate", 208 reason: "value must be less than or equal to 100", 209 } 210 } 211 212 } 213 214 if wrapper := m.GetFailurePercentageThreshold(); wrapper != nil { 215 216 if wrapper.GetValue() > 100 { 217 return OutlierDetectionValidationError{ 218 field: "FailurePercentageThreshold", 219 reason: "value must be less than or equal to 100", 220 } 221 } 222 223 } 224 225 if wrapper := m.GetEnforcingFailurePercentage(); wrapper != nil { 226 227 if wrapper.GetValue() > 100 { 228 return OutlierDetectionValidationError{ 229 field: "EnforcingFailurePercentage", 230 reason: "value must be less than or equal to 100", 231 } 232 } 233 234 } 235 236 if wrapper := m.GetEnforcingFailurePercentageLocalOrigin(); wrapper != nil { 237 238 if wrapper.GetValue() > 100 { 239 return OutlierDetectionValidationError{ 240 field: "EnforcingFailurePercentageLocalOrigin", 241 reason: "value must be less than or equal to 100", 242 } 243 } 244 245 } 246 247 if v, ok := interface{}(m.GetFailurePercentageMinimumHosts()).(interface{ Validate() error }); ok { 248 if err := v.Validate(); err != nil { 249 return OutlierDetectionValidationError{ 250 field: "FailurePercentageMinimumHosts", 251 reason: "embedded message failed validation", 252 cause: err, 253 } 254 } 255 } 256 257 if v, ok := interface{}(m.GetFailurePercentageRequestVolume()).(interface{ Validate() error }); ok { 258 if err := v.Validate(); err != nil { 259 return OutlierDetectionValidationError{ 260 field: "FailurePercentageRequestVolume", 261 reason: "embedded message failed validation", 262 cause: err, 263 } 264 } 265 } 266 267 if d := m.GetMaxEjectionTime(); d != nil { 268 dur, err := d.AsDuration(), d.CheckValid() 269 if err != nil { 270 return OutlierDetectionValidationError{ 271 field: "MaxEjectionTime", 272 reason: "value is not a valid duration", 273 cause: err, 274 } 275 } 276 277 gt := time.Duration(0*time.Second + 0*time.Nanosecond) 278 279 if dur <= gt { 280 return OutlierDetectionValidationError{ 281 field: "MaxEjectionTime", 282 reason: "value must be greater than 0s", 283 } 284 } 285 286 } 287 288 return nil 289 } 290 291 // OutlierDetectionValidationError is the validation error returned by 292 // OutlierDetection.Validate if the designated constraints aren't met. 293 type OutlierDetectionValidationError struct { 294 field string 295 reason string 296 cause error 297 key bool 298 } 299 300 // Field function returns field value. 301 func (e OutlierDetectionValidationError) Field() string { return e.field } 302 303 // Reason function returns reason value. 304 func (e OutlierDetectionValidationError) Reason() string { return e.reason } 305 306 // Cause function returns cause value. 307 func (e OutlierDetectionValidationError) Cause() error { return e.cause } 308 309 // Key function returns key value. 310 func (e OutlierDetectionValidationError) Key() bool { return e.key } 311 312 // ErrorName returns error name. 313 func (e OutlierDetectionValidationError) ErrorName() string { return "OutlierDetectionValidationError" } 314 315 // Error satisfies the builtin error interface 316 func (e OutlierDetectionValidationError) Error() string { 317 cause := "" 318 if e.cause != nil { 319 cause = fmt.Sprintf(" | caused by: %v", e.cause) 320 } 321 322 key := "" 323 if e.key { 324 key = "key for " 325 } 326 327 return fmt.Sprintf( 328 "invalid %sOutlierDetection.%s: %s%s", 329 key, 330 e.field, 331 e.reason, 332 cause) 333 } 334 335 var _ error = OutlierDetectionValidationError{} 336 337 var _ interface { 338 Field() string 339 Reason() string 340 Key() bool 341 Cause() error 342 ErrorName() string 343 } = OutlierDetectionValidationError{}