gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/api/v2/cluster/outlier_detection.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/api/v2/cluster/outlier_detection.proto
     3  
     4  package envoy_api_v2_cluster
     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  	return nil
   268  }
   269  
   270  // OutlierDetectionValidationError is the validation error returned by
   271  // OutlierDetection.Validate if the designated constraints aren't met.
   272  type OutlierDetectionValidationError struct {
   273  	field  string
   274  	reason string
   275  	cause  error
   276  	key    bool
   277  }
   278  
   279  // Field function returns field value.
   280  func (e OutlierDetectionValidationError) Field() string { return e.field }
   281  
   282  // Reason function returns reason value.
   283  func (e OutlierDetectionValidationError) Reason() string { return e.reason }
   284  
   285  // Cause function returns cause value.
   286  func (e OutlierDetectionValidationError) Cause() error { return e.cause }
   287  
   288  // Key function returns key value.
   289  func (e OutlierDetectionValidationError) Key() bool { return e.key }
   290  
   291  // ErrorName returns error name.
   292  func (e OutlierDetectionValidationError) ErrorName() string { return "OutlierDetectionValidationError" }
   293  
   294  // Error satisfies the builtin error interface
   295  func (e OutlierDetectionValidationError) Error() string {
   296  	cause := ""
   297  	if e.cause != nil {
   298  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   299  	}
   300  
   301  	key := ""
   302  	if e.key {
   303  		key = "key for "
   304  	}
   305  
   306  	return fmt.Sprintf(
   307  		"invalid %sOutlierDetection.%s: %s%s",
   308  		key,
   309  		e.field,
   310  		e.reason,
   311  		cause)
   312  }
   313  
   314  var _ error = OutlierDetectionValidationError{}
   315  
   316  var _ interface {
   317  	Field() string
   318  	Reason() string
   319  	Key() bool
   320  	Cause() error
   321  	ErrorName() string
   322  } = OutlierDetectionValidationError{}