github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/overload/v2alpha/overload.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/overload/v2alpha/overload.proto
     3  
     4  package envoy_config_overload_v2alpha
     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 ResourceMonitor 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 *ResourceMonitor) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if len(m.GetName()) < 1 {
    45  		return ResourceMonitorValidationError{
    46  			field:  "Name",
    47  			reason: "value length must be at least 1 bytes",
    48  		}
    49  	}
    50  
    51  	switch m.ConfigType.(type) {
    52  
    53  	case *ResourceMonitor_Config:
    54  
    55  		if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
    56  			if err := v.Validate(); err != nil {
    57  				return ResourceMonitorValidationError{
    58  					field:  "Config",
    59  					reason: "embedded message failed validation",
    60  					cause:  err,
    61  				}
    62  			}
    63  		}
    64  
    65  	case *ResourceMonitor_TypedConfig:
    66  
    67  		if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
    68  			if err := v.Validate(); err != nil {
    69  				return ResourceMonitorValidationError{
    70  					field:  "TypedConfig",
    71  					reason: "embedded message failed validation",
    72  					cause:  err,
    73  				}
    74  			}
    75  		}
    76  
    77  	}
    78  
    79  	return nil
    80  }
    81  
    82  // ResourceMonitorValidationError is the validation error returned by
    83  // ResourceMonitor.Validate if the designated constraints aren't met.
    84  type ResourceMonitorValidationError struct {
    85  	field  string
    86  	reason string
    87  	cause  error
    88  	key    bool
    89  }
    90  
    91  // Field function returns field value.
    92  func (e ResourceMonitorValidationError) Field() string { return e.field }
    93  
    94  // Reason function returns reason value.
    95  func (e ResourceMonitorValidationError) Reason() string { return e.reason }
    96  
    97  // Cause function returns cause value.
    98  func (e ResourceMonitorValidationError) Cause() error { return e.cause }
    99  
   100  // Key function returns key value.
   101  func (e ResourceMonitorValidationError) Key() bool { return e.key }
   102  
   103  // ErrorName returns error name.
   104  func (e ResourceMonitorValidationError) ErrorName() string { return "ResourceMonitorValidationError" }
   105  
   106  // Error satisfies the builtin error interface
   107  func (e ResourceMonitorValidationError) Error() string {
   108  	cause := ""
   109  	if e.cause != nil {
   110  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   111  	}
   112  
   113  	key := ""
   114  	if e.key {
   115  		key = "key for "
   116  	}
   117  
   118  	return fmt.Sprintf(
   119  		"invalid %sResourceMonitor.%s: %s%s",
   120  		key,
   121  		e.field,
   122  		e.reason,
   123  		cause)
   124  }
   125  
   126  var _ error = ResourceMonitorValidationError{}
   127  
   128  var _ interface {
   129  	Field() string
   130  	Reason() string
   131  	Key() bool
   132  	Cause() error
   133  	ErrorName() string
   134  } = ResourceMonitorValidationError{}
   135  
   136  // Validate checks the field values on ThresholdTrigger with the rules defined
   137  // in the proto definition for this message. If any rules are violated, an
   138  // error is returned.
   139  func (m *ThresholdTrigger) Validate() error {
   140  	if m == nil {
   141  		return nil
   142  	}
   143  
   144  	if val := m.GetValue(); val < 0 || val > 1 {
   145  		return ThresholdTriggerValidationError{
   146  			field:  "Value",
   147  			reason: "value must be inside range [0, 1]",
   148  		}
   149  	}
   150  
   151  	return nil
   152  }
   153  
   154  // ThresholdTriggerValidationError is the validation error returned by
   155  // ThresholdTrigger.Validate if the designated constraints aren't met.
   156  type ThresholdTriggerValidationError struct {
   157  	field  string
   158  	reason string
   159  	cause  error
   160  	key    bool
   161  }
   162  
   163  // Field function returns field value.
   164  func (e ThresholdTriggerValidationError) Field() string { return e.field }
   165  
   166  // Reason function returns reason value.
   167  func (e ThresholdTriggerValidationError) Reason() string { return e.reason }
   168  
   169  // Cause function returns cause value.
   170  func (e ThresholdTriggerValidationError) Cause() error { return e.cause }
   171  
   172  // Key function returns key value.
   173  func (e ThresholdTriggerValidationError) Key() bool { return e.key }
   174  
   175  // ErrorName returns error name.
   176  func (e ThresholdTriggerValidationError) ErrorName() string { return "ThresholdTriggerValidationError" }
   177  
   178  // Error satisfies the builtin error interface
   179  func (e ThresholdTriggerValidationError) Error() string {
   180  	cause := ""
   181  	if e.cause != nil {
   182  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   183  	}
   184  
   185  	key := ""
   186  	if e.key {
   187  		key = "key for "
   188  	}
   189  
   190  	return fmt.Sprintf(
   191  		"invalid %sThresholdTrigger.%s: %s%s",
   192  		key,
   193  		e.field,
   194  		e.reason,
   195  		cause)
   196  }
   197  
   198  var _ error = ThresholdTriggerValidationError{}
   199  
   200  var _ interface {
   201  	Field() string
   202  	Reason() string
   203  	Key() bool
   204  	Cause() error
   205  	ErrorName() string
   206  } = ThresholdTriggerValidationError{}
   207  
   208  // Validate checks the field values on Trigger with the rules defined in the
   209  // proto definition for this message. If any rules are violated, an error is returned.
   210  func (m *Trigger) Validate() error {
   211  	if m == nil {
   212  		return nil
   213  	}
   214  
   215  	if len(m.GetName()) < 1 {
   216  		return TriggerValidationError{
   217  			field:  "Name",
   218  			reason: "value length must be at least 1 bytes",
   219  		}
   220  	}
   221  
   222  	switch m.TriggerOneof.(type) {
   223  
   224  	case *Trigger_Threshold:
   225  
   226  		if v, ok := interface{}(m.GetThreshold()).(interface{ Validate() error }); ok {
   227  			if err := v.Validate(); err != nil {
   228  				return TriggerValidationError{
   229  					field:  "Threshold",
   230  					reason: "embedded message failed validation",
   231  					cause:  err,
   232  				}
   233  			}
   234  		}
   235  
   236  	default:
   237  		return TriggerValidationError{
   238  			field:  "TriggerOneof",
   239  			reason: "value is required",
   240  		}
   241  
   242  	}
   243  
   244  	return nil
   245  }
   246  
   247  // TriggerValidationError is the validation error returned by Trigger.Validate
   248  // if the designated constraints aren't met.
   249  type TriggerValidationError struct {
   250  	field  string
   251  	reason string
   252  	cause  error
   253  	key    bool
   254  }
   255  
   256  // Field function returns field value.
   257  func (e TriggerValidationError) Field() string { return e.field }
   258  
   259  // Reason function returns reason value.
   260  func (e TriggerValidationError) Reason() string { return e.reason }
   261  
   262  // Cause function returns cause value.
   263  func (e TriggerValidationError) Cause() error { return e.cause }
   264  
   265  // Key function returns key value.
   266  func (e TriggerValidationError) Key() bool { return e.key }
   267  
   268  // ErrorName returns error name.
   269  func (e TriggerValidationError) ErrorName() string { return "TriggerValidationError" }
   270  
   271  // Error satisfies the builtin error interface
   272  func (e TriggerValidationError) Error() string {
   273  	cause := ""
   274  	if e.cause != nil {
   275  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   276  	}
   277  
   278  	key := ""
   279  	if e.key {
   280  		key = "key for "
   281  	}
   282  
   283  	return fmt.Sprintf(
   284  		"invalid %sTrigger.%s: %s%s",
   285  		key,
   286  		e.field,
   287  		e.reason,
   288  		cause)
   289  }
   290  
   291  var _ error = TriggerValidationError{}
   292  
   293  var _ interface {
   294  	Field() string
   295  	Reason() string
   296  	Key() bool
   297  	Cause() error
   298  	ErrorName() string
   299  } = TriggerValidationError{}
   300  
   301  // Validate checks the field values on OverloadAction with the rules defined in
   302  // the proto definition for this message. If any rules are violated, an error
   303  // is returned.
   304  func (m *OverloadAction) Validate() error {
   305  	if m == nil {
   306  		return nil
   307  	}
   308  
   309  	if len(m.GetName()) < 1 {
   310  		return OverloadActionValidationError{
   311  			field:  "Name",
   312  			reason: "value length must be at least 1 bytes",
   313  		}
   314  	}
   315  
   316  	if len(m.GetTriggers()) < 1 {
   317  		return OverloadActionValidationError{
   318  			field:  "Triggers",
   319  			reason: "value must contain at least 1 item(s)",
   320  		}
   321  	}
   322  
   323  	for idx, item := range m.GetTriggers() {
   324  		_, _ = idx, item
   325  
   326  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   327  			if err := v.Validate(); err != nil {
   328  				return OverloadActionValidationError{
   329  					field:  fmt.Sprintf("Triggers[%v]", idx),
   330  					reason: "embedded message failed validation",
   331  					cause:  err,
   332  				}
   333  			}
   334  		}
   335  
   336  	}
   337  
   338  	return nil
   339  }
   340  
   341  // OverloadActionValidationError is the validation error returned by
   342  // OverloadAction.Validate if the designated constraints aren't met.
   343  type OverloadActionValidationError struct {
   344  	field  string
   345  	reason string
   346  	cause  error
   347  	key    bool
   348  }
   349  
   350  // Field function returns field value.
   351  func (e OverloadActionValidationError) Field() string { return e.field }
   352  
   353  // Reason function returns reason value.
   354  func (e OverloadActionValidationError) Reason() string { return e.reason }
   355  
   356  // Cause function returns cause value.
   357  func (e OverloadActionValidationError) Cause() error { return e.cause }
   358  
   359  // Key function returns key value.
   360  func (e OverloadActionValidationError) Key() bool { return e.key }
   361  
   362  // ErrorName returns error name.
   363  func (e OverloadActionValidationError) ErrorName() string { return "OverloadActionValidationError" }
   364  
   365  // Error satisfies the builtin error interface
   366  func (e OverloadActionValidationError) Error() string {
   367  	cause := ""
   368  	if e.cause != nil {
   369  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   370  	}
   371  
   372  	key := ""
   373  	if e.key {
   374  		key = "key for "
   375  	}
   376  
   377  	return fmt.Sprintf(
   378  		"invalid %sOverloadAction.%s: %s%s",
   379  		key,
   380  		e.field,
   381  		e.reason,
   382  		cause)
   383  }
   384  
   385  var _ error = OverloadActionValidationError{}
   386  
   387  var _ interface {
   388  	Field() string
   389  	Reason() string
   390  	Key() bool
   391  	Cause() error
   392  	ErrorName() string
   393  } = OverloadActionValidationError{}
   394  
   395  // Validate checks the field values on OverloadManager with the rules defined
   396  // in the proto definition for this message. If any rules are violated, an
   397  // error is returned.
   398  func (m *OverloadManager) Validate() error {
   399  	if m == nil {
   400  		return nil
   401  	}
   402  
   403  	if v, ok := interface{}(m.GetRefreshInterval()).(interface{ Validate() error }); ok {
   404  		if err := v.Validate(); err != nil {
   405  			return OverloadManagerValidationError{
   406  				field:  "RefreshInterval",
   407  				reason: "embedded message failed validation",
   408  				cause:  err,
   409  			}
   410  		}
   411  	}
   412  
   413  	if len(m.GetResourceMonitors()) < 1 {
   414  		return OverloadManagerValidationError{
   415  			field:  "ResourceMonitors",
   416  			reason: "value must contain at least 1 item(s)",
   417  		}
   418  	}
   419  
   420  	for idx, item := range m.GetResourceMonitors() {
   421  		_, _ = idx, item
   422  
   423  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   424  			if err := v.Validate(); err != nil {
   425  				return OverloadManagerValidationError{
   426  					field:  fmt.Sprintf("ResourceMonitors[%v]", idx),
   427  					reason: "embedded message failed validation",
   428  					cause:  err,
   429  				}
   430  			}
   431  		}
   432  
   433  	}
   434  
   435  	for idx, item := range m.GetActions() {
   436  		_, _ = idx, item
   437  
   438  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   439  			if err := v.Validate(); err != nil {
   440  				return OverloadManagerValidationError{
   441  					field:  fmt.Sprintf("Actions[%v]", idx),
   442  					reason: "embedded message failed validation",
   443  					cause:  err,
   444  				}
   445  			}
   446  		}
   447  
   448  	}
   449  
   450  	return nil
   451  }
   452  
   453  // OverloadManagerValidationError is the validation error returned by
   454  // OverloadManager.Validate if the designated constraints aren't met.
   455  type OverloadManagerValidationError struct {
   456  	field  string
   457  	reason string
   458  	cause  error
   459  	key    bool
   460  }
   461  
   462  // Field function returns field value.
   463  func (e OverloadManagerValidationError) Field() string { return e.field }
   464  
   465  // Reason function returns reason value.
   466  func (e OverloadManagerValidationError) Reason() string { return e.reason }
   467  
   468  // Cause function returns cause value.
   469  func (e OverloadManagerValidationError) Cause() error { return e.cause }
   470  
   471  // Key function returns key value.
   472  func (e OverloadManagerValidationError) Key() bool { return e.key }
   473  
   474  // ErrorName returns error name.
   475  func (e OverloadManagerValidationError) ErrorName() string { return "OverloadManagerValidationError" }
   476  
   477  // Error satisfies the builtin error interface
   478  func (e OverloadManagerValidationError) Error() string {
   479  	cause := ""
   480  	if e.cause != nil {
   481  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   482  	}
   483  
   484  	key := ""
   485  	if e.key {
   486  		key = "key for "
   487  	}
   488  
   489  	return fmt.Sprintf(
   490  		"invalid %sOverloadManager.%s: %s%s",
   491  		key,
   492  		e.field,
   493  		e.reason,
   494  		cause)
   495  }
   496  
   497  var _ error = OverloadManagerValidationError{}
   498  
   499  var _ interface {
   500  	Field() string
   501  	Reason() string
   502  	Key() bool
   503  	Cause() error
   504  	ErrorName() string
   505  } = OverloadManagerValidationError{}