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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/api/v2/auth/common.proto
     3  
     4  package envoy_api_v2_auth
     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 len(m.GetProviderName()) < 1 {
   124  		return PrivateKeyProviderValidationError{
   125  			field:  "ProviderName",
   126  			reason: "value length must be at least 1 bytes",
   127  		}
   128  	}
   129  
   130  	switch m.ConfigType.(type) {
   131  
   132  	case *PrivateKeyProvider_Config:
   133  
   134  		if v, ok := interface{}(m.GetConfig()).(interface{ Validate() error }); ok {
   135  			if err := v.Validate(); err != nil {
   136  				return PrivateKeyProviderValidationError{
   137  					field:  "Config",
   138  					reason: "embedded message failed validation",
   139  					cause:  err,
   140  				}
   141  			}
   142  		}
   143  
   144  	case *PrivateKeyProvider_TypedConfig:
   145  
   146  		if v, ok := interface{}(m.GetTypedConfig()).(interface{ Validate() error }); ok {
   147  			if err := v.Validate(); err != nil {
   148  				return PrivateKeyProviderValidationError{
   149  					field:  "TypedConfig",
   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.GetPrivateKeyProvider()).(interface{ Validate() error }); ok {
   246  		if err := v.Validate(); err != nil {
   247  			return TlsCertificateValidationError{
   248  				field:  "PrivateKeyProvider",
   249  				reason: "embedded message failed validation",
   250  				cause:  err,
   251  			}
   252  		}
   253  	}
   254  
   255  	if v, ok := interface{}(m.GetPassword()).(interface{ Validate() error }); ok {
   256  		if err := v.Validate(); err != nil {
   257  			return TlsCertificateValidationError{
   258  				field:  "Password",
   259  				reason: "embedded message failed validation",
   260  				cause:  err,
   261  			}
   262  		}
   263  	}
   264  
   265  	if v, ok := interface{}(m.GetOcspStaple()).(interface{ Validate() error }); ok {
   266  		if err := v.Validate(); err != nil {
   267  			return TlsCertificateValidationError{
   268  				field:  "OcspStaple",
   269  				reason: "embedded message failed validation",
   270  				cause:  err,
   271  			}
   272  		}
   273  	}
   274  
   275  	for idx, item := range m.GetSignedCertificateTimestamp() {
   276  		_, _ = idx, item
   277  
   278  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   279  			if err := v.Validate(); err != nil {
   280  				return TlsCertificateValidationError{
   281  					field:  fmt.Sprintf("SignedCertificateTimestamp[%v]", idx),
   282  					reason: "embedded message failed validation",
   283  					cause:  err,
   284  				}
   285  			}
   286  		}
   287  
   288  	}
   289  
   290  	return nil
   291  }
   292  
   293  // TlsCertificateValidationError is the validation error returned by
   294  // TlsCertificate.Validate if the designated constraints aren't met.
   295  type TlsCertificateValidationError struct {
   296  	field  string
   297  	reason string
   298  	cause  error
   299  	key    bool
   300  }
   301  
   302  // Field function returns field value.
   303  func (e TlsCertificateValidationError) Field() string { return e.field }
   304  
   305  // Reason function returns reason value.
   306  func (e TlsCertificateValidationError) Reason() string { return e.reason }
   307  
   308  // Cause function returns cause value.
   309  func (e TlsCertificateValidationError) Cause() error { return e.cause }
   310  
   311  // Key function returns key value.
   312  func (e TlsCertificateValidationError) Key() bool { return e.key }
   313  
   314  // ErrorName returns error name.
   315  func (e TlsCertificateValidationError) ErrorName() string { return "TlsCertificateValidationError" }
   316  
   317  // Error satisfies the builtin error interface
   318  func (e TlsCertificateValidationError) Error() string {
   319  	cause := ""
   320  	if e.cause != nil {
   321  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   322  	}
   323  
   324  	key := ""
   325  	if e.key {
   326  		key = "key for "
   327  	}
   328  
   329  	return fmt.Sprintf(
   330  		"invalid %sTlsCertificate.%s: %s%s",
   331  		key,
   332  		e.field,
   333  		e.reason,
   334  		cause)
   335  }
   336  
   337  var _ error = TlsCertificateValidationError{}
   338  
   339  var _ interface {
   340  	Field() string
   341  	Reason() string
   342  	Key() bool
   343  	Cause() error
   344  	ErrorName() string
   345  } = TlsCertificateValidationError{}
   346  
   347  // Validate checks the field values on TlsSessionTicketKeys with the rules
   348  // defined in the proto definition for this message. If any rules are
   349  // violated, an error is returned.
   350  func (m *TlsSessionTicketKeys) Validate() error {
   351  	if m == nil {
   352  		return nil
   353  	}
   354  
   355  	if len(m.GetKeys()) < 1 {
   356  		return TlsSessionTicketKeysValidationError{
   357  			field:  "Keys",
   358  			reason: "value must contain at least 1 item(s)",
   359  		}
   360  	}
   361  
   362  	for idx, item := range m.GetKeys() {
   363  		_, _ = idx, item
   364  
   365  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   366  			if err := v.Validate(); err != nil {
   367  				return TlsSessionTicketKeysValidationError{
   368  					field:  fmt.Sprintf("Keys[%v]", idx),
   369  					reason: "embedded message failed validation",
   370  					cause:  err,
   371  				}
   372  			}
   373  		}
   374  
   375  	}
   376  
   377  	return nil
   378  }
   379  
   380  // TlsSessionTicketKeysValidationError is the validation error returned by
   381  // TlsSessionTicketKeys.Validate if the designated constraints aren't met.
   382  type TlsSessionTicketKeysValidationError struct {
   383  	field  string
   384  	reason string
   385  	cause  error
   386  	key    bool
   387  }
   388  
   389  // Field function returns field value.
   390  func (e TlsSessionTicketKeysValidationError) Field() string { return e.field }
   391  
   392  // Reason function returns reason value.
   393  func (e TlsSessionTicketKeysValidationError) Reason() string { return e.reason }
   394  
   395  // Cause function returns cause value.
   396  func (e TlsSessionTicketKeysValidationError) Cause() error { return e.cause }
   397  
   398  // Key function returns key value.
   399  func (e TlsSessionTicketKeysValidationError) Key() bool { return e.key }
   400  
   401  // ErrorName returns error name.
   402  func (e TlsSessionTicketKeysValidationError) ErrorName() string {
   403  	return "TlsSessionTicketKeysValidationError"
   404  }
   405  
   406  // Error satisfies the builtin error interface
   407  func (e TlsSessionTicketKeysValidationError) Error() string {
   408  	cause := ""
   409  	if e.cause != nil {
   410  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   411  	}
   412  
   413  	key := ""
   414  	if e.key {
   415  		key = "key for "
   416  	}
   417  
   418  	return fmt.Sprintf(
   419  		"invalid %sTlsSessionTicketKeys.%s: %s%s",
   420  		key,
   421  		e.field,
   422  		e.reason,
   423  		cause)
   424  }
   425  
   426  var _ error = TlsSessionTicketKeysValidationError{}
   427  
   428  var _ interface {
   429  	Field() string
   430  	Reason() string
   431  	Key() bool
   432  	Cause() error
   433  	ErrorName() string
   434  } = TlsSessionTicketKeysValidationError{}
   435  
   436  // Validate checks the field values on CertificateValidationContext with the
   437  // rules defined in the proto definition for this message. If any rules are
   438  // violated, an error is returned.
   439  func (m *CertificateValidationContext) Validate() error {
   440  	if m == nil {
   441  		return nil
   442  	}
   443  
   444  	if v, ok := interface{}(m.GetTrustedCa()).(interface{ Validate() error }); ok {
   445  		if err := v.Validate(); err != nil {
   446  			return CertificateValidationContextValidationError{
   447  				field:  "TrustedCa",
   448  				reason: "embedded message failed validation",
   449  				cause:  err,
   450  			}
   451  		}
   452  	}
   453  
   454  	for idx, item := range m.GetVerifyCertificateSpki() {
   455  		_, _ = idx, item
   456  
   457  		if len(item) != 44 {
   458  			return CertificateValidationContextValidationError{
   459  				field:  fmt.Sprintf("VerifyCertificateSpki[%v]", idx),
   460  				reason: "value length must be 44 bytes",
   461  			}
   462  		}
   463  
   464  	}
   465  
   466  	for idx, item := range m.GetVerifyCertificateHash() {
   467  		_, _ = idx, item
   468  
   469  		if l := len(item); l < 64 || l > 95 {
   470  			return CertificateValidationContextValidationError{
   471  				field:  fmt.Sprintf("VerifyCertificateHash[%v]", idx),
   472  				reason: "value length must be between 64 and 95 bytes, inclusive",
   473  			}
   474  		}
   475  
   476  	}
   477  
   478  	for idx, item := range m.GetMatchSubjectAltNames() {
   479  		_, _ = idx, item
   480  
   481  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   482  			if err := v.Validate(); err != nil {
   483  				return CertificateValidationContextValidationError{
   484  					field:  fmt.Sprintf("MatchSubjectAltNames[%v]", idx),
   485  					reason: "embedded message failed validation",
   486  					cause:  err,
   487  				}
   488  			}
   489  		}
   490  
   491  	}
   492  
   493  	if v, ok := interface{}(m.GetRequireOcspStaple()).(interface{ Validate() error }); ok {
   494  		if err := v.Validate(); err != nil {
   495  			return CertificateValidationContextValidationError{
   496  				field:  "RequireOcspStaple",
   497  				reason: "embedded message failed validation",
   498  				cause:  err,
   499  			}
   500  		}
   501  	}
   502  
   503  	if v, ok := interface{}(m.GetRequireSignedCertificateTimestamp()).(interface{ Validate() error }); ok {
   504  		if err := v.Validate(); err != nil {
   505  			return CertificateValidationContextValidationError{
   506  				field:  "RequireSignedCertificateTimestamp",
   507  				reason: "embedded message failed validation",
   508  				cause:  err,
   509  			}
   510  		}
   511  	}
   512  
   513  	if v, ok := interface{}(m.GetCrl()).(interface{ Validate() error }); ok {
   514  		if err := v.Validate(); err != nil {
   515  			return CertificateValidationContextValidationError{
   516  				field:  "Crl",
   517  				reason: "embedded message failed validation",
   518  				cause:  err,
   519  			}
   520  		}
   521  	}
   522  
   523  	// no validation rules for AllowExpiredCertificate
   524  
   525  	if _, ok := CertificateValidationContext_TrustChainVerification_name[int32(m.GetTrustChainVerification())]; !ok {
   526  		return CertificateValidationContextValidationError{
   527  			field:  "TrustChainVerification",
   528  			reason: "value must be one of the defined enum values",
   529  		}
   530  	}
   531  
   532  	return nil
   533  }
   534  
   535  // CertificateValidationContextValidationError is the validation error returned
   536  // by CertificateValidationContext.Validate if the designated constraints
   537  // aren't met.
   538  type CertificateValidationContextValidationError struct {
   539  	field  string
   540  	reason string
   541  	cause  error
   542  	key    bool
   543  }
   544  
   545  // Field function returns field value.
   546  func (e CertificateValidationContextValidationError) Field() string { return e.field }
   547  
   548  // Reason function returns reason value.
   549  func (e CertificateValidationContextValidationError) Reason() string { return e.reason }
   550  
   551  // Cause function returns cause value.
   552  func (e CertificateValidationContextValidationError) Cause() error { return e.cause }
   553  
   554  // Key function returns key value.
   555  func (e CertificateValidationContextValidationError) Key() bool { return e.key }
   556  
   557  // ErrorName returns error name.
   558  func (e CertificateValidationContextValidationError) ErrorName() string {
   559  	return "CertificateValidationContextValidationError"
   560  }
   561  
   562  // Error satisfies the builtin error interface
   563  func (e CertificateValidationContextValidationError) Error() string {
   564  	cause := ""
   565  	if e.cause != nil {
   566  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   567  	}
   568  
   569  	key := ""
   570  	if e.key {
   571  		key = "key for "
   572  	}
   573  
   574  	return fmt.Sprintf(
   575  		"invalid %sCertificateValidationContext.%s: %s%s",
   576  		key,
   577  		e.field,
   578  		e.reason,
   579  		cause)
   580  }
   581  
   582  var _ error = CertificateValidationContextValidationError{}
   583  
   584  var _ interface {
   585  	Field() string
   586  	Reason() string
   587  	Key() bool
   588  	Cause() error
   589  	ErrorName() string
   590  } = CertificateValidationContextValidationError{}