...

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

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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/service/metrics/v2/metrics_service.proto
     3  
     4  package metricsv2
     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 StreamMetricsResponse 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 *StreamMetricsResponse) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on StreamMetricsResponse 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  // StreamMetricsResponseMultiError, or nil if none found.
    49  func (m *StreamMetricsResponse) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *StreamMetricsResponse) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	if len(errors) > 0 {
    61  		return StreamMetricsResponseMultiError(errors)
    62  	}
    63  
    64  	return nil
    65  }
    66  
    67  // StreamMetricsResponseMultiError is an error wrapping multiple validation
    68  // errors returned by StreamMetricsResponse.ValidateAll() if the designated
    69  // constraints aren't met.
    70  type StreamMetricsResponseMultiError []error
    71  
    72  // Error returns a concatenation of all the error messages it wraps.
    73  func (m StreamMetricsResponseMultiError) Error() string {
    74  	var msgs []string
    75  	for _, err := range m {
    76  		msgs = append(msgs, err.Error())
    77  	}
    78  	return strings.Join(msgs, "; ")
    79  }
    80  
    81  // AllErrors returns a list of validation violation errors.
    82  func (m StreamMetricsResponseMultiError) AllErrors() []error { return m }
    83  
    84  // StreamMetricsResponseValidationError is the validation error returned by
    85  // StreamMetricsResponse.Validate if the designated constraints aren't met.
    86  type StreamMetricsResponseValidationError struct {
    87  	field  string
    88  	reason string
    89  	cause  error
    90  	key    bool
    91  }
    92  
    93  // Field function returns field value.
    94  func (e StreamMetricsResponseValidationError) Field() string { return e.field }
    95  
    96  // Reason function returns reason value.
    97  func (e StreamMetricsResponseValidationError) Reason() string { return e.reason }
    98  
    99  // Cause function returns cause value.
   100  func (e StreamMetricsResponseValidationError) Cause() error { return e.cause }
   101  
   102  // Key function returns key value.
   103  func (e StreamMetricsResponseValidationError) Key() bool { return e.key }
   104  
   105  // ErrorName returns error name.
   106  func (e StreamMetricsResponseValidationError) ErrorName() string {
   107  	return "StreamMetricsResponseValidationError"
   108  }
   109  
   110  // Error satisfies the builtin error interface
   111  func (e StreamMetricsResponseValidationError) Error() string {
   112  	cause := ""
   113  	if e.cause != nil {
   114  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   115  	}
   116  
   117  	key := ""
   118  	if e.key {
   119  		key = "key for "
   120  	}
   121  
   122  	return fmt.Sprintf(
   123  		"invalid %sStreamMetricsResponse.%s: %s%s",
   124  		key,
   125  		e.field,
   126  		e.reason,
   127  		cause)
   128  }
   129  
   130  var _ error = StreamMetricsResponseValidationError{}
   131  
   132  var _ interface {
   133  	Field() string
   134  	Reason() string
   135  	Key() bool
   136  	Cause() error
   137  	ErrorName() string
   138  } = StreamMetricsResponseValidationError{}
   139  
   140  // Validate checks the field values on StreamMetricsMessage with the rules
   141  // defined in the proto definition for this message. If any rules are
   142  // violated, the first error encountered is returned, or nil if there are no violations.
   143  func (m *StreamMetricsMessage) Validate() error {
   144  	return m.validate(false)
   145  }
   146  
   147  // ValidateAll checks the field values on StreamMetricsMessage with the rules
   148  // defined in the proto definition for this message. If any rules are
   149  // violated, the result is a list of violation errors wrapped in
   150  // StreamMetricsMessageMultiError, or nil if none found.
   151  func (m *StreamMetricsMessage) ValidateAll() error {
   152  	return m.validate(true)
   153  }
   154  
   155  func (m *StreamMetricsMessage) validate(all bool) error {
   156  	if m == nil {
   157  		return nil
   158  	}
   159  
   160  	var errors []error
   161  
   162  	if all {
   163  		switch v := interface{}(m.GetIdentifier()).(type) {
   164  		case interface{ ValidateAll() error }:
   165  			if err := v.ValidateAll(); err != nil {
   166  				errors = append(errors, StreamMetricsMessageValidationError{
   167  					field:  "Identifier",
   168  					reason: "embedded message failed validation",
   169  					cause:  err,
   170  				})
   171  			}
   172  		case interface{ Validate() error }:
   173  			if err := v.Validate(); err != nil {
   174  				errors = append(errors, StreamMetricsMessageValidationError{
   175  					field:  "Identifier",
   176  					reason: "embedded message failed validation",
   177  					cause:  err,
   178  				})
   179  			}
   180  		}
   181  	} else if v, ok := interface{}(m.GetIdentifier()).(interface{ Validate() error }); ok {
   182  		if err := v.Validate(); err != nil {
   183  			return StreamMetricsMessageValidationError{
   184  				field:  "Identifier",
   185  				reason: "embedded message failed validation",
   186  				cause:  err,
   187  			}
   188  		}
   189  	}
   190  
   191  	for idx, item := range m.GetEnvoyMetrics() {
   192  		_, _ = idx, item
   193  
   194  		if all {
   195  			switch v := interface{}(item).(type) {
   196  			case interface{ ValidateAll() error }:
   197  				if err := v.ValidateAll(); err != nil {
   198  					errors = append(errors, StreamMetricsMessageValidationError{
   199  						field:  fmt.Sprintf("EnvoyMetrics[%v]", idx),
   200  						reason: "embedded message failed validation",
   201  						cause:  err,
   202  					})
   203  				}
   204  			case interface{ Validate() error }:
   205  				if err := v.Validate(); err != nil {
   206  					errors = append(errors, StreamMetricsMessageValidationError{
   207  						field:  fmt.Sprintf("EnvoyMetrics[%v]", idx),
   208  						reason: "embedded message failed validation",
   209  						cause:  err,
   210  					})
   211  				}
   212  			}
   213  		} else if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   214  			if err := v.Validate(); err != nil {
   215  				return StreamMetricsMessageValidationError{
   216  					field:  fmt.Sprintf("EnvoyMetrics[%v]", idx),
   217  					reason: "embedded message failed validation",
   218  					cause:  err,
   219  				}
   220  			}
   221  		}
   222  
   223  	}
   224  
   225  	if len(errors) > 0 {
   226  		return StreamMetricsMessageMultiError(errors)
   227  	}
   228  
   229  	return nil
   230  }
   231  
   232  // StreamMetricsMessageMultiError is an error wrapping multiple validation
   233  // errors returned by StreamMetricsMessage.ValidateAll() if the designated
   234  // constraints aren't met.
   235  type StreamMetricsMessageMultiError []error
   236  
   237  // Error returns a concatenation of all the error messages it wraps.
   238  func (m StreamMetricsMessageMultiError) Error() string {
   239  	var msgs []string
   240  	for _, err := range m {
   241  		msgs = append(msgs, err.Error())
   242  	}
   243  	return strings.Join(msgs, "; ")
   244  }
   245  
   246  // AllErrors returns a list of validation violation errors.
   247  func (m StreamMetricsMessageMultiError) AllErrors() []error { return m }
   248  
   249  // StreamMetricsMessageValidationError is the validation error returned by
   250  // StreamMetricsMessage.Validate if the designated constraints aren't met.
   251  type StreamMetricsMessageValidationError struct {
   252  	field  string
   253  	reason string
   254  	cause  error
   255  	key    bool
   256  }
   257  
   258  // Field function returns field value.
   259  func (e StreamMetricsMessageValidationError) Field() string { return e.field }
   260  
   261  // Reason function returns reason value.
   262  func (e StreamMetricsMessageValidationError) Reason() string { return e.reason }
   263  
   264  // Cause function returns cause value.
   265  func (e StreamMetricsMessageValidationError) Cause() error { return e.cause }
   266  
   267  // Key function returns key value.
   268  func (e StreamMetricsMessageValidationError) Key() bool { return e.key }
   269  
   270  // ErrorName returns error name.
   271  func (e StreamMetricsMessageValidationError) ErrorName() string {
   272  	return "StreamMetricsMessageValidationError"
   273  }
   274  
   275  // Error satisfies the builtin error interface
   276  func (e StreamMetricsMessageValidationError) Error() string {
   277  	cause := ""
   278  	if e.cause != nil {
   279  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   280  	}
   281  
   282  	key := ""
   283  	if e.key {
   284  		key = "key for "
   285  	}
   286  
   287  	return fmt.Sprintf(
   288  		"invalid %sStreamMetricsMessage.%s: %s%s",
   289  		key,
   290  		e.field,
   291  		e.reason,
   292  		cause)
   293  }
   294  
   295  var _ error = StreamMetricsMessageValidationError{}
   296  
   297  var _ interface {
   298  	Field() string
   299  	Reason() string
   300  	Key() bool
   301  	Cause() error
   302  	ErrorName() string
   303  } = StreamMetricsMessageValidationError{}
   304  
   305  // Validate checks the field values on StreamMetricsMessage_Identifier with the
   306  // rules defined in the proto definition for this message. If any rules are
   307  // violated, the first error encountered is returned, or nil if there are no violations.
   308  func (m *StreamMetricsMessage_Identifier) Validate() error {
   309  	return m.validate(false)
   310  }
   311  
   312  // ValidateAll checks the field values on StreamMetricsMessage_Identifier with
   313  // the rules defined in the proto definition for this message. If any rules
   314  // are violated, the result is a list of violation errors wrapped in
   315  // StreamMetricsMessage_IdentifierMultiError, or nil if none found.
   316  func (m *StreamMetricsMessage_Identifier) ValidateAll() error {
   317  	return m.validate(true)
   318  }
   319  
   320  func (m *StreamMetricsMessage_Identifier) validate(all bool) error {
   321  	if m == nil {
   322  		return nil
   323  	}
   324  
   325  	var errors []error
   326  
   327  	if m.GetNode() == nil {
   328  		err := StreamMetricsMessage_IdentifierValidationError{
   329  			field:  "Node",
   330  			reason: "value is required",
   331  		}
   332  		if !all {
   333  			return err
   334  		}
   335  		errors = append(errors, err)
   336  	}
   337  
   338  	if all {
   339  		switch v := interface{}(m.GetNode()).(type) {
   340  		case interface{ ValidateAll() error }:
   341  			if err := v.ValidateAll(); err != nil {
   342  				errors = append(errors, StreamMetricsMessage_IdentifierValidationError{
   343  					field:  "Node",
   344  					reason: "embedded message failed validation",
   345  					cause:  err,
   346  				})
   347  			}
   348  		case interface{ Validate() error }:
   349  			if err := v.Validate(); err != nil {
   350  				errors = append(errors, StreamMetricsMessage_IdentifierValidationError{
   351  					field:  "Node",
   352  					reason: "embedded message failed validation",
   353  					cause:  err,
   354  				})
   355  			}
   356  		}
   357  	} else if v, ok := interface{}(m.GetNode()).(interface{ Validate() error }); ok {
   358  		if err := v.Validate(); err != nil {
   359  			return StreamMetricsMessage_IdentifierValidationError{
   360  				field:  "Node",
   361  				reason: "embedded message failed validation",
   362  				cause:  err,
   363  			}
   364  		}
   365  	}
   366  
   367  	if len(errors) > 0 {
   368  		return StreamMetricsMessage_IdentifierMultiError(errors)
   369  	}
   370  
   371  	return nil
   372  }
   373  
   374  // StreamMetricsMessage_IdentifierMultiError is an error wrapping multiple
   375  // validation errors returned by StreamMetricsMessage_Identifier.ValidateAll()
   376  // if the designated constraints aren't met.
   377  type StreamMetricsMessage_IdentifierMultiError []error
   378  
   379  // Error returns a concatenation of all the error messages it wraps.
   380  func (m StreamMetricsMessage_IdentifierMultiError) Error() string {
   381  	var msgs []string
   382  	for _, err := range m {
   383  		msgs = append(msgs, err.Error())
   384  	}
   385  	return strings.Join(msgs, "; ")
   386  }
   387  
   388  // AllErrors returns a list of validation violation errors.
   389  func (m StreamMetricsMessage_IdentifierMultiError) AllErrors() []error { return m }
   390  
   391  // StreamMetricsMessage_IdentifierValidationError is the validation error
   392  // returned by StreamMetricsMessage_Identifier.Validate if the designated
   393  // constraints aren't met.
   394  type StreamMetricsMessage_IdentifierValidationError struct {
   395  	field  string
   396  	reason string
   397  	cause  error
   398  	key    bool
   399  }
   400  
   401  // Field function returns field value.
   402  func (e StreamMetricsMessage_IdentifierValidationError) Field() string { return e.field }
   403  
   404  // Reason function returns reason value.
   405  func (e StreamMetricsMessage_IdentifierValidationError) Reason() string { return e.reason }
   406  
   407  // Cause function returns cause value.
   408  func (e StreamMetricsMessage_IdentifierValidationError) Cause() error { return e.cause }
   409  
   410  // Key function returns key value.
   411  func (e StreamMetricsMessage_IdentifierValidationError) Key() bool { return e.key }
   412  
   413  // ErrorName returns error name.
   414  func (e StreamMetricsMessage_IdentifierValidationError) ErrorName() string {
   415  	return "StreamMetricsMessage_IdentifierValidationError"
   416  }
   417  
   418  // Error satisfies the builtin error interface
   419  func (e StreamMetricsMessage_IdentifierValidationError) Error() string {
   420  	cause := ""
   421  	if e.cause != nil {
   422  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   423  	}
   424  
   425  	key := ""
   426  	if e.key {
   427  		key = "key for "
   428  	}
   429  
   430  	return fmt.Sprintf(
   431  		"invalid %sStreamMetricsMessage_Identifier.%s: %s%s",
   432  		key,
   433  		e.field,
   434  		e.reason,
   435  		cause)
   436  }
   437  
   438  var _ error = StreamMetricsMessage_IdentifierValidationError{}
   439  
   440  var _ interface {
   441  	Field() string
   442  	Reason() string
   443  	Key() bool
   444  	Cause() error
   445  	ErrorName() string
   446  } = StreamMetricsMessage_IdentifierValidationError{}
   447  

View as plain text