github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/extensions/transport_sockets/tls/v3/common.pb.validate.go (about)

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