...

Source file src/github.com/datawire/ambassador/v2/pkg/api/envoy/config/metrics/v3/metrics_service.pb.validate.go

Documentation: github.com/datawire/ambassador/v2/pkg/api/envoy/config/metrics/v3

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/metrics/v3/metrics_service.proto
     3  
     4  package envoy_config_metrics_v3
     5  
     6  import (
     7  	"bytes"
     8  	"errors"
     9  	"fmt"
    10  	"net"
    11  	"net/mail"
    12  	"net/url"
    13  	"regexp"
    14  	"strings"
    15  	"time"
    16  	"unicode/utf8"
    17  
    18  	"github.com/golang/protobuf/ptypes"
    19  
    20  	v3 "github.com/datawire/ambassador/v2/pkg/api/envoy/config/core/v3"
    21  )
    22  
    23  // ensure the imports are used
    24  var (
    25  	_ = bytes.MinRead
    26  	_ = errors.New("")
    27  	_ = fmt.Print
    28  	_ = utf8.UTFMax
    29  	_ = (*regexp.Regexp)(nil)
    30  	_ = (*strings.Reader)(nil)
    31  	_ = net.IPv4len
    32  	_ = time.Duration(0)
    33  	_ = (*url.URL)(nil)
    34  	_ = (*mail.Address)(nil)
    35  	_ = ptypes.DynamicAny{}
    36  
    37  	_ = v3.ApiVersion(0)
    38  )
    39  
    40  // Validate checks the field values on MetricsServiceConfig with the rules
    41  // defined in the proto definition for this message. If any rules are
    42  // violated, an error is returned.
    43  func (m *MetricsServiceConfig) Validate() error {
    44  	if m == nil {
    45  		return nil
    46  	}
    47  
    48  	if m.GetGrpcService() == nil {
    49  		return MetricsServiceConfigValidationError{
    50  			field:  "GrpcService",
    51  			reason: "value is required",
    52  		}
    53  	}
    54  
    55  	if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
    56  		if err := v.Validate(); err != nil {
    57  			return MetricsServiceConfigValidationError{
    58  				field:  "GrpcService",
    59  				reason: "embedded message failed validation",
    60  				cause:  err,
    61  			}
    62  		}
    63  	}
    64  
    65  	if _, ok := v3.ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
    66  		return MetricsServiceConfigValidationError{
    67  			field:  "TransportApiVersion",
    68  			reason: "value must be one of the defined enum values",
    69  		}
    70  	}
    71  
    72  	if v, ok := interface{}(m.GetReportCountersAsDeltas()).(interface{ Validate() error }); ok {
    73  		if err := v.Validate(); err != nil {
    74  			return MetricsServiceConfigValidationError{
    75  				field:  "ReportCountersAsDeltas",
    76  				reason: "embedded message failed validation",
    77  				cause:  err,
    78  			}
    79  		}
    80  	}
    81  
    82  	return nil
    83  }
    84  
    85  // MetricsServiceConfigValidationError is the validation error returned by
    86  // MetricsServiceConfig.Validate if the designated constraints aren't met.
    87  type MetricsServiceConfigValidationError struct {
    88  	field  string
    89  	reason string
    90  	cause  error
    91  	key    bool
    92  }
    93  
    94  // Field function returns field value.
    95  func (e MetricsServiceConfigValidationError) Field() string { return e.field }
    96  
    97  // Reason function returns reason value.
    98  func (e MetricsServiceConfigValidationError) Reason() string { return e.reason }
    99  
   100  // Cause function returns cause value.
   101  func (e MetricsServiceConfigValidationError) Cause() error { return e.cause }
   102  
   103  // Key function returns key value.
   104  func (e MetricsServiceConfigValidationError) Key() bool { return e.key }
   105  
   106  // ErrorName returns error name.
   107  func (e MetricsServiceConfigValidationError) ErrorName() string {
   108  	return "MetricsServiceConfigValidationError"
   109  }
   110  
   111  // Error satisfies the builtin error interface
   112  func (e MetricsServiceConfigValidationError) Error() string {
   113  	cause := ""
   114  	if e.cause != nil {
   115  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   116  	}
   117  
   118  	key := ""
   119  	if e.key {
   120  		key = "key for "
   121  	}
   122  
   123  	return fmt.Sprintf(
   124  		"invalid %sMetricsServiceConfig.%s: %s%s",
   125  		key,
   126  		e.field,
   127  		e.reason,
   128  		cause)
   129  }
   130  
   131  var _ error = MetricsServiceConfigValidationError{}
   132  
   133  var _ interface {
   134  	Field() string
   135  	Reason() string
   136  	Key() bool
   137  	Cause() error
   138  	ErrorName() string
   139  } = MetricsServiceConfigValidationError{}
   140  

View as plain text