...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/admin/v2alpha/certs.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/admin/v2alpha

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/admin/v2alpha/certs.proto
     3  
     4  package v2alpha
     5  
     6  import (
     7  	"bytes"
     8  	"errors"
     9  	"fmt"
    10  	"net"
    11  	"net/mail"
    12  	"net/url"
    13  	"regexp"
    14  	"sort"
    15  	"strings"
    16  	"time"
    17  	"unicode/utf8"
    18  
    19  	"google.golang.org/protobuf/types/known/anypb"
    20  )
    21  
    22  // ensure the imports are used
    23  var (
    24  	_ = bytes.MinRead
    25  	_ = errors.New("")
    26  	_ = fmt.Print
    27  	_ = utf8.UTFMax
    28  	_ = (*regexp.Regexp)(nil)
    29  	_ = (*strings.Reader)(nil)
    30  	_ = net.IPv4len
    31  	_ = time.Duration(0)
    32  	_ = (*url.URL)(nil)
    33  	_ = (*mail.Address)(nil)
    34  	_ = anypb.Any{}
    35  	_ = sort.Sort
    36  )
    37  
    38  // Validate checks the field values on Certificates with the rules defined in
    39  // the proto definition for this message. If any rules are violated, the first
    40  // error encountered is returned, or nil if there are no violations.
    41  func (m *Certificates) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on Certificates with the rules defined
    46  // in the proto definition for this message. If any rules are violated, the
    47  // result is a list of violation errors wrapped in CertificatesMultiError, or
    48  // nil if none found.
    49  func (m *Certificates) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *Certificates) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	for idx, item := range m.GetCertificates() {
    61  		_, _ = idx, item
    62  
    63  		if all {
    64  			switch v := interface{}(item).(type) {
    65  			case interface{ ValidateAll() error }:
    66  				if err := v.ValidateAll(); err != nil {
    67  					errors = append(errors, CertificatesValidationError{
    68  						field:  fmt.Sprintf("Certificates[%v]", idx),
    69  						reason: "embedded message failed validation",
    70  						cause:  err,
    71  					})
    72  				}
    73  			case interface{ Validate() error }:
    74  				if err := v.Validate(); err != nil {
    75  					errors = append(errors, CertificatesValidationError{
    76  						field:  fmt.Sprintf("Certificates[%v]", idx),
    77  						reason: "embedded message failed validation",
    78  						cause:  err,
    79  					})
    80  				}
    81  			}
    82  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    83  			if err := v.Validate(); err != nil {
    84  				return CertificatesValidationError{
    85  					field:  fmt.Sprintf("Certificates[%v]", idx),
    86  					reason: "embedded message failed validation",
    87  					cause:  err,
    88  				}
    89  			}
    90  		}
    91  
    92  	}
    93  
    94  	if len(errors) > 0 {
    95  		return CertificatesMultiError(errors)
    96  	}
    97  
    98  	return nil
    99  }
   100  
   101  // CertificatesMultiError is an error wrapping multiple validation errors
   102  // returned by Certificates.ValidateAll() if the designated constraints aren't met.
   103  type CertificatesMultiError []error
   104  
   105  // Error returns a concatenation of all the error messages it wraps.
   106  func (m CertificatesMultiError) Error() string {
   107  	var msgs []string
   108  	for _, err := range m {
   109  		msgs = append(msgs, err.Error())
   110  	}
   111  	return strings.Join(msgs, "; ")
   112  }
   113  
   114  // AllErrors returns a list of validation violation errors.
   115  func (m CertificatesMultiError) AllErrors() []error { return m }
   116  
   117  // CertificatesValidationError is the validation error returned by
   118  // Certificates.Validate if the designated constraints aren't met.
   119  type CertificatesValidationError struct {
   120  	field  string
   121  	reason string
   122  	cause  error
   123  	key    bool
   124  }
   125  
   126  // Field function returns field value.
   127  func (e CertificatesValidationError) Field() string { return e.field }
   128  
   129  // Reason function returns reason value.
   130  func (e CertificatesValidationError) Reason() string { return e.reason }
   131  
   132  // Cause function returns cause value.
   133  func (e CertificatesValidationError) Cause() error { return e.cause }
   134  
   135  // Key function returns key value.
   136  func (e CertificatesValidationError) Key() bool { return e.key }
   137  
   138  // ErrorName returns error name.
   139  func (e CertificatesValidationError) ErrorName() string { return "CertificatesValidationError" }
   140  
   141  // Error satisfies the builtin error interface
   142  func (e CertificatesValidationError) Error() string {
   143  	cause := ""
   144  	if e.cause != nil {
   145  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   146  	}
   147  
   148  	key := ""
   149  	if e.key {
   150  		key = "key for "
   151  	}
   152  
   153  	return fmt.Sprintf(
   154  		"invalid %sCertificates.%s: %s%s",
   155  		key,
   156  		e.field,
   157  		e.reason,
   158  		cause)
   159  }
   160  
   161  var _ error = CertificatesValidationError{}
   162  
   163  var _ interface {
   164  	Field() string
   165  	Reason() string
   166  	Key() bool
   167  	Cause() error
   168  	ErrorName() string
   169  } = CertificatesValidationError{}
   170  
   171  // Validate checks the field values on Certificate with the rules defined in
   172  // the proto definition for this message. If any rules are violated, the first
   173  // error encountered is returned, or nil if there are no violations.
   174  func (m *Certificate) Validate() error {
   175  	return m.validate(false)
   176  }
   177  
   178  // ValidateAll checks the field values on Certificate with the rules defined in
   179  // the proto definition for this message. If any rules are violated, the
   180  // result is a list of violation errors wrapped in CertificateMultiError, or
   181  // nil if none found.
   182  func (m *Certificate) ValidateAll() error {
   183  	return m.validate(true)
   184  }
   185  
   186  func (m *Certificate) validate(all bool) error {
   187  	if m == nil {
   188  		return nil
   189  	}
   190  
   191  	var errors []error
   192  
   193  	for idx, item := range m.GetCaCert() {
   194  		_, _ = idx, item
   195  
   196  		if all {
   197  			switch v := interface{}(item).(type) {
   198  			case interface{ ValidateAll() error }:
   199  				if err := v.ValidateAll(); err != nil {
   200  					errors = append(errors, CertificateValidationError{
   201  						field:  fmt.Sprintf("CaCert[%v]", idx),
   202  						reason: "embedded message failed validation",
   203  						cause:  err,
   204  					})
   205  				}
   206  			case interface{ Validate() error }:
   207  				if err := v.Validate(); err != nil {
   208  					errors = append(errors, CertificateValidationError{
   209  						field:  fmt.Sprintf("CaCert[%v]", idx),
   210  						reason: "embedded message failed validation",
   211  						cause:  err,
   212  					})
   213  				}
   214  			}
   215  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   216  			if err := v.Validate(); err != nil {
   217  				return CertificateValidationError{
   218  					field:  fmt.Sprintf("CaCert[%v]", idx),
   219  					reason: "embedded message failed validation",
   220  					cause:  err,
   221  				}
   222  			}
   223  		}
   224  
   225  	}
   226  
   227  	for idx, item := range m.GetCertChain() {
   228  		_, _ = idx, item
   229  
   230  		if all {
   231  			switch v := interface{}(item).(type) {
   232  			case interface{ ValidateAll() error }:
   233  				if err := v.ValidateAll(); err != nil {
   234  					errors = append(errors, CertificateValidationError{
   235  						field:  fmt.Sprintf("CertChain[%v]", idx),
   236  						reason: "embedded message failed validation",
   237  						cause:  err,
   238  					})
   239  				}
   240  			case interface{ Validate() error }:
   241  				if err := v.Validate(); err != nil {
   242  					errors = append(errors, CertificateValidationError{
   243  						field:  fmt.Sprintf("CertChain[%v]", idx),
   244  						reason: "embedded message failed validation",
   245  						cause:  err,
   246  					})
   247  				}
   248  			}
   249  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   250  			if err := v.Validate(); err != nil {
   251  				return CertificateValidationError{
   252  					field:  fmt.Sprintf("CertChain[%v]", idx),
   253  					reason: "embedded message failed validation",
   254  					cause:  err,
   255  				}
   256  			}
   257  		}
   258  
   259  	}
   260  
   261  	if len(errors) > 0 {
   262  		return CertificateMultiError(errors)
   263  	}
   264  
   265  	return nil
   266  }
   267  
   268  // CertificateMultiError is an error wrapping multiple validation errors
   269  // returned by Certificate.ValidateAll() if the designated constraints aren't met.
   270  type CertificateMultiError []error
   271  
   272  // Error returns a concatenation of all the error messages it wraps.
   273  func (m CertificateMultiError) Error() string {
   274  	var msgs []string
   275  	for _, err := range m {
   276  		msgs = append(msgs, err.Error())
   277  	}
   278  	return strings.Join(msgs, "; ")
   279  }
   280  
   281  // AllErrors returns a list of validation violation errors.
   282  func (m CertificateMultiError) AllErrors() []error { return m }
   283  
   284  // CertificateValidationError is the validation error returned by
   285  // Certificate.Validate if the designated constraints aren't met.
   286  type CertificateValidationError struct {
   287  	field  string
   288  	reason string
   289  	cause  error
   290  	key    bool
   291  }
   292  
   293  // Field function returns field value.
   294  func (e CertificateValidationError) Field() string { return e.field }
   295  
   296  // Reason function returns reason value.
   297  func (e CertificateValidationError) Reason() string { return e.reason }
   298  
   299  // Cause function returns cause value.
   300  func (e CertificateValidationError) Cause() error { return e.cause }
   301  
   302  // Key function returns key value.
   303  func (e CertificateValidationError) Key() bool { return e.key }
   304  
   305  // ErrorName returns error name.
   306  func (e CertificateValidationError) ErrorName() string { return "CertificateValidationError" }
   307  
   308  // Error satisfies the builtin error interface
   309  func (e CertificateValidationError) Error() string {
   310  	cause := ""
   311  	if e.cause != nil {
   312  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   313  	}
   314  
   315  	key := ""
   316  	if e.key {
   317  		key = "key for "
   318  	}
   319  
   320  	return fmt.Sprintf(
   321  		"invalid %sCertificate.%s: %s%s",
   322  		key,
   323  		e.field,
   324  		e.reason,
   325  		cause)
   326  }
   327  
   328  var _ error = CertificateValidationError{}
   329  
   330  var _ interface {
   331  	Field() string
   332  	Reason() string
   333  	Key() bool
   334  	Cause() error
   335  	ErrorName() string
   336  } = CertificateValidationError{}
   337  
   338  // Validate checks the field values on CertificateDetails with the rules
   339  // defined in the proto definition for this message. If any rules are
   340  // violated, the first error encountered is returned, or nil if there are no violations.
   341  func (m *CertificateDetails) Validate() error {
   342  	return m.validate(false)
   343  }
   344  
   345  // ValidateAll checks the field values on CertificateDetails with the rules
   346  // defined in the proto definition for this message. If any rules are
   347  // violated, the result is a list of violation errors wrapped in
   348  // CertificateDetailsMultiError, or nil if none found.
   349  func (m *CertificateDetails) ValidateAll() error {
   350  	return m.validate(true)
   351  }
   352  
   353  func (m *CertificateDetails) validate(all bool) error {
   354  	if m == nil {
   355  		return nil
   356  	}
   357  
   358  	var errors []error
   359  
   360  	// no validation rules for Path
   361  
   362  	// no validation rules for SerialNumber
   363  
   364  	for idx, item := range m.GetSubjectAltNames() {
   365  		_, _ = idx, item
   366  
   367  		if all {
   368  			switch v := interface{}(item).(type) {
   369  			case interface{ ValidateAll() error }:
   370  				if err := v.ValidateAll(); err != nil {
   371  					errors = append(errors, CertificateDetailsValidationError{
   372  						field:  fmt.Sprintf("SubjectAltNames[%v]", idx),
   373  						reason: "embedded message failed validation",
   374  						cause:  err,
   375  					})
   376  				}
   377  			case interface{ Validate() error }:
   378  				if err := v.Validate(); err != nil {
   379  					errors = append(errors, CertificateDetailsValidationError{
   380  						field:  fmt.Sprintf("SubjectAltNames[%v]", idx),
   381  						reason: "embedded message failed validation",
   382  						cause:  err,
   383  					})
   384  				}
   385  			}
   386  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   387  			if err := v.Validate(); err != nil {
   388  				return CertificateDetailsValidationError{
   389  					field:  fmt.Sprintf("SubjectAltNames[%v]", idx),
   390  					reason: "embedded message failed validation",
   391  					cause:  err,
   392  				}
   393  			}
   394  		}
   395  
   396  	}
   397  
   398  	// no validation rules for DaysUntilExpiration
   399  
   400  	if all {
   401  		switch v := interface{}(m.GetValidFrom()).(type) {
   402  		case interface{ ValidateAll() error }:
   403  			if err := v.ValidateAll(); err != nil {
   404  				errors = append(errors, CertificateDetailsValidationError{
   405  					field:  "ValidFrom",
   406  					reason: "embedded message failed validation",
   407  					cause:  err,
   408  				})
   409  			}
   410  		case interface{ Validate() error }:
   411  			if err := v.Validate(); err != nil {
   412  				errors = append(errors, CertificateDetailsValidationError{
   413  					field:  "ValidFrom",
   414  					reason: "embedded message failed validation",
   415  					cause:  err,
   416  				})
   417  			}
   418  		}
   419  	} else if v, ok := interface{}(m.GetValidFrom()).(interface{ Validate() error }); ok {
   420  		if err := v.Validate(); err != nil {
   421  			return CertificateDetailsValidationError{
   422  				field:  "ValidFrom",
   423  				reason: "embedded message failed validation",
   424  				cause:  err,
   425  			}
   426  		}
   427  	}
   428  
   429  	if all {
   430  		switch v := interface{}(m.GetExpirationTime()).(type) {
   431  		case interface{ ValidateAll() error }:
   432  			if err := v.ValidateAll(); err != nil {
   433  				errors = append(errors, CertificateDetailsValidationError{
   434  					field:  "ExpirationTime",
   435  					reason: "embedded message failed validation",
   436  					cause:  err,
   437  				})
   438  			}
   439  		case interface{ Validate() error }:
   440  			if err := v.Validate(); err != nil {
   441  				errors = append(errors, CertificateDetailsValidationError{
   442  					field:  "ExpirationTime",
   443  					reason: "embedded message failed validation",
   444  					cause:  err,
   445  				})
   446  			}
   447  		}
   448  	} else if v, ok := interface{}(m.GetExpirationTime()).(interface{ Validate() error }); ok {
   449  		if err := v.Validate(); err != nil {
   450  			return CertificateDetailsValidationError{
   451  				field:  "ExpirationTime",
   452  				reason: "embedded message failed validation",
   453  				cause:  err,
   454  			}
   455  		}
   456  	}
   457  
   458  	if len(errors) > 0 {
   459  		return CertificateDetailsMultiError(errors)
   460  	}
   461  
   462  	return nil
   463  }
   464  
   465  // CertificateDetailsMultiError is an error wrapping multiple validation errors
   466  // returned by CertificateDetails.ValidateAll() if the designated constraints
   467  // aren't met.
   468  type CertificateDetailsMultiError []error
   469  
   470  // Error returns a concatenation of all the error messages it wraps.
   471  func (m CertificateDetailsMultiError) Error() string {
   472  	var msgs []string
   473  	for _, err := range m {
   474  		msgs = append(msgs, err.Error())
   475  	}
   476  	return strings.Join(msgs, "; ")
   477  }
   478  
   479  // AllErrors returns a list of validation violation errors.
   480  func (m CertificateDetailsMultiError) AllErrors() []error { return m }
   481  
   482  // CertificateDetailsValidationError is the validation error returned by
   483  // CertificateDetails.Validate if the designated constraints aren't met.
   484  type CertificateDetailsValidationError struct {
   485  	field  string
   486  	reason string
   487  	cause  error
   488  	key    bool
   489  }
   490  
   491  // Field function returns field value.
   492  func (e CertificateDetailsValidationError) Field() string { return e.field }
   493  
   494  // Reason function returns reason value.
   495  func (e CertificateDetailsValidationError) Reason() string { return e.reason }
   496  
   497  // Cause function returns cause value.
   498  func (e CertificateDetailsValidationError) Cause() error { return e.cause }
   499  
   500  // Key function returns key value.
   501  func (e CertificateDetailsValidationError) Key() bool { return e.key }
   502  
   503  // ErrorName returns error name.
   504  func (e CertificateDetailsValidationError) ErrorName() string {
   505  	return "CertificateDetailsValidationError"
   506  }
   507  
   508  // Error satisfies the builtin error interface
   509  func (e CertificateDetailsValidationError) Error() string {
   510  	cause := ""
   511  	if e.cause != nil {
   512  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   513  	}
   514  
   515  	key := ""
   516  	if e.key {
   517  		key = "key for "
   518  	}
   519  
   520  	return fmt.Sprintf(
   521  		"invalid %sCertificateDetails.%s: %s%s",
   522  		key,
   523  		e.field,
   524  		e.reason,
   525  		cause)
   526  }
   527  
   528  var _ error = CertificateDetailsValidationError{}
   529  
   530  var _ interface {
   531  	Field() string
   532  	Reason() string
   533  	Key() bool
   534  	Cause() error
   535  	ErrorName() string
   536  } = CertificateDetailsValidationError{}
   537  
   538  // Validate checks the field values on SubjectAlternateName with the rules
   539  // defined in the proto definition for this message. If any rules are
   540  // violated, the first error encountered is returned, or nil if there are no violations.
   541  func (m *SubjectAlternateName) Validate() error {
   542  	return m.validate(false)
   543  }
   544  
   545  // ValidateAll checks the field values on SubjectAlternateName with the rules
   546  // defined in the proto definition for this message. If any rules are
   547  // violated, the result is a list of violation errors wrapped in
   548  // SubjectAlternateNameMultiError, or nil if none found.
   549  func (m *SubjectAlternateName) ValidateAll() error {
   550  	return m.validate(true)
   551  }
   552  
   553  func (m *SubjectAlternateName) validate(all bool) error {
   554  	if m == nil {
   555  		return nil
   556  	}
   557  
   558  	var errors []error
   559  
   560  	switch v := m.Name.(type) {
   561  	case *SubjectAlternateName_Dns:
   562  		if v == nil {
   563  			err := SubjectAlternateNameValidationError{
   564  				field:  "Name",
   565  				reason: "oneof value cannot be a typed-nil",
   566  			}
   567  			if !all {
   568  				return err
   569  			}
   570  			errors = append(errors, err)
   571  		}
   572  		// no validation rules for Dns
   573  	case *SubjectAlternateName_Uri:
   574  		if v == nil {
   575  			err := SubjectAlternateNameValidationError{
   576  				field:  "Name",
   577  				reason: "oneof value cannot be a typed-nil",
   578  			}
   579  			if !all {
   580  				return err
   581  			}
   582  			errors = append(errors, err)
   583  		}
   584  		// no validation rules for Uri
   585  	case *SubjectAlternateName_IpAddress:
   586  		if v == nil {
   587  			err := SubjectAlternateNameValidationError{
   588  				field:  "Name",
   589  				reason: "oneof value cannot be a typed-nil",
   590  			}
   591  			if !all {
   592  				return err
   593  			}
   594  			errors = append(errors, err)
   595  		}
   596  		// no validation rules for IpAddress
   597  	default:
   598  		_ = v // ensures v is used
   599  	}
   600  
   601  	if len(errors) > 0 {
   602  		return SubjectAlternateNameMultiError(errors)
   603  	}
   604  
   605  	return nil
   606  }
   607  
   608  // SubjectAlternateNameMultiError is an error wrapping multiple validation
   609  // errors returned by SubjectAlternateName.ValidateAll() if the designated
   610  // constraints aren't met.
   611  type SubjectAlternateNameMultiError []error
   612  
   613  // Error returns a concatenation of all the error messages it wraps.
   614  func (m SubjectAlternateNameMultiError) Error() string {
   615  	var msgs []string
   616  	for _, err := range m {
   617  		msgs = append(msgs, err.Error())
   618  	}
   619  	return strings.Join(msgs, "; ")
   620  }
   621  
   622  // AllErrors returns a list of validation violation errors.
   623  func (m SubjectAlternateNameMultiError) AllErrors() []error { return m }
   624  
   625  // SubjectAlternateNameValidationError is the validation error returned by
   626  // SubjectAlternateName.Validate if the designated constraints aren't met.
   627  type SubjectAlternateNameValidationError struct {
   628  	field  string
   629  	reason string
   630  	cause  error
   631  	key    bool
   632  }
   633  
   634  // Field function returns field value.
   635  func (e SubjectAlternateNameValidationError) Field() string { return e.field }
   636  
   637  // Reason function returns reason value.
   638  func (e SubjectAlternateNameValidationError) Reason() string { return e.reason }
   639  
   640  // Cause function returns cause value.
   641  func (e SubjectAlternateNameValidationError) Cause() error { return e.cause }
   642  
   643  // Key function returns key value.
   644  func (e SubjectAlternateNameValidationError) Key() bool { return e.key }
   645  
   646  // ErrorName returns error name.
   647  func (e SubjectAlternateNameValidationError) ErrorName() string {
   648  	return "SubjectAlternateNameValidationError"
   649  }
   650  
   651  // Error satisfies the builtin error interface
   652  func (e SubjectAlternateNameValidationError) Error() string {
   653  	cause := ""
   654  	if e.cause != nil {
   655  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   656  	}
   657  
   658  	key := ""
   659  	if e.key {
   660  		key = "key for "
   661  	}
   662  
   663  	return fmt.Sprintf(
   664  		"invalid %sSubjectAlternateName.%s: %s%s",
   665  		key,
   666  		e.field,
   667  		e.reason,
   668  		cause)
   669  }
   670  
   671  var _ error = SubjectAlternateNameValidationError{}
   672  
   673  var _ interface {
   674  	Field() string
   675  	Reason() string
   676  	Key() bool
   677  	Cause() error
   678  	ErrorName() string
   679  } = SubjectAlternateNameValidationError{}
   680  

View as plain text