github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/api/v2/core/config_source.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/api/v2/core/config_source.proto
     3  
     4  package envoy_api_v2_core
     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 ApiConfigSource 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 *ApiConfigSource) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if _, ok := ApiConfigSource_ApiType_name[int32(m.GetApiType())]; !ok {
    45  		return ApiConfigSourceValidationError{
    46  			field:  "ApiType",
    47  			reason: "value must be one of the defined enum values",
    48  		}
    49  	}
    50  
    51  	if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
    52  		return ApiConfigSourceValidationError{
    53  			field:  "TransportApiVersion",
    54  			reason: "value must be one of the defined enum values",
    55  		}
    56  	}
    57  
    58  	for idx, item := range m.GetGrpcServices() {
    59  		_, _ = idx, item
    60  
    61  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    62  			if err := v.Validate(); err != nil {
    63  				return ApiConfigSourceValidationError{
    64  					field:  fmt.Sprintf("GrpcServices[%v]", idx),
    65  					reason: "embedded message failed validation",
    66  					cause:  err,
    67  				}
    68  			}
    69  		}
    70  
    71  	}
    72  
    73  	if v, ok := interface{}(m.GetRefreshDelay()).(interface{ Validate() error }); ok {
    74  		if err := v.Validate(); err != nil {
    75  			return ApiConfigSourceValidationError{
    76  				field:  "RefreshDelay",
    77  				reason: "embedded message failed validation",
    78  				cause:  err,
    79  			}
    80  		}
    81  	}
    82  
    83  	if d := m.GetRequestTimeout(); d != nil {
    84  		dur, err := d.AsDuration(), d.CheckValid()
    85  		if err != nil {
    86  			return ApiConfigSourceValidationError{
    87  				field:  "RequestTimeout",
    88  				reason: "value is not a valid duration",
    89  				cause:  err,
    90  			}
    91  		}
    92  
    93  		gt := time.Duration(0*time.Second + 0*time.Nanosecond)
    94  
    95  		if dur <= gt {
    96  			return ApiConfigSourceValidationError{
    97  				field:  "RequestTimeout",
    98  				reason: "value must be greater than 0s",
    99  			}
   100  		}
   101  
   102  	}
   103  
   104  	if v, ok := interface{}(m.GetRateLimitSettings()).(interface{ Validate() error }); ok {
   105  		if err := v.Validate(); err != nil {
   106  			return ApiConfigSourceValidationError{
   107  				field:  "RateLimitSettings",
   108  				reason: "embedded message failed validation",
   109  				cause:  err,
   110  			}
   111  		}
   112  	}
   113  
   114  	// no validation rules for SetNodeOnFirstMessageOnly
   115  
   116  	return nil
   117  }
   118  
   119  // ApiConfigSourceValidationError is the validation error returned by
   120  // ApiConfigSource.Validate if the designated constraints aren't met.
   121  type ApiConfigSourceValidationError struct {
   122  	field  string
   123  	reason string
   124  	cause  error
   125  	key    bool
   126  }
   127  
   128  // Field function returns field value.
   129  func (e ApiConfigSourceValidationError) Field() string { return e.field }
   130  
   131  // Reason function returns reason value.
   132  func (e ApiConfigSourceValidationError) Reason() string { return e.reason }
   133  
   134  // Cause function returns cause value.
   135  func (e ApiConfigSourceValidationError) Cause() error { return e.cause }
   136  
   137  // Key function returns key value.
   138  func (e ApiConfigSourceValidationError) Key() bool { return e.key }
   139  
   140  // ErrorName returns error name.
   141  func (e ApiConfigSourceValidationError) ErrorName() string { return "ApiConfigSourceValidationError" }
   142  
   143  // Error satisfies the builtin error interface
   144  func (e ApiConfigSourceValidationError) Error() string {
   145  	cause := ""
   146  	if e.cause != nil {
   147  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   148  	}
   149  
   150  	key := ""
   151  	if e.key {
   152  		key = "key for "
   153  	}
   154  
   155  	return fmt.Sprintf(
   156  		"invalid %sApiConfigSource.%s: %s%s",
   157  		key,
   158  		e.field,
   159  		e.reason,
   160  		cause)
   161  }
   162  
   163  var _ error = ApiConfigSourceValidationError{}
   164  
   165  var _ interface {
   166  	Field() string
   167  	Reason() string
   168  	Key() bool
   169  	Cause() error
   170  	ErrorName() string
   171  } = ApiConfigSourceValidationError{}
   172  
   173  // Validate checks the field values on AggregatedConfigSource with the rules
   174  // defined in the proto definition for this message. If any rules are
   175  // violated, an error is returned.
   176  func (m *AggregatedConfigSource) Validate() error {
   177  	if m == nil {
   178  		return nil
   179  	}
   180  
   181  	return nil
   182  }
   183  
   184  // AggregatedConfigSourceValidationError is the validation error returned by
   185  // AggregatedConfigSource.Validate if the designated constraints aren't met.
   186  type AggregatedConfigSourceValidationError struct {
   187  	field  string
   188  	reason string
   189  	cause  error
   190  	key    bool
   191  }
   192  
   193  // Field function returns field value.
   194  func (e AggregatedConfigSourceValidationError) Field() string { return e.field }
   195  
   196  // Reason function returns reason value.
   197  func (e AggregatedConfigSourceValidationError) Reason() string { return e.reason }
   198  
   199  // Cause function returns cause value.
   200  func (e AggregatedConfigSourceValidationError) Cause() error { return e.cause }
   201  
   202  // Key function returns key value.
   203  func (e AggregatedConfigSourceValidationError) Key() bool { return e.key }
   204  
   205  // ErrorName returns error name.
   206  func (e AggregatedConfigSourceValidationError) ErrorName() string {
   207  	return "AggregatedConfigSourceValidationError"
   208  }
   209  
   210  // Error satisfies the builtin error interface
   211  func (e AggregatedConfigSourceValidationError) Error() string {
   212  	cause := ""
   213  	if e.cause != nil {
   214  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   215  	}
   216  
   217  	key := ""
   218  	if e.key {
   219  		key = "key for "
   220  	}
   221  
   222  	return fmt.Sprintf(
   223  		"invalid %sAggregatedConfigSource.%s: %s%s",
   224  		key,
   225  		e.field,
   226  		e.reason,
   227  		cause)
   228  }
   229  
   230  var _ error = AggregatedConfigSourceValidationError{}
   231  
   232  var _ interface {
   233  	Field() string
   234  	Reason() string
   235  	Key() bool
   236  	Cause() error
   237  	ErrorName() string
   238  } = AggregatedConfigSourceValidationError{}
   239  
   240  // Validate checks the field values on SelfConfigSource with the rules defined
   241  // in the proto definition for this message. If any rules are violated, an
   242  // error is returned.
   243  func (m *SelfConfigSource) Validate() error {
   244  	if m == nil {
   245  		return nil
   246  	}
   247  
   248  	if _, ok := ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
   249  		return SelfConfigSourceValidationError{
   250  			field:  "TransportApiVersion",
   251  			reason: "value must be one of the defined enum values",
   252  		}
   253  	}
   254  
   255  	return nil
   256  }
   257  
   258  // SelfConfigSourceValidationError is the validation error returned by
   259  // SelfConfigSource.Validate if the designated constraints aren't met.
   260  type SelfConfigSourceValidationError struct {
   261  	field  string
   262  	reason string
   263  	cause  error
   264  	key    bool
   265  }
   266  
   267  // Field function returns field value.
   268  func (e SelfConfigSourceValidationError) Field() string { return e.field }
   269  
   270  // Reason function returns reason value.
   271  func (e SelfConfigSourceValidationError) Reason() string { return e.reason }
   272  
   273  // Cause function returns cause value.
   274  func (e SelfConfigSourceValidationError) Cause() error { return e.cause }
   275  
   276  // Key function returns key value.
   277  func (e SelfConfigSourceValidationError) Key() bool { return e.key }
   278  
   279  // ErrorName returns error name.
   280  func (e SelfConfigSourceValidationError) ErrorName() string { return "SelfConfigSourceValidationError" }
   281  
   282  // Error satisfies the builtin error interface
   283  func (e SelfConfigSourceValidationError) Error() string {
   284  	cause := ""
   285  	if e.cause != nil {
   286  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   287  	}
   288  
   289  	key := ""
   290  	if e.key {
   291  		key = "key for "
   292  	}
   293  
   294  	return fmt.Sprintf(
   295  		"invalid %sSelfConfigSource.%s: %s%s",
   296  		key,
   297  		e.field,
   298  		e.reason,
   299  		cause)
   300  }
   301  
   302  var _ error = SelfConfigSourceValidationError{}
   303  
   304  var _ interface {
   305  	Field() string
   306  	Reason() string
   307  	Key() bool
   308  	Cause() error
   309  	ErrorName() string
   310  } = SelfConfigSourceValidationError{}
   311  
   312  // Validate checks the field values on RateLimitSettings with the rules defined
   313  // in the proto definition for this message. If any rules are violated, an
   314  // error is returned.
   315  func (m *RateLimitSettings) Validate() error {
   316  	if m == nil {
   317  		return nil
   318  	}
   319  
   320  	if v, ok := interface{}(m.GetMaxTokens()).(interface{ Validate() error }); ok {
   321  		if err := v.Validate(); err != nil {
   322  			return RateLimitSettingsValidationError{
   323  				field:  "MaxTokens",
   324  				reason: "embedded message failed validation",
   325  				cause:  err,
   326  			}
   327  		}
   328  	}
   329  
   330  	if wrapper := m.GetFillRate(); wrapper != nil {
   331  
   332  		if wrapper.GetValue() <= 0 {
   333  			return RateLimitSettingsValidationError{
   334  				field:  "FillRate",
   335  				reason: "value must be greater than 0",
   336  			}
   337  		}
   338  
   339  	}
   340  
   341  	return nil
   342  }
   343  
   344  // RateLimitSettingsValidationError is the validation error returned by
   345  // RateLimitSettings.Validate if the designated constraints aren't met.
   346  type RateLimitSettingsValidationError struct {
   347  	field  string
   348  	reason string
   349  	cause  error
   350  	key    bool
   351  }
   352  
   353  // Field function returns field value.
   354  func (e RateLimitSettingsValidationError) Field() string { return e.field }
   355  
   356  // Reason function returns reason value.
   357  func (e RateLimitSettingsValidationError) Reason() string { return e.reason }
   358  
   359  // Cause function returns cause value.
   360  func (e RateLimitSettingsValidationError) Cause() error { return e.cause }
   361  
   362  // Key function returns key value.
   363  func (e RateLimitSettingsValidationError) Key() bool { return e.key }
   364  
   365  // ErrorName returns error name.
   366  func (e RateLimitSettingsValidationError) ErrorName() string {
   367  	return "RateLimitSettingsValidationError"
   368  }
   369  
   370  // Error satisfies the builtin error interface
   371  func (e RateLimitSettingsValidationError) Error() string {
   372  	cause := ""
   373  	if e.cause != nil {
   374  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   375  	}
   376  
   377  	key := ""
   378  	if e.key {
   379  		key = "key for "
   380  	}
   381  
   382  	return fmt.Sprintf(
   383  		"invalid %sRateLimitSettings.%s: %s%s",
   384  		key,
   385  		e.field,
   386  		e.reason,
   387  		cause)
   388  }
   389  
   390  var _ error = RateLimitSettingsValidationError{}
   391  
   392  var _ interface {
   393  	Field() string
   394  	Reason() string
   395  	Key() bool
   396  	Cause() error
   397  	ErrorName() string
   398  } = RateLimitSettingsValidationError{}
   399  
   400  // Validate checks the field values on ConfigSource with the rules defined in
   401  // the proto definition for this message. If any rules are violated, an error
   402  // is returned.
   403  func (m *ConfigSource) Validate() error {
   404  	if m == nil {
   405  		return nil
   406  	}
   407  
   408  	if v, ok := interface{}(m.GetInitialFetchTimeout()).(interface{ Validate() error }); ok {
   409  		if err := v.Validate(); err != nil {
   410  			return ConfigSourceValidationError{
   411  				field:  "InitialFetchTimeout",
   412  				reason: "embedded message failed validation",
   413  				cause:  err,
   414  			}
   415  		}
   416  	}
   417  
   418  	if _, ok := ApiVersion_name[int32(m.GetResourceApiVersion())]; !ok {
   419  		return ConfigSourceValidationError{
   420  			field:  "ResourceApiVersion",
   421  			reason: "value must be one of the defined enum values",
   422  		}
   423  	}
   424  
   425  	switch m.ConfigSourceSpecifier.(type) {
   426  
   427  	case *ConfigSource_Path:
   428  		// no validation rules for Path
   429  
   430  	case *ConfigSource_ApiConfigSource:
   431  
   432  		if v, ok := interface{}(m.GetApiConfigSource()).(interface{ Validate() error }); ok {
   433  			if err := v.Validate(); err != nil {
   434  				return ConfigSourceValidationError{
   435  					field:  "ApiConfigSource",
   436  					reason: "embedded message failed validation",
   437  					cause:  err,
   438  				}
   439  			}
   440  		}
   441  
   442  	case *ConfigSource_Ads:
   443  
   444  		if v, ok := interface{}(m.GetAds()).(interface{ Validate() error }); ok {
   445  			if err := v.Validate(); err != nil {
   446  				return ConfigSourceValidationError{
   447  					field:  "Ads",
   448  					reason: "embedded message failed validation",
   449  					cause:  err,
   450  				}
   451  			}
   452  		}
   453  
   454  	case *ConfigSource_Self:
   455  
   456  		if v, ok := interface{}(m.GetSelf()).(interface{ Validate() error }); ok {
   457  			if err := v.Validate(); err != nil {
   458  				return ConfigSourceValidationError{
   459  					field:  "Self",
   460  					reason: "embedded message failed validation",
   461  					cause:  err,
   462  				}
   463  			}
   464  		}
   465  
   466  	default:
   467  		return ConfigSourceValidationError{
   468  			field:  "ConfigSourceSpecifier",
   469  			reason: "value is required",
   470  		}
   471  
   472  	}
   473  
   474  	return nil
   475  }
   476  
   477  // ConfigSourceValidationError is the validation error returned by
   478  // ConfigSource.Validate if the designated constraints aren't met.
   479  type ConfigSourceValidationError struct {
   480  	field  string
   481  	reason string
   482  	cause  error
   483  	key    bool
   484  }
   485  
   486  // Field function returns field value.
   487  func (e ConfigSourceValidationError) Field() string { return e.field }
   488  
   489  // Reason function returns reason value.
   490  func (e ConfigSourceValidationError) Reason() string { return e.reason }
   491  
   492  // Cause function returns cause value.
   493  func (e ConfigSourceValidationError) Cause() error { return e.cause }
   494  
   495  // Key function returns key value.
   496  func (e ConfigSourceValidationError) Key() bool { return e.key }
   497  
   498  // ErrorName returns error name.
   499  func (e ConfigSourceValidationError) ErrorName() string { return "ConfigSourceValidationError" }
   500  
   501  // Error satisfies the builtin error interface
   502  func (e ConfigSourceValidationError) Error() string {
   503  	cause := ""
   504  	if e.cause != nil {
   505  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   506  	}
   507  
   508  	key := ""
   509  	if e.key {
   510  		key = "key for "
   511  	}
   512  
   513  	return fmt.Sprintf(
   514  		"invalid %sConfigSource.%s: %s%s",
   515  		key,
   516  		e.field,
   517  		e.reason,
   518  		cause)
   519  }
   520  
   521  var _ error = ConfigSourceValidationError{}
   522  
   523  var _ interface {
   524  	Field() string
   525  	Reason() string
   526  	Key() bool
   527  	Cause() error
   528  	ErrorName() string
   529  } = ConfigSourceValidationError{}