...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/service/load_stats/v2/lrs.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/service/load_stats/v2

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/service/load_stats/v2/lrs.proto
     3  
     4  package load_statsv2
     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 LoadStatsRequest with the rules defined
    39  // in the proto definition for this message. If any rules are violated, the
    40  // first error encountered is returned, or nil if there are no violations.
    41  func (m *LoadStatsRequest) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on LoadStatsRequest with the rules
    46  // 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  // LoadStatsRequestMultiError, or nil if none found.
    49  func (m *LoadStatsRequest) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *LoadStatsRequest) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	if all {
    61  		switch v := interface{}(m.GetNode()).(type) {
    62  		case interface{ ValidateAll() error }:
    63  			if err := v.ValidateAll(); err != nil {
    64  				errors = append(errors, LoadStatsRequestValidationError{
    65  					field:  "Node",
    66  					reason: "embedded message failed validation",
    67  					cause:  err,
    68  				})
    69  			}
    70  		case interface{ Validate() error }:
    71  			if err := v.Validate(); err != nil {
    72  				errors = append(errors, LoadStatsRequestValidationError{
    73  					field:  "Node",
    74  					reason: "embedded message failed validation",
    75  					cause:  err,
    76  				})
    77  			}
    78  		}
    79  	} else if v, ok := interface{}(m.GetNode()).(interface{ Validate() error }); ok {
    80  		if err := v.Validate(); err != nil {
    81  			return LoadStatsRequestValidationError{
    82  				field:  "Node",
    83  				reason: "embedded message failed validation",
    84  				cause:  err,
    85  			}
    86  		}
    87  	}
    88  
    89  	for idx, item := range m.GetClusterStats() {
    90  		_, _ = idx, item
    91  
    92  		if all {
    93  			switch v := interface{}(item).(type) {
    94  			case interface{ ValidateAll() error }:
    95  				if err := v.ValidateAll(); err != nil {
    96  					errors = append(errors, LoadStatsRequestValidationError{
    97  						field:  fmt.Sprintf("ClusterStats[%v]", idx),
    98  						reason: "embedded message failed validation",
    99  						cause:  err,
   100  					})
   101  				}
   102  			case interface{ Validate() error }:
   103  				if err := v.Validate(); err != nil {
   104  					errors = append(errors, LoadStatsRequestValidationError{
   105  						field:  fmt.Sprintf("ClusterStats[%v]", idx),
   106  						reason: "embedded message failed validation",
   107  						cause:  err,
   108  					})
   109  				}
   110  			}
   111  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   112  			if err := v.Validate(); err != nil {
   113  				return LoadStatsRequestValidationError{
   114  					field:  fmt.Sprintf("ClusterStats[%v]", idx),
   115  					reason: "embedded message failed validation",
   116  					cause:  err,
   117  				}
   118  			}
   119  		}
   120  
   121  	}
   122  
   123  	if len(errors) > 0 {
   124  		return LoadStatsRequestMultiError(errors)
   125  	}
   126  
   127  	return nil
   128  }
   129  
   130  // LoadStatsRequestMultiError is an error wrapping multiple validation errors
   131  // returned by LoadStatsRequest.ValidateAll() if the designated constraints
   132  // aren't met.
   133  type LoadStatsRequestMultiError []error
   134  
   135  // Error returns a concatenation of all the error messages it wraps.
   136  func (m LoadStatsRequestMultiError) Error() string {
   137  	var msgs []string
   138  	for _, err := range m {
   139  		msgs = append(msgs, err.Error())
   140  	}
   141  	return strings.Join(msgs, "; ")
   142  }
   143  
   144  // AllErrors returns a list of validation violation errors.
   145  func (m LoadStatsRequestMultiError) AllErrors() []error { return m }
   146  
   147  // LoadStatsRequestValidationError is the validation error returned by
   148  // LoadStatsRequest.Validate if the designated constraints aren't met.
   149  type LoadStatsRequestValidationError struct {
   150  	field  string
   151  	reason string
   152  	cause  error
   153  	key    bool
   154  }
   155  
   156  // Field function returns field value.
   157  func (e LoadStatsRequestValidationError) Field() string { return e.field }
   158  
   159  // Reason function returns reason value.
   160  func (e LoadStatsRequestValidationError) Reason() string { return e.reason }
   161  
   162  // Cause function returns cause value.
   163  func (e LoadStatsRequestValidationError) Cause() error { return e.cause }
   164  
   165  // Key function returns key value.
   166  func (e LoadStatsRequestValidationError) Key() bool { return e.key }
   167  
   168  // ErrorName returns error name.
   169  func (e LoadStatsRequestValidationError) ErrorName() string { return "LoadStatsRequestValidationError" }
   170  
   171  // Error satisfies the builtin error interface
   172  func (e LoadStatsRequestValidationError) Error() string {
   173  	cause := ""
   174  	if e.cause != nil {
   175  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   176  	}
   177  
   178  	key := ""
   179  	if e.key {
   180  		key = "key for "
   181  	}
   182  
   183  	return fmt.Sprintf(
   184  		"invalid %sLoadStatsRequest.%s: %s%s",
   185  		key,
   186  		e.field,
   187  		e.reason,
   188  		cause)
   189  }
   190  
   191  var _ error = LoadStatsRequestValidationError{}
   192  
   193  var _ interface {
   194  	Field() string
   195  	Reason() string
   196  	Key() bool
   197  	Cause() error
   198  	ErrorName() string
   199  } = LoadStatsRequestValidationError{}
   200  
   201  // Validate checks the field values on LoadStatsResponse with the rules defined
   202  // in the proto definition for this message. If any rules are violated, the
   203  // first error encountered is returned, or nil if there are no violations.
   204  func (m *LoadStatsResponse) Validate() error {
   205  	return m.validate(false)
   206  }
   207  
   208  // ValidateAll checks the field values on LoadStatsResponse with the rules
   209  // defined in the proto definition for this message. If any rules are
   210  // violated, the result is a list of violation errors wrapped in
   211  // LoadStatsResponseMultiError, or nil if none found.
   212  func (m *LoadStatsResponse) ValidateAll() error {
   213  	return m.validate(true)
   214  }
   215  
   216  func (m *LoadStatsResponse) validate(all bool) error {
   217  	if m == nil {
   218  		return nil
   219  	}
   220  
   221  	var errors []error
   222  
   223  	// no validation rules for SendAllClusters
   224  
   225  	if all {
   226  		switch v := interface{}(m.GetLoadReportingInterval()).(type) {
   227  		case interface{ ValidateAll() error }:
   228  			if err := v.ValidateAll(); err != nil {
   229  				errors = append(errors, LoadStatsResponseValidationError{
   230  					field:  "LoadReportingInterval",
   231  					reason: "embedded message failed validation",
   232  					cause:  err,
   233  				})
   234  			}
   235  		case interface{ Validate() error }:
   236  			if err := v.Validate(); err != nil {
   237  				errors = append(errors, LoadStatsResponseValidationError{
   238  					field:  "LoadReportingInterval",
   239  					reason: "embedded message failed validation",
   240  					cause:  err,
   241  				})
   242  			}
   243  		}
   244  	} else if v, ok := interface{}(m.GetLoadReportingInterval()).(interface{ Validate() error }); ok {
   245  		if err := v.Validate(); err != nil {
   246  			return LoadStatsResponseValidationError{
   247  				field:  "LoadReportingInterval",
   248  				reason: "embedded message failed validation",
   249  				cause:  err,
   250  			}
   251  		}
   252  	}
   253  
   254  	// no validation rules for ReportEndpointGranularity
   255  
   256  	if len(errors) > 0 {
   257  		return LoadStatsResponseMultiError(errors)
   258  	}
   259  
   260  	return nil
   261  }
   262  
   263  // LoadStatsResponseMultiError is an error wrapping multiple validation errors
   264  // returned by LoadStatsResponse.ValidateAll() if the designated constraints
   265  // aren't met.
   266  type LoadStatsResponseMultiError []error
   267  
   268  // Error returns a concatenation of all the error messages it wraps.
   269  func (m LoadStatsResponseMultiError) Error() string {
   270  	var msgs []string
   271  	for _, err := range m {
   272  		msgs = append(msgs, err.Error())
   273  	}
   274  	return strings.Join(msgs, "; ")
   275  }
   276  
   277  // AllErrors returns a list of validation violation errors.
   278  func (m LoadStatsResponseMultiError) AllErrors() []error { return m }
   279  
   280  // LoadStatsResponseValidationError is the validation error returned by
   281  // LoadStatsResponse.Validate if the designated constraints aren't met.
   282  type LoadStatsResponseValidationError struct {
   283  	field  string
   284  	reason string
   285  	cause  error
   286  	key    bool
   287  }
   288  
   289  // Field function returns field value.
   290  func (e LoadStatsResponseValidationError) Field() string { return e.field }
   291  
   292  // Reason function returns reason value.
   293  func (e LoadStatsResponseValidationError) Reason() string { return e.reason }
   294  
   295  // Cause function returns cause value.
   296  func (e LoadStatsResponseValidationError) Cause() error { return e.cause }
   297  
   298  // Key function returns key value.
   299  func (e LoadStatsResponseValidationError) Key() bool { return e.key }
   300  
   301  // ErrorName returns error name.
   302  func (e LoadStatsResponseValidationError) ErrorName() string {
   303  	return "LoadStatsResponseValidationError"
   304  }
   305  
   306  // Error satisfies the builtin error interface
   307  func (e LoadStatsResponseValidationError) Error() string {
   308  	cause := ""
   309  	if e.cause != nil {
   310  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   311  	}
   312  
   313  	key := ""
   314  	if e.key {
   315  		key = "key for "
   316  	}
   317  
   318  	return fmt.Sprintf(
   319  		"invalid %sLoadStatsResponse.%s: %s%s",
   320  		key,
   321  		e.field,
   322  		e.reason,
   323  		cause)
   324  }
   325  
   326  var _ error = LoadStatsResponseValidationError{}
   327  
   328  var _ interface {
   329  	Field() string
   330  	Reason() string
   331  	Key() bool
   332  	Cause() error
   333  	ErrorName() string
   334  } = LoadStatsResponseValidationError{}
   335  

View as plain text