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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/core/v3/address.proto
     3  
     4  package envoy_config_core_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 Pipe with the rules defined in the proto
    37  // definition for this message. If any rules are violated, an error is returned.
    38  func (m *Pipe) Validate() error {
    39  	if m == nil {
    40  		return nil
    41  	}
    42  
    43  	if utf8.RuneCountInString(m.GetPath()) < 1 {
    44  		return PipeValidationError{
    45  			field:  "Path",
    46  			reason: "value length must be at least 1 runes",
    47  		}
    48  	}
    49  
    50  	if m.GetMode() > 511 {
    51  		return PipeValidationError{
    52  			field:  "Mode",
    53  			reason: "value must be less than or equal to 511",
    54  		}
    55  	}
    56  
    57  	return nil
    58  }
    59  
    60  // PipeValidationError is the validation error returned by Pipe.Validate if the
    61  // designated constraints aren't met.
    62  type PipeValidationError struct {
    63  	field  string
    64  	reason string
    65  	cause  error
    66  	key    bool
    67  }
    68  
    69  // Field function returns field value.
    70  func (e PipeValidationError) Field() string { return e.field }
    71  
    72  // Reason function returns reason value.
    73  func (e PipeValidationError) Reason() string { return e.reason }
    74  
    75  // Cause function returns cause value.
    76  func (e PipeValidationError) Cause() error { return e.cause }
    77  
    78  // Key function returns key value.
    79  func (e PipeValidationError) Key() bool { return e.key }
    80  
    81  // ErrorName returns error name.
    82  func (e PipeValidationError) ErrorName() string { return "PipeValidationError" }
    83  
    84  // Error satisfies the builtin error interface
    85  func (e PipeValidationError) Error() string {
    86  	cause := ""
    87  	if e.cause != nil {
    88  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
    89  	}
    90  
    91  	key := ""
    92  	if e.key {
    93  		key = "key for "
    94  	}
    95  
    96  	return fmt.Sprintf(
    97  		"invalid %sPipe.%s: %s%s",
    98  		key,
    99  		e.field,
   100  		e.reason,
   101  		cause)
   102  }
   103  
   104  var _ error = PipeValidationError{}
   105  
   106  var _ interface {
   107  	Field() string
   108  	Reason() string
   109  	Key() bool
   110  	Cause() error
   111  	ErrorName() string
   112  } = PipeValidationError{}
   113  
   114  // Validate checks the field values on EnvoyInternalAddress with the rules
   115  // defined in the proto definition for this message. If any rules are
   116  // violated, an error is returned.
   117  func (m *EnvoyInternalAddress) Validate() error {
   118  	if m == nil {
   119  		return nil
   120  	}
   121  
   122  	switch m.AddressNameSpecifier.(type) {
   123  
   124  	case *EnvoyInternalAddress_ServerListenerName:
   125  		// no validation rules for ServerListenerName
   126  
   127  	default:
   128  		return EnvoyInternalAddressValidationError{
   129  			field:  "AddressNameSpecifier",
   130  			reason: "value is required",
   131  		}
   132  
   133  	}
   134  
   135  	return nil
   136  }
   137  
   138  // EnvoyInternalAddressValidationError is the validation error returned by
   139  // EnvoyInternalAddress.Validate if the designated constraints aren't met.
   140  type EnvoyInternalAddressValidationError struct {
   141  	field  string
   142  	reason string
   143  	cause  error
   144  	key    bool
   145  }
   146  
   147  // Field function returns field value.
   148  func (e EnvoyInternalAddressValidationError) Field() string { return e.field }
   149  
   150  // Reason function returns reason value.
   151  func (e EnvoyInternalAddressValidationError) Reason() string { return e.reason }
   152  
   153  // Cause function returns cause value.
   154  func (e EnvoyInternalAddressValidationError) Cause() error { return e.cause }
   155  
   156  // Key function returns key value.
   157  func (e EnvoyInternalAddressValidationError) Key() bool { return e.key }
   158  
   159  // ErrorName returns error name.
   160  func (e EnvoyInternalAddressValidationError) ErrorName() string {
   161  	return "EnvoyInternalAddressValidationError"
   162  }
   163  
   164  // Error satisfies the builtin error interface
   165  func (e EnvoyInternalAddressValidationError) Error() string {
   166  	cause := ""
   167  	if e.cause != nil {
   168  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   169  	}
   170  
   171  	key := ""
   172  	if e.key {
   173  		key = "key for "
   174  	}
   175  
   176  	return fmt.Sprintf(
   177  		"invalid %sEnvoyInternalAddress.%s: %s%s",
   178  		key,
   179  		e.field,
   180  		e.reason,
   181  		cause)
   182  }
   183  
   184  var _ error = EnvoyInternalAddressValidationError{}
   185  
   186  var _ interface {
   187  	Field() string
   188  	Reason() string
   189  	Key() bool
   190  	Cause() error
   191  	ErrorName() string
   192  } = EnvoyInternalAddressValidationError{}
   193  
   194  // Validate checks the field values on SocketAddress with the rules defined in
   195  // the proto definition for this message. If any rules are violated, an error
   196  // is returned.
   197  func (m *SocketAddress) Validate() error {
   198  	if m == nil {
   199  		return nil
   200  	}
   201  
   202  	if _, ok := SocketAddress_Protocol_name[int32(m.GetProtocol())]; !ok {
   203  		return SocketAddressValidationError{
   204  			field:  "Protocol",
   205  			reason: "value must be one of the defined enum values",
   206  		}
   207  	}
   208  
   209  	if utf8.RuneCountInString(m.GetAddress()) < 1 {
   210  		return SocketAddressValidationError{
   211  			field:  "Address",
   212  			reason: "value length must be at least 1 runes",
   213  		}
   214  	}
   215  
   216  	// no validation rules for ResolverName
   217  
   218  	// no validation rules for Ipv4Compat
   219  
   220  	switch m.PortSpecifier.(type) {
   221  
   222  	case *SocketAddress_PortValue:
   223  
   224  		if m.GetPortValue() > 65535 {
   225  			return SocketAddressValidationError{
   226  				field:  "PortValue",
   227  				reason: "value must be less than or equal to 65535",
   228  			}
   229  		}
   230  
   231  	case *SocketAddress_NamedPort:
   232  		// no validation rules for NamedPort
   233  
   234  	default:
   235  		return SocketAddressValidationError{
   236  			field:  "PortSpecifier",
   237  			reason: "value is required",
   238  		}
   239  
   240  	}
   241  
   242  	return nil
   243  }
   244  
   245  // SocketAddressValidationError is the validation error returned by
   246  // SocketAddress.Validate if the designated constraints aren't met.
   247  type SocketAddressValidationError struct {
   248  	field  string
   249  	reason string
   250  	cause  error
   251  	key    bool
   252  }
   253  
   254  // Field function returns field value.
   255  func (e SocketAddressValidationError) Field() string { return e.field }
   256  
   257  // Reason function returns reason value.
   258  func (e SocketAddressValidationError) Reason() string { return e.reason }
   259  
   260  // Cause function returns cause value.
   261  func (e SocketAddressValidationError) Cause() error { return e.cause }
   262  
   263  // Key function returns key value.
   264  func (e SocketAddressValidationError) Key() bool { return e.key }
   265  
   266  // ErrorName returns error name.
   267  func (e SocketAddressValidationError) ErrorName() string { return "SocketAddressValidationError" }
   268  
   269  // Error satisfies the builtin error interface
   270  func (e SocketAddressValidationError) Error() string {
   271  	cause := ""
   272  	if e.cause != nil {
   273  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   274  	}
   275  
   276  	key := ""
   277  	if e.key {
   278  		key = "key for "
   279  	}
   280  
   281  	return fmt.Sprintf(
   282  		"invalid %sSocketAddress.%s: %s%s",
   283  		key,
   284  		e.field,
   285  		e.reason,
   286  		cause)
   287  }
   288  
   289  var _ error = SocketAddressValidationError{}
   290  
   291  var _ interface {
   292  	Field() string
   293  	Reason() string
   294  	Key() bool
   295  	Cause() error
   296  	ErrorName() string
   297  } = SocketAddressValidationError{}
   298  
   299  // Validate checks the field values on TcpKeepalive with the rules defined in
   300  // the proto definition for this message. If any rules are violated, an error
   301  // is returned.
   302  func (m *TcpKeepalive) Validate() error {
   303  	if m == nil {
   304  		return nil
   305  	}
   306  
   307  	if v, ok := interface{}(m.GetKeepaliveProbes()).(interface{ Validate() error }); ok {
   308  		if err := v.Validate(); err != nil {
   309  			return TcpKeepaliveValidationError{
   310  				field:  "KeepaliveProbes",
   311  				reason: "embedded message failed validation",
   312  				cause:  err,
   313  			}
   314  		}
   315  	}
   316  
   317  	if v, ok := interface{}(m.GetKeepaliveTime()).(interface{ Validate() error }); ok {
   318  		if err := v.Validate(); err != nil {
   319  			return TcpKeepaliveValidationError{
   320  				field:  "KeepaliveTime",
   321  				reason: "embedded message failed validation",
   322  				cause:  err,
   323  			}
   324  		}
   325  	}
   326  
   327  	if v, ok := interface{}(m.GetKeepaliveInterval()).(interface{ Validate() error }); ok {
   328  		if err := v.Validate(); err != nil {
   329  			return TcpKeepaliveValidationError{
   330  				field:  "KeepaliveInterval",
   331  				reason: "embedded message failed validation",
   332  				cause:  err,
   333  			}
   334  		}
   335  	}
   336  
   337  	return nil
   338  }
   339  
   340  // TcpKeepaliveValidationError is the validation error returned by
   341  // TcpKeepalive.Validate if the designated constraints aren't met.
   342  type TcpKeepaliveValidationError struct {
   343  	field  string
   344  	reason string
   345  	cause  error
   346  	key    bool
   347  }
   348  
   349  // Field function returns field value.
   350  func (e TcpKeepaliveValidationError) Field() string { return e.field }
   351  
   352  // Reason function returns reason value.
   353  func (e TcpKeepaliveValidationError) Reason() string { return e.reason }
   354  
   355  // Cause function returns cause value.
   356  func (e TcpKeepaliveValidationError) Cause() error { return e.cause }
   357  
   358  // Key function returns key value.
   359  func (e TcpKeepaliveValidationError) Key() bool { return e.key }
   360  
   361  // ErrorName returns error name.
   362  func (e TcpKeepaliveValidationError) ErrorName() string { return "TcpKeepaliveValidationError" }
   363  
   364  // Error satisfies the builtin error interface
   365  func (e TcpKeepaliveValidationError) Error() string {
   366  	cause := ""
   367  	if e.cause != nil {
   368  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   369  	}
   370  
   371  	key := ""
   372  	if e.key {
   373  		key = "key for "
   374  	}
   375  
   376  	return fmt.Sprintf(
   377  		"invalid %sTcpKeepalive.%s: %s%s",
   378  		key,
   379  		e.field,
   380  		e.reason,
   381  		cause)
   382  }
   383  
   384  var _ error = TcpKeepaliveValidationError{}
   385  
   386  var _ interface {
   387  	Field() string
   388  	Reason() string
   389  	Key() bool
   390  	Cause() error
   391  	ErrorName() string
   392  } = TcpKeepaliveValidationError{}
   393  
   394  // Validate checks the field values on BindConfig with the rules defined in the
   395  // proto definition for this message. If any rules are violated, an error is returned.
   396  func (m *BindConfig) Validate() error {
   397  	if m == nil {
   398  		return nil
   399  	}
   400  
   401  	if m.GetSourceAddress() == nil {
   402  		return BindConfigValidationError{
   403  			field:  "SourceAddress",
   404  			reason: "value is required",
   405  		}
   406  	}
   407  
   408  	if v, ok := interface{}(m.GetSourceAddress()).(interface{ Validate() error }); ok {
   409  		if err := v.Validate(); err != nil {
   410  			return BindConfigValidationError{
   411  				field:  "SourceAddress",
   412  				reason: "embedded message failed validation",
   413  				cause:  err,
   414  			}
   415  		}
   416  	}
   417  
   418  	if v, ok := interface{}(m.GetFreebind()).(interface{ Validate() error }); ok {
   419  		if err := v.Validate(); err != nil {
   420  			return BindConfigValidationError{
   421  				field:  "Freebind",
   422  				reason: "embedded message failed validation",
   423  				cause:  err,
   424  			}
   425  		}
   426  	}
   427  
   428  	for idx, item := range m.GetSocketOptions() {
   429  		_, _ = idx, item
   430  
   431  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   432  			if err := v.Validate(); err != nil {
   433  				return BindConfigValidationError{
   434  					field:  fmt.Sprintf("SocketOptions[%v]", idx),
   435  					reason: "embedded message failed validation",
   436  					cause:  err,
   437  				}
   438  			}
   439  		}
   440  
   441  	}
   442  
   443  	return nil
   444  }
   445  
   446  // BindConfigValidationError is the validation error returned by
   447  // BindConfig.Validate if the designated constraints aren't met.
   448  type BindConfigValidationError struct {
   449  	field  string
   450  	reason string
   451  	cause  error
   452  	key    bool
   453  }
   454  
   455  // Field function returns field value.
   456  func (e BindConfigValidationError) Field() string { return e.field }
   457  
   458  // Reason function returns reason value.
   459  func (e BindConfigValidationError) Reason() string { return e.reason }
   460  
   461  // Cause function returns cause value.
   462  func (e BindConfigValidationError) Cause() error { return e.cause }
   463  
   464  // Key function returns key value.
   465  func (e BindConfigValidationError) Key() bool { return e.key }
   466  
   467  // ErrorName returns error name.
   468  func (e BindConfigValidationError) ErrorName() string { return "BindConfigValidationError" }
   469  
   470  // Error satisfies the builtin error interface
   471  func (e BindConfigValidationError) Error() string {
   472  	cause := ""
   473  	if e.cause != nil {
   474  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   475  	}
   476  
   477  	key := ""
   478  	if e.key {
   479  		key = "key for "
   480  	}
   481  
   482  	return fmt.Sprintf(
   483  		"invalid %sBindConfig.%s: %s%s",
   484  		key,
   485  		e.field,
   486  		e.reason,
   487  		cause)
   488  }
   489  
   490  var _ error = BindConfigValidationError{}
   491  
   492  var _ interface {
   493  	Field() string
   494  	Reason() string
   495  	Key() bool
   496  	Cause() error
   497  	ErrorName() string
   498  } = BindConfigValidationError{}
   499  
   500  // Validate checks the field values on Address with the rules defined in the
   501  // proto definition for this message. If any rules are violated, an error is returned.
   502  func (m *Address) Validate() error {
   503  	if m == nil {
   504  		return nil
   505  	}
   506  
   507  	switch m.Address.(type) {
   508  
   509  	case *Address_SocketAddress:
   510  
   511  		if v, ok := interface{}(m.GetSocketAddress()).(interface{ Validate() error }); ok {
   512  			if err := v.Validate(); err != nil {
   513  				return AddressValidationError{
   514  					field:  "SocketAddress",
   515  					reason: "embedded message failed validation",
   516  					cause:  err,
   517  				}
   518  			}
   519  		}
   520  
   521  	case *Address_Pipe:
   522  
   523  		if v, ok := interface{}(m.GetPipe()).(interface{ Validate() error }); ok {
   524  			if err := v.Validate(); err != nil {
   525  				return AddressValidationError{
   526  					field:  "Pipe",
   527  					reason: "embedded message failed validation",
   528  					cause:  err,
   529  				}
   530  			}
   531  		}
   532  
   533  	case *Address_EnvoyInternalAddress:
   534  
   535  		if v, ok := interface{}(m.GetEnvoyInternalAddress()).(interface{ Validate() error }); ok {
   536  			if err := v.Validate(); err != nil {
   537  				return AddressValidationError{
   538  					field:  "EnvoyInternalAddress",
   539  					reason: "embedded message failed validation",
   540  					cause:  err,
   541  				}
   542  			}
   543  		}
   544  
   545  	default:
   546  		return AddressValidationError{
   547  			field:  "Address",
   548  			reason: "value is required",
   549  		}
   550  
   551  	}
   552  
   553  	return nil
   554  }
   555  
   556  // AddressValidationError is the validation error returned by Address.Validate
   557  // if the designated constraints aren't met.
   558  type AddressValidationError struct {
   559  	field  string
   560  	reason string
   561  	cause  error
   562  	key    bool
   563  }
   564  
   565  // Field function returns field value.
   566  func (e AddressValidationError) Field() string { return e.field }
   567  
   568  // Reason function returns reason value.
   569  func (e AddressValidationError) Reason() string { return e.reason }
   570  
   571  // Cause function returns cause value.
   572  func (e AddressValidationError) Cause() error { return e.cause }
   573  
   574  // Key function returns key value.
   575  func (e AddressValidationError) Key() bool { return e.key }
   576  
   577  // ErrorName returns error name.
   578  func (e AddressValidationError) ErrorName() string { return "AddressValidationError" }
   579  
   580  // Error satisfies the builtin error interface
   581  func (e AddressValidationError) Error() string {
   582  	cause := ""
   583  	if e.cause != nil {
   584  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   585  	}
   586  
   587  	key := ""
   588  	if e.key {
   589  		key = "key for "
   590  	}
   591  
   592  	return fmt.Sprintf(
   593  		"invalid %sAddress.%s: %s%s",
   594  		key,
   595  		e.field,
   596  		e.reason,
   597  		cause)
   598  }
   599  
   600  var _ error = AddressValidationError{}
   601  
   602  var _ interface {
   603  	Field() string
   604  	Reason() string
   605  	Key() bool
   606  	Cause() error
   607  	ErrorName() string
   608  } = AddressValidationError{}
   609  
   610  // Validate checks the field values on CidrRange with the rules defined in the
   611  // proto definition for this message. If any rules are violated, an error is returned.
   612  func (m *CidrRange) Validate() error {
   613  	if m == nil {
   614  		return nil
   615  	}
   616  
   617  	if utf8.RuneCountInString(m.GetAddressPrefix()) < 1 {
   618  		return CidrRangeValidationError{
   619  			field:  "AddressPrefix",
   620  			reason: "value length must be at least 1 runes",
   621  		}
   622  	}
   623  
   624  	if wrapper := m.GetPrefixLen(); wrapper != nil {
   625  
   626  		if wrapper.GetValue() > 128 {
   627  			return CidrRangeValidationError{
   628  				field:  "PrefixLen",
   629  				reason: "value must be less than or equal to 128",
   630  			}
   631  		}
   632  
   633  	}
   634  
   635  	return nil
   636  }
   637  
   638  // CidrRangeValidationError is the validation error returned by
   639  // CidrRange.Validate if the designated constraints aren't met.
   640  type CidrRangeValidationError struct {
   641  	field  string
   642  	reason string
   643  	cause  error
   644  	key    bool
   645  }
   646  
   647  // Field function returns field value.
   648  func (e CidrRangeValidationError) Field() string { return e.field }
   649  
   650  // Reason function returns reason value.
   651  func (e CidrRangeValidationError) Reason() string { return e.reason }
   652  
   653  // Cause function returns cause value.
   654  func (e CidrRangeValidationError) Cause() error { return e.cause }
   655  
   656  // Key function returns key value.
   657  func (e CidrRangeValidationError) Key() bool { return e.key }
   658  
   659  // ErrorName returns error name.
   660  func (e CidrRangeValidationError) ErrorName() string { return "CidrRangeValidationError" }
   661  
   662  // Error satisfies the builtin error interface
   663  func (e CidrRangeValidationError) Error() string {
   664  	cause := ""
   665  	if e.cause != nil {
   666  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   667  	}
   668  
   669  	key := ""
   670  	if e.key {
   671  		key = "key for "
   672  	}
   673  
   674  	return fmt.Sprintf(
   675  		"invalid %sCidrRange.%s: %s%s",
   676  		key,
   677  		e.field,
   678  		e.reason,
   679  		cause)
   680  }
   681  
   682  var _ error = CidrRangeValidationError{}
   683  
   684  var _ interface {
   685  	Field() string
   686  	Reason() string
   687  	Key() bool
   688  	Cause() error
   689  	ErrorName() string
   690  } = CidrRangeValidationError{}