github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/go-control-plane/envoy/config/trace/v3/zipkin.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/trace/v3/zipkin.proto
     3  
     4  package envoy_config_trace_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  	"google.golang.org/protobuf/types/known/anypb"
    19  )
    20  
    21  // ensure the imports are used
    22  var (
    23  	_ = bytes.MinRead
    24  	_ = errors.New("")
    25  	_ = fmt.Print
    26  	_ = utf8.UTFMax
    27  	_ = (*regexp.Regexp)(nil)
    28  	_ = (*strings.Reader)(nil)
    29  	_ = net.IPv4len
    30  	_ = time.Duration(0)
    31  	_ = (*url.URL)(nil)
    32  	_ = (*mail.Address)(nil)
    33  	_ = anypb.Any{}
    34  )
    35  
    36  // Validate checks the field values on ZipkinConfig with the rules defined in
    37  // the proto definition for this message. If any rules are violated, an error
    38  // is returned.
    39  func (m *ZipkinConfig) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if utf8.RuneCountInString(m.GetCollectorCluster()) < 1 {
    45  		return ZipkinConfigValidationError{
    46  			field:  "CollectorCluster",
    47  			reason: "value length must be at least 1 runes",
    48  		}
    49  	}
    50  
    51  	if utf8.RuneCountInString(m.GetCollectorEndpoint()) < 1 {
    52  		return ZipkinConfigValidationError{
    53  			field:  "CollectorEndpoint",
    54  			reason: "value length must be at least 1 runes",
    55  		}
    56  	}
    57  
    58  	// no validation rules for TraceId_128Bit
    59  
    60  	if v, ok := interface{}(m.GetSharedSpanContext()).(interface{ Validate() error }); ok {
    61  		if err := v.Validate(); err != nil {
    62  			return ZipkinConfigValidationError{
    63  				field:  "SharedSpanContext",
    64  				reason: "embedded message failed validation",
    65  				cause:  err,
    66  			}
    67  		}
    68  	}
    69  
    70  	// no validation rules for CollectorEndpointVersion
    71  
    72  	// no validation rules for CollectorHostname
    73  
    74  	return nil
    75  }
    76  
    77  // ZipkinConfigValidationError is the validation error returned by
    78  // ZipkinConfig.Validate if the designated constraints aren't met.
    79  type ZipkinConfigValidationError struct {
    80  	field  string
    81  	reason string
    82  	cause  error
    83  	key    bool
    84  }
    85  
    86  // Field function returns field value.
    87  func (e ZipkinConfigValidationError) Field() string { return e.field }
    88  
    89  // Reason function returns reason value.
    90  func (e ZipkinConfigValidationError) Reason() string { return e.reason }
    91  
    92  // Cause function returns cause value.
    93  func (e ZipkinConfigValidationError) Cause() error { return e.cause }
    94  
    95  // Key function returns key value.
    96  func (e ZipkinConfigValidationError) Key() bool { return e.key }
    97  
    98  // ErrorName returns error name.
    99  func (e ZipkinConfigValidationError) ErrorName() string { return "ZipkinConfigValidationError" }
   100  
   101  // Error satisfies the builtin error interface
   102  func (e ZipkinConfigValidationError) Error() string {
   103  	cause := ""
   104  	if e.cause != nil {
   105  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   106  	}
   107  
   108  	key := ""
   109  	if e.key {
   110  		key = "key for "
   111  	}
   112  
   113  	return fmt.Sprintf(
   114  		"invalid %sZipkinConfig.%s: %s%s",
   115  		key,
   116  		e.field,
   117  		e.reason,
   118  		cause)
   119  }
   120  
   121  var _ error = ZipkinConfigValidationError{}
   122  
   123  var _ interface {
   124  	Field() string
   125  	Reason() string
   126  	Key() bool
   127  	Cause() error
   128  	ErrorName() string
   129  } = ZipkinConfigValidationError{}