...

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

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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/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 MetricsServiceConfig 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 *MetricsServiceConfig) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on MetricsServiceConfig 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  // MetricsServiceConfigMultiError, or nil if none found.
    49  func (m *MetricsServiceConfig) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *MetricsServiceConfig) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	if m.GetGrpcService() == nil {
    61  		err := MetricsServiceConfigValidationError{
    62  			field:  "GrpcService",
    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.GetGrpcService()).(type) {
    73  		case interface{ ValidateAll() error }:
    74  			if err := v.ValidateAll(); err != nil {
    75  				errors = append(errors, MetricsServiceConfigValidationError{
    76  					field:  "GrpcService",
    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, MetricsServiceConfigValidationError{
    84  					field:  "GrpcService",
    85  					reason: "embedded message failed validation",
    86  					cause:  err,
    87  				})
    88  			}
    89  		}
    90  	} else if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
    91  		if err := v.Validate(); err != nil {
    92  			return MetricsServiceConfigValidationError{
    93  				field:  "GrpcService",
    94  				reason: "embedded message failed validation",
    95  				cause:  err,
    96  			}
    97  		}
    98  	}
    99  
   100  	if len(errors) > 0 {
   101  		return MetricsServiceConfigMultiError(errors)
   102  	}
   103  
   104  	return nil
   105  }
   106  
   107  // MetricsServiceConfigMultiError is an error wrapping multiple validation
   108  // errors returned by MetricsServiceConfig.ValidateAll() if the designated
   109  // constraints aren't met.
   110  type MetricsServiceConfigMultiError []error
   111  
   112  // Error returns a concatenation of all the error messages it wraps.
   113  func (m MetricsServiceConfigMultiError) 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 MetricsServiceConfigMultiError) AllErrors() []error { return m }
   123  
   124  // MetricsServiceConfigValidationError is the validation error returned by
   125  // MetricsServiceConfig.Validate if the designated constraints aren't met.
   126  type MetricsServiceConfigValidationError struct {
   127  	field  string
   128  	reason string
   129  	cause  error
   130  	key    bool
   131  }
   132  
   133  // Field function returns field value.
   134  func (e MetricsServiceConfigValidationError) Field() string { return e.field }
   135  
   136  // Reason function returns reason value.
   137  func (e MetricsServiceConfigValidationError) Reason() string { return e.reason }
   138  
   139  // Cause function returns cause value.
   140  func (e MetricsServiceConfigValidationError) Cause() error { return e.cause }
   141  
   142  // Key function returns key value.
   143  func (e MetricsServiceConfigValidationError) Key() bool { return e.key }
   144  
   145  // ErrorName returns error name.
   146  func (e MetricsServiceConfigValidationError) ErrorName() string {
   147  	return "MetricsServiceConfigValidationError"
   148  }
   149  
   150  // Error satisfies the builtin error interface
   151  func (e MetricsServiceConfigValidationError) 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 %sMetricsServiceConfig.%s: %s%s",
   164  		key,
   165  		e.field,
   166  		e.reason,
   167  		cause)
   168  }
   169  
   170  var _ error = MetricsServiceConfigValidationError{}
   171  
   172  var _ interface {
   173  	Field() string
   174  	Reason() string
   175  	Key() bool
   176  	Cause() error
   177  	ErrorName() string
   178  } = MetricsServiceConfigValidationError{}
   179  

View as plain text