github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/data/cluster/v3/outlier_detection_event.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/data/cluster/v3/outlier_detection_event.proto
     3  
     4  package envoy_data_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 OutlierDetectionEvent 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 *OutlierDetectionEvent) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if _, ok := OutlierEjectionType_name[int32(m.GetType())]; !ok {
    45  		return OutlierDetectionEventValidationError{
    46  			field:  "Type",
    47  			reason: "value must be one of the defined enum values",
    48  		}
    49  	}
    50  
    51  	if v, ok := interface{}(m.GetTimestamp()).(interface{ Validate() error }); ok {
    52  		if err := v.Validate(); err != nil {
    53  			return OutlierDetectionEventValidationError{
    54  				field:  "Timestamp",
    55  				reason: "embedded message failed validation",
    56  				cause:  err,
    57  			}
    58  		}
    59  	}
    60  
    61  	if v, ok := interface{}(m.GetSecsSinceLastAction()).(interface{ Validate() error }); ok {
    62  		if err := v.Validate(); err != nil {
    63  			return OutlierDetectionEventValidationError{
    64  				field:  "SecsSinceLastAction",
    65  				reason: "embedded message failed validation",
    66  				cause:  err,
    67  			}
    68  		}
    69  	}
    70  
    71  	if utf8.RuneCountInString(m.GetClusterName()) < 1 {
    72  		return OutlierDetectionEventValidationError{
    73  			field:  "ClusterName",
    74  			reason: "value length must be at least 1 runes",
    75  		}
    76  	}
    77  
    78  	if utf8.RuneCountInString(m.GetUpstreamUrl()) < 1 {
    79  		return OutlierDetectionEventValidationError{
    80  			field:  "UpstreamUrl",
    81  			reason: "value length must be at least 1 runes",
    82  		}
    83  	}
    84  
    85  	if _, ok := Action_name[int32(m.GetAction())]; !ok {
    86  		return OutlierDetectionEventValidationError{
    87  			field:  "Action",
    88  			reason: "value must be one of the defined enum values",
    89  		}
    90  	}
    91  
    92  	// no validation rules for NumEjections
    93  
    94  	// no validation rules for Enforced
    95  
    96  	switch m.Event.(type) {
    97  
    98  	case *OutlierDetectionEvent_EjectSuccessRateEvent:
    99  
   100  		if v, ok := interface{}(m.GetEjectSuccessRateEvent()).(interface{ Validate() error }); ok {
   101  			if err := v.Validate(); err != nil {
   102  				return OutlierDetectionEventValidationError{
   103  					field:  "EjectSuccessRateEvent",
   104  					reason: "embedded message failed validation",
   105  					cause:  err,
   106  				}
   107  			}
   108  		}
   109  
   110  	case *OutlierDetectionEvent_EjectConsecutiveEvent:
   111  
   112  		if v, ok := interface{}(m.GetEjectConsecutiveEvent()).(interface{ Validate() error }); ok {
   113  			if err := v.Validate(); err != nil {
   114  				return OutlierDetectionEventValidationError{
   115  					field:  "EjectConsecutiveEvent",
   116  					reason: "embedded message failed validation",
   117  					cause:  err,
   118  				}
   119  			}
   120  		}
   121  
   122  	case *OutlierDetectionEvent_EjectFailurePercentageEvent:
   123  
   124  		if v, ok := interface{}(m.GetEjectFailurePercentageEvent()).(interface{ Validate() error }); ok {
   125  			if err := v.Validate(); err != nil {
   126  				return OutlierDetectionEventValidationError{
   127  					field:  "EjectFailurePercentageEvent",
   128  					reason: "embedded message failed validation",
   129  					cause:  err,
   130  				}
   131  			}
   132  		}
   133  
   134  	default:
   135  		return OutlierDetectionEventValidationError{
   136  			field:  "Event",
   137  			reason: "value is required",
   138  		}
   139  
   140  	}
   141  
   142  	return nil
   143  }
   144  
   145  // OutlierDetectionEventValidationError is the validation error returned by
   146  // OutlierDetectionEvent.Validate if the designated constraints aren't met.
   147  type OutlierDetectionEventValidationError struct {
   148  	field  string
   149  	reason string
   150  	cause  error
   151  	key    bool
   152  }
   153  
   154  // Field function returns field value.
   155  func (e OutlierDetectionEventValidationError) Field() string { return e.field }
   156  
   157  // Reason function returns reason value.
   158  func (e OutlierDetectionEventValidationError) Reason() string { return e.reason }
   159  
   160  // Cause function returns cause value.
   161  func (e OutlierDetectionEventValidationError) Cause() error { return e.cause }
   162  
   163  // Key function returns key value.
   164  func (e OutlierDetectionEventValidationError) Key() bool { return e.key }
   165  
   166  // ErrorName returns error name.
   167  func (e OutlierDetectionEventValidationError) ErrorName() string {
   168  	return "OutlierDetectionEventValidationError"
   169  }
   170  
   171  // Error satisfies the builtin error interface
   172  func (e OutlierDetectionEventValidationError) Error() string {
   173  	cause := ""
   174  	if e.cause != nil {
   175  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   176  	}
   177  
   178  	key := ""
   179  	if e.key {
   180  		key = "key for "
   181  	}
   182  
   183  	return fmt.Sprintf(
   184  		"invalid %sOutlierDetectionEvent.%s: %s%s",
   185  		key,
   186  		e.field,
   187  		e.reason,
   188  		cause)
   189  }
   190  
   191  var _ error = OutlierDetectionEventValidationError{}
   192  
   193  var _ interface {
   194  	Field() string
   195  	Reason() string
   196  	Key() bool
   197  	Cause() error
   198  	ErrorName() string
   199  } = OutlierDetectionEventValidationError{}
   200  
   201  // Validate checks the field values on OutlierEjectSuccessRate with the rules
   202  // defined in the proto definition for this message. If any rules are
   203  // violated, an error is returned.
   204  func (m *OutlierEjectSuccessRate) Validate() error {
   205  	if m == nil {
   206  		return nil
   207  	}
   208  
   209  	if m.GetHostSuccessRate() > 100 {
   210  		return OutlierEjectSuccessRateValidationError{
   211  			field:  "HostSuccessRate",
   212  			reason: "value must be less than or equal to 100",
   213  		}
   214  	}
   215  
   216  	if m.GetClusterAverageSuccessRate() > 100 {
   217  		return OutlierEjectSuccessRateValidationError{
   218  			field:  "ClusterAverageSuccessRate",
   219  			reason: "value must be less than or equal to 100",
   220  		}
   221  	}
   222  
   223  	if m.GetClusterSuccessRateEjectionThreshold() > 100 {
   224  		return OutlierEjectSuccessRateValidationError{
   225  			field:  "ClusterSuccessRateEjectionThreshold",
   226  			reason: "value must be less than or equal to 100",
   227  		}
   228  	}
   229  
   230  	return nil
   231  }
   232  
   233  // OutlierEjectSuccessRateValidationError is the validation error returned by
   234  // OutlierEjectSuccessRate.Validate if the designated constraints aren't met.
   235  type OutlierEjectSuccessRateValidationError struct {
   236  	field  string
   237  	reason string
   238  	cause  error
   239  	key    bool
   240  }
   241  
   242  // Field function returns field value.
   243  func (e OutlierEjectSuccessRateValidationError) Field() string { return e.field }
   244  
   245  // Reason function returns reason value.
   246  func (e OutlierEjectSuccessRateValidationError) Reason() string { return e.reason }
   247  
   248  // Cause function returns cause value.
   249  func (e OutlierEjectSuccessRateValidationError) Cause() error { return e.cause }
   250  
   251  // Key function returns key value.
   252  func (e OutlierEjectSuccessRateValidationError) Key() bool { return e.key }
   253  
   254  // ErrorName returns error name.
   255  func (e OutlierEjectSuccessRateValidationError) ErrorName() string {
   256  	return "OutlierEjectSuccessRateValidationError"
   257  }
   258  
   259  // Error satisfies the builtin error interface
   260  func (e OutlierEjectSuccessRateValidationError) Error() string {
   261  	cause := ""
   262  	if e.cause != nil {
   263  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   264  	}
   265  
   266  	key := ""
   267  	if e.key {
   268  		key = "key for "
   269  	}
   270  
   271  	return fmt.Sprintf(
   272  		"invalid %sOutlierEjectSuccessRate.%s: %s%s",
   273  		key,
   274  		e.field,
   275  		e.reason,
   276  		cause)
   277  }
   278  
   279  var _ error = OutlierEjectSuccessRateValidationError{}
   280  
   281  var _ interface {
   282  	Field() string
   283  	Reason() string
   284  	Key() bool
   285  	Cause() error
   286  	ErrorName() string
   287  } = OutlierEjectSuccessRateValidationError{}
   288  
   289  // Validate checks the field values on OutlierEjectConsecutive with the rules
   290  // defined in the proto definition for this message. If any rules are
   291  // violated, an error is returned.
   292  func (m *OutlierEjectConsecutive) Validate() error {
   293  	if m == nil {
   294  		return nil
   295  	}
   296  
   297  	return nil
   298  }
   299  
   300  // OutlierEjectConsecutiveValidationError is the validation error returned by
   301  // OutlierEjectConsecutive.Validate if the designated constraints aren't met.
   302  type OutlierEjectConsecutiveValidationError struct {
   303  	field  string
   304  	reason string
   305  	cause  error
   306  	key    bool
   307  }
   308  
   309  // Field function returns field value.
   310  func (e OutlierEjectConsecutiveValidationError) Field() string { return e.field }
   311  
   312  // Reason function returns reason value.
   313  func (e OutlierEjectConsecutiveValidationError) Reason() string { return e.reason }
   314  
   315  // Cause function returns cause value.
   316  func (e OutlierEjectConsecutiveValidationError) Cause() error { return e.cause }
   317  
   318  // Key function returns key value.
   319  func (e OutlierEjectConsecutiveValidationError) Key() bool { return e.key }
   320  
   321  // ErrorName returns error name.
   322  func (e OutlierEjectConsecutiveValidationError) ErrorName() string {
   323  	return "OutlierEjectConsecutiveValidationError"
   324  }
   325  
   326  // Error satisfies the builtin error interface
   327  func (e OutlierEjectConsecutiveValidationError) Error() string {
   328  	cause := ""
   329  	if e.cause != nil {
   330  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   331  	}
   332  
   333  	key := ""
   334  	if e.key {
   335  		key = "key for "
   336  	}
   337  
   338  	return fmt.Sprintf(
   339  		"invalid %sOutlierEjectConsecutive.%s: %s%s",
   340  		key,
   341  		e.field,
   342  		e.reason,
   343  		cause)
   344  }
   345  
   346  var _ error = OutlierEjectConsecutiveValidationError{}
   347  
   348  var _ interface {
   349  	Field() string
   350  	Reason() string
   351  	Key() bool
   352  	Cause() error
   353  	ErrorName() string
   354  } = OutlierEjectConsecutiveValidationError{}
   355  
   356  // Validate checks the field values on OutlierEjectFailurePercentage with the
   357  // rules defined in the proto definition for this message. If any rules are
   358  // violated, an error is returned.
   359  func (m *OutlierEjectFailurePercentage) Validate() error {
   360  	if m == nil {
   361  		return nil
   362  	}
   363  
   364  	if m.GetHostSuccessRate() > 100 {
   365  		return OutlierEjectFailurePercentageValidationError{
   366  			field:  "HostSuccessRate",
   367  			reason: "value must be less than or equal to 100",
   368  		}
   369  	}
   370  
   371  	return nil
   372  }
   373  
   374  // OutlierEjectFailurePercentageValidationError is the validation error
   375  // returned by OutlierEjectFailurePercentage.Validate if the designated
   376  // constraints aren't met.
   377  type OutlierEjectFailurePercentageValidationError struct {
   378  	field  string
   379  	reason string
   380  	cause  error
   381  	key    bool
   382  }
   383  
   384  // Field function returns field value.
   385  func (e OutlierEjectFailurePercentageValidationError) Field() string { return e.field }
   386  
   387  // Reason function returns reason value.
   388  func (e OutlierEjectFailurePercentageValidationError) Reason() string { return e.reason }
   389  
   390  // Cause function returns cause value.
   391  func (e OutlierEjectFailurePercentageValidationError) Cause() error { return e.cause }
   392  
   393  // Key function returns key value.
   394  func (e OutlierEjectFailurePercentageValidationError) Key() bool { return e.key }
   395  
   396  // ErrorName returns error name.
   397  func (e OutlierEjectFailurePercentageValidationError) ErrorName() string {
   398  	return "OutlierEjectFailurePercentageValidationError"
   399  }
   400  
   401  // Error satisfies the builtin error interface
   402  func (e OutlierEjectFailurePercentageValidationError) Error() string {
   403  	cause := ""
   404  	if e.cause != nil {
   405  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   406  	}
   407  
   408  	key := ""
   409  	if e.key {
   410  		key = "key for "
   411  	}
   412  
   413  	return fmt.Sprintf(
   414  		"invalid %sOutlierEjectFailurePercentage.%s: %s%s",
   415  		key,
   416  		e.field,
   417  		e.reason,
   418  		cause)
   419  }
   420  
   421  var _ error = OutlierEjectFailurePercentageValidationError{}
   422  
   423  var _ interface {
   424  	Field() string
   425  	Reason() string
   426  	Key() bool
   427  	Cause() error
   428  	ErrorName() string
   429  } = OutlierEjectFailurePercentageValidationError{}