...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/accesslog/v2/als.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/accesslog/v2

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

View as plain text