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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/trace/v2/zipkin.proto
     3  
     4  package envoy_config_trace_v2
     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 len(m.GetCollectorCluster()) < 1 {
    45  		return ZipkinConfigValidationError{
    46  			field:  "CollectorCluster",
    47  			reason: "value length must be at least 1 bytes",
    48  		}
    49  	}
    50  
    51  	if len(m.GetCollectorEndpoint()) < 1 {
    52  		return ZipkinConfigValidationError{
    53  			field:  "CollectorEndpoint",
    54  			reason: "value length must be at least 1 bytes",
    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  	return nil
    73  }
    74  
    75  // ZipkinConfigValidationError is the validation error returned by
    76  // ZipkinConfig.Validate if the designated constraints aren't met.
    77  type ZipkinConfigValidationError struct {
    78  	field  string
    79  	reason string
    80  	cause  error
    81  	key    bool
    82  }
    83  
    84  // Field function returns field value.
    85  func (e ZipkinConfigValidationError) Field() string { return e.field }
    86  
    87  // Reason function returns reason value.
    88  func (e ZipkinConfigValidationError) Reason() string { return e.reason }
    89  
    90  // Cause function returns cause value.
    91  func (e ZipkinConfigValidationError) Cause() error { return e.cause }
    92  
    93  // Key function returns key value.
    94  func (e ZipkinConfigValidationError) Key() bool { return e.key }
    95  
    96  // ErrorName returns error name.
    97  func (e ZipkinConfigValidationError) ErrorName() string { return "ZipkinConfigValidationError" }
    98  
    99  // Error satisfies the builtin error interface
   100  func (e ZipkinConfigValidationError) Error() string {
   101  	cause := ""
   102  	if e.cause != nil {
   103  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   104  	}
   105  
   106  	key := ""
   107  	if e.key {
   108  		key = "key for "
   109  	}
   110  
   111  	return fmt.Sprintf(
   112  		"invalid %sZipkinConfig.%s: %s%s",
   113  		key,
   114  		e.field,
   115  		e.reason,
   116  		cause)
   117  }
   118  
   119  var _ error = ZipkinConfigValidationError{}
   120  
   121  var _ interface {
   122  	Field() string
   123  	Reason() string
   124  	Key() bool
   125  	Cause() error
   126  	ErrorName() string
   127  } = ZipkinConfigValidationError{}