gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/go-control-plane/envoy/config/trace/v2alpha/xray.pb.validate.go (about)

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/trace/v2alpha/xray.proto
     3  
     4  package envoy_config_trace_v2alpha
     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 XRayConfig with the rules defined in the
    37  // proto definition for this message. If any rules are violated, an error is returned.
    38  func (m *XRayConfig) Validate() error {
    39  	if m == nil {
    40  		return nil
    41  	}
    42  
    43  	if v, ok := interface{}(m.GetDaemonEndpoint()).(interface{ Validate() error }); ok {
    44  		if err := v.Validate(); err != nil {
    45  			return XRayConfigValidationError{
    46  				field:  "DaemonEndpoint",
    47  				reason: "embedded message failed validation",
    48  				cause:  err,
    49  			}
    50  		}
    51  	}
    52  
    53  	if utf8.RuneCountInString(m.GetSegmentName()) < 1 {
    54  		return XRayConfigValidationError{
    55  			field:  "SegmentName",
    56  			reason: "value length must be at least 1 runes",
    57  		}
    58  	}
    59  
    60  	if v, ok := interface{}(m.GetSamplingRuleManifest()).(interface{ Validate() error }); ok {
    61  		if err := v.Validate(); err != nil {
    62  			return XRayConfigValidationError{
    63  				field:  "SamplingRuleManifest",
    64  				reason: "embedded message failed validation",
    65  				cause:  err,
    66  			}
    67  		}
    68  	}
    69  
    70  	return nil
    71  }
    72  
    73  // XRayConfigValidationError is the validation error returned by
    74  // XRayConfig.Validate if the designated constraints aren't met.
    75  type XRayConfigValidationError struct {
    76  	field  string
    77  	reason string
    78  	cause  error
    79  	key    bool
    80  }
    81  
    82  // Field function returns field value.
    83  func (e XRayConfigValidationError) Field() string { return e.field }
    84  
    85  // Reason function returns reason value.
    86  func (e XRayConfigValidationError) Reason() string { return e.reason }
    87  
    88  // Cause function returns cause value.
    89  func (e XRayConfigValidationError) Cause() error { return e.cause }
    90  
    91  // Key function returns key value.
    92  func (e XRayConfigValidationError) Key() bool { return e.key }
    93  
    94  // ErrorName returns error name.
    95  func (e XRayConfigValidationError) ErrorName() string { return "XRayConfigValidationError" }
    96  
    97  // Error satisfies the builtin error interface
    98  func (e XRayConfigValidationError) Error() string {
    99  	cause := ""
   100  	if e.cause != nil {
   101  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   102  	}
   103  
   104  	key := ""
   105  	if e.key {
   106  		key = "key for "
   107  	}
   108  
   109  	return fmt.Sprintf(
   110  		"invalid %sXRayConfig.%s: %s%s",
   111  		key,
   112  		e.field,
   113  		e.reason,
   114  		cause)
   115  }
   116  
   117  var _ error = XRayConfigValidationError{}
   118  
   119  var _ interface {
   120  	Field() string
   121  	Reason() string
   122  	Key() bool
   123  	Cause() error
   124  	ErrorName() string
   125  } = XRayConfigValidationError{}