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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/endpoint/v3/endpoint.proto
     3  
     4  package envoy_config_endpoint_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 ClusterLoadAssignment with the rules
    37  // defined in the proto definition for this message. If any rules are
    38  // violated, an error is returned.
    39  func (m *ClusterLoadAssignment) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if utf8.RuneCountInString(m.GetClusterName()) < 1 {
    45  		return ClusterLoadAssignmentValidationError{
    46  			field:  "ClusterName",
    47  			reason: "value length must be at least 1 runes",
    48  		}
    49  	}
    50  
    51  	for idx, item := range m.GetEndpoints() {
    52  		_, _ = idx, item
    53  
    54  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
    55  			if err := v.Validate(); err != nil {
    56  				return ClusterLoadAssignmentValidationError{
    57  					field:  fmt.Sprintf("Endpoints[%v]", idx),
    58  					reason: "embedded message failed validation",
    59  					cause:  err,
    60  				}
    61  			}
    62  		}
    63  
    64  	}
    65  
    66  	for key, val := range m.GetNamedEndpoints() {
    67  		_ = val
    68  
    69  		// no validation rules for NamedEndpoints[key]
    70  
    71  		if v, ok := interface{}(val).(interface{ Validate() error }); ok {
    72  			if err := v.Validate(); err != nil {
    73  				return ClusterLoadAssignmentValidationError{
    74  					field:  fmt.Sprintf("NamedEndpoints[%v]", key),
    75  					reason: "embedded message failed validation",
    76  					cause:  err,
    77  				}
    78  			}
    79  		}
    80  
    81  	}
    82  
    83  	if v, ok := interface{}(m.GetPolicy()).(interface{ Validate() error }); ok {
    84  		if err := v.Validate(); err != nil {
    85  			return ClusterLoadAssignmentValidationError{
    86  				field:  "Policy",
    87  				reason: "embedded message failed validation",
    88  				cause:  err,
    89  			}
    90  		}
    91  	}
    92  
    93  	return nil
    94  }
    95  
    96  // ClusterLoadAssignmentValidationError is the validation error returned by
    97  // ClusterLoadAssignment.Validate if the designated constraints aren't met.
    98  type ClusterLoadAssignmentValidationError struct {
    99  	field  string
   100  	reason string
   101  	cause  error
   102  	key    bool
   103  }
   104  
   105  // Field function returns field value.
   106  func (e ClusterLoadAssignmentValidationError) Field() string { return e.field }
   107  
   108  // Reason function returns reason value.
   109  func (e ClusterLoadAssignmentValidationError) Reason() string { return e.reason }
   110  
   111  // Cause function returns cause value.
   112  func (e ClusterLoadAssignmentValidationError) Cause() error { return e.cause }
   113  
   114  // Key function returns key value.
   115  func (e ClusterLoadAssignmentValidationError) Key() bool { return e.key }
   116  
   117  // ErrorName returns error name.
   118  func (e ClusterLoadAssignmentValidationError) ErrorName() string {
   119  	return "ClusterLoadAssignmentValidationError"
   120  }
   121  
   122  // Error satisfies the builtin error interface
   123  func (e ClusterLoadAssignmentValidationError) Error() string {
   124  	cause := ""
   125  	if e.cause != nil {
   126  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   127  	}
   128  
   129  	key := ""
   130  	if e.key {
   131  		key = "key for "
   132  	}
   133  
   134  	return fmt.Sprintf(
   135  		"invalid %sClusterLoadAssignment.%s: %s%s",
   136  		key,
   137  		e.field,
   138  		e.reason,
   139  		cause)
   140  }
   141  
   142  var _ error = ClusterLoadAssignmentValidationError{}
   143  
   144  var _ interface {
   145  	Field() string
   146  	Reason() string
   147  	Key() bool
   148  	Cause() error
   149  	ErrorName() string
   150  } = ClusterLoadAssignmentValidationError{}
   151  
   152  // Validate checks the field values on ClusterLoadAssignment_Policy with the
   153  // rules defined in the proto definition for this message. If any rules are
   154  // violated, an error is returned.
   155  func (m *ClusterLoadAssignment_Policy) Validate() error {
   156  	if m == nil {
   157  		return nil
   158  	}
   159  
   160  	for idx, item := range m.GetDropOverloads() {
   161  		_, _ = idx, item
   162  
   163  		if v, ok := interface{}(item).(interface{ Validate() error }); ok {
   164  			if err := v.Validate(); err != nil {
   165  				return ClusterLoadAssignment_PolicyValidationError{
   166  					field:  fmt.Sprintf("DropOverloads[%v]", idx),
   167  					reason: "embedded message failed validation",
   168  					cause:  err,
   169  				}
   170  			}
   171  		}
   172  
   173  	}
   174  
   175  	if wrapper := m.GetOverprovisioningFactor(); wrapper != nil {
   176  
   177  		if wrapper.GetValue() <= 0 {
   178  			return ClusterLoadAssignment_PolicyValidationError{
   179  				field:  "OverprovisioningFactor",
   180  				reason: "value must be greater than 0",
   181  			}
   182  		}
   183  
   184  	}
   185  
   186  	if d := m.GetEndpointStaleAfter(); d != nil {
   187  		dur, err := d.AsDuration(), d.CheckValid()
   188  		if err != nil {
   189  			return ClusterLoadAssignment_PolicyValidationError{
   190  				field:  "EndpointStaleAfter",
   191  				reason: "value is not a valid duration",
   192  				cause:  err,
   193  			}
   194  		}
   195  
   196  		gt := time.Duration(0*time.Second + 0*time.Nanosecond)
   197  
   198  		if dur <= gt {
   199  			return ClusterLoadAssignment_PolicyValidationError{
   200  				field:  "EndpointStaleAfter",
   201  				reason: "value must be greater than 0s",
   202  			}
   203  		}
   204  
   205  	}
   206  
   207  	// no validation rules for HiddenEnvoyDeprecatedDisableOverprovisioning
   208  
   209  	return nil
   210  }
   211  
   212  // ClusterLoadAssignment_PolicyValidationError is the validation error returned
   213  // by ClusterLoadAssignment_Policy.Validate if the designated constraints
   214  // aren't met.
   215  type ClusterLoadAssignment_PolicyValidationError struct {
   216  	field  string
   217  	reason string
   218  	cause  error
   219  	key    bool
   220  }
   221  
   222  // Field function returns field value.
   223  func (e ClusterLoadAssignment_PolicyValidationError) Field() string { return e.field }
   224  
   225  // Reason function returns reason value.
   226  func (e ClusterLoadAssignment_PolicyValidationError) Reason() string { return e.reason }
   227  
   228  // Cause function returns cause value.
   229  func (e ClusterLoadAssignment_PolicyValidationError) Cause() error { return e.cause }
   230  
   231  // Key function returns key value.
   232  func (e ClusterLoadAssignment_PolicyValidationError) Key() bool { return e.key }
   233  
   234  // ErrorName returns error name.
   235  func (e ClusterLoadAssignment_PolicyValidationError) ErrorName() string {
   236  	return "ClusterLoadAssignment_PolicyValidationError"
   237  }
   238  
   239  // Error satisfies the builtin error interface
   240  func (e ClusterLoadAssignment_PolicyValidationError) Error() string {
   241  	cause := ""
   242  	if e.cause != nil {
   243  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   244  	}
   245  
   246  	key := ""
   247  	if e.key {
   248  		key = "key for "
   249  	}
   250  
   251  	return fmt.Sprintf(
   252  		"invalid %sClusterLoadAssignment_Policy.%s: %s%s",
   253  		key,
   254  		e.field,
   255  		e.reason,
   256  		cause)
   257  }
   258  
   259  var _ error = ClusterLoadAssignment_PolicyValidationError{}
   260  
   261  var _ interface {
   262  	Field() string
   263  	Reason() string
   264  	Key() bool
   265  	Cause() error
   266  	ErrorName() string
   267  } = ClusterLoadAssignment_PolicyValidationError{}
   268  
   269  // Validate checks the field values on
   270  // ClusterLoadAssignment_Policy_DropOverload with the rules defined in the
   271  // proto definition for this message. If any rules are violated, an error is returned.
   272  func (m *ClusterLoadAssignment_Policy_DropOverload) Validate() error {
   273  	if m == nil {
   274  		return nil
   275  	}
   276  
   277  	if utf8.RuneCountInString(m.GetCategory()) < 1 {
   278  		return ClusterLoadAssignment_Policy_DropOverloadValidationError{
   279  			field:  "Category",
   280  			reason: "value length must be at least 1 runes",
   281  		}
   282  	}
   283  
   284  	if v, ok := interface{}(m.GetDropPercentage()).(interface{ Validate() error }); ok {
   285  		if err := v.Validate(); err != nil {
   286  			return ClusterLoadAssignment_Policy_DropOverloadValidationError{
   287  				field:  "DropPercentage",
   288  				reason: "embedded message failed validation",
   289  				cause:  err,
   290  			}
   291  		}
   292  	}
   293  
   294  	return nil
   295  }
   296  
   297  // ClusterLoadAssignment_Policy_DropOverloadValidationError is the validation
   298  // error returned by ClusterLoadAssignment_Policy_DropOverload.Validate if the
   299  // designated constraints aren't met.
   300  type ClusterLoadAssignment_Policy_DropOverloadValidationError struct {
   301  	field  string
   302  	reason string
   303  	cause  error
   304  	key    bool
   305  }
   306  
   307  // Field function returns field value.
   308  func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Field() string { return e.field }
   309  
   310  // Reason function returns reason value.
   311  func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Reason() string { return e.reason }
   312  
   313  // Cause function returns cause value.
   314  func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Cause() error { return e.cause }
   315  
   316  // Key function returns key value.
   317  func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Key() bool { return e.key }
   318  
   319  // ErrorName returns error name.
   320  func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) ErrorName() string {
   321  	return "ClusterLoadAssignment_Policy_DropOverloadValidationError"
   322  }
   323  
   324  // Error satisfies the builtin error interface
   325  func (e ClusterLoadAssignment_Policy_DropOverloadValidationError) Error() string {
   326  	cause := ""
   327  	if e.cause != nil {
   328  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   329  	}
   330  
   331  	key := ""
   332  	if e.key {
   333  		key = "key for "
   334  	}
   335  
   336  	return fmt.Sprintf(
   337  		"invalid %sClusterLoadAssignment_Policy_DropOverload.%s: %s%s",
   338  		key,
   339  		e.field,
   340  		e.reason,
   341  		cause)
   342  }
   343  
   344  var _ error = ClusterLoadAssignment_Policy_DropOverloadValidationError{}
   345  
   346  var _ interface {
   347  	Field() string
   348  	Reason() string
   349  	Key() bool
   350  	Cause() error
   351  	ErrorName() string
   352  } = ClusterLoadAssignment_Policy_DropOverloadValidationError{}