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

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/cluster/redis/redis_cluster.proto
     3  
     4  package envoy_config_cluster_redis
     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 RedisClusterConfig 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 *RedisClusterConfig) Validate() error {
    40  	if m == nil {
    41  		return nil
    42  	}
    43  
    44  	if d := m.GetClusterRefreshRate(); d != nil {
    45  		dur, err := d.AsDuration(), d.CheckValid()
    46  		if err != nil {
    47  			return RedisClusterConfigValidationError{
    48  				field:  "ClusterRefreshRate",
    49  				reason: "value is not a valid duration",
    50  				cause:  err,
    51  			}
    52  		}
    53  
    54  		gt := time.Duration(0*time.Second + 0*time.Nanosecond)
    55  
    56  		if dur <= gt {
    57  			return RedisClusterConfigValidationError{
    58  				field:  "ClusterRefreshRate",
    59  				reason: "value must be greater than 0s",
    60  			}
    61  		}
    62  
    63  	}
    64  
    65  	if d := m.GetClusterRefreshTimeout(); d != nil {
    66  		dur, err := d.AsDuration(), d.CheckValid()
    67  		if err != nil {
    68  			return RedisClusterConfigValidationError{
    69  				field:  "ClusterRefreshTimeout",
    70  				reason: "value is not a valid duration",
    71  				cause:  err,
    72  			}
    73  		}
    74  
    75  		gt := time.Duration(0*time.Second + 0*time.Nanosecond)
    76  
    77  		if dur <= gt {
    78  			return RedisClusterConfigValidationError{
    79  				field:  "ClusterRefreshTimeout",
    80  				reason: "value must be greater than 0s",
    81  			}
    82  		}
    83  
    84  	}
    85  
    86  	if v, ok := interface{}(m.GetRedirectRefreshInterval()).(interface{ Validate() error }); ok {
    87  		if err := v.Validate(); err != nil {
    88  			return RedisClusterConfigValidationError{
    89  				field:  "RedirectRefreshInterval",
    90  				reason: "embedded message failed validation",
    91  				cause:  err,
    92  			}
    93  		}
    94  	}
    95  
    96  	if v, ok := interface{}(m.GetRedirectRefreshThreshold()).(interface{ Validate() error }); ok {
    97  		if err := v.Validate(); err != nil {
    98  			return RedisClusterConfigValidationError{
    99  				field:  "RedirectRefreshThreshold",
   100  				reason: "embedded message failed validation",
   101  				cause:  err,
   102  			}
   103  		}
   104  	}
   105  
   106  	// no validation rules for FailureRefreshThreshold
   107  
   108  	// no validation rules for HostDegradedRefreshThreshold
   109  
   110  	return nil
   111  }
   112  
   113  // RedisClusterConfigValidationError is the validation error returned by
   114  // RedisClusterConfig.Validate if the designated constraints aren't met.
   115  type RedisClusterConfigValidationError struct {
   116  	field  string
   117  	reason string
   118  	cause  error
   119  	key    bool
   120  }
   121  
   122  // Field function returns field value.
   123  func (e RedisClusterConfigValidationError) Field() string { return e.field }
   124  
   125  // Reason function returns reason value.
   126  func (e RedisClusterConfigValidationError) Reason() string { return e.reason }
   127  
   128  // Cause function returns cause value.
   129  func (e RedisClusterConfigValidationError) Cause() error { return e.cause }
   130  
   131  // Key function returns key value.
   132  func (e RedisClusterConfigValidationError) Key() bool { return e.key }
   133  
   134  // ErrorName returns error name.
   135  func (e RedisClusterConfigValidationError) ErrorName() string {
   136  	return "RedisClusterConfigValidationError"
   137  }
   138  
   139  // Error satisfies the builtin error interface
   140  func (e RedisClusterConfigValidationError) Error() string {
   141  	cause := ""
   142  	if e.cause != nil {
   143  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   144  	}
   145  
   146  	key := ""
   147  	if e.key {
   148  		key = "key for "
   149  	}
   150  
   151  	return fmt.Sprintf(
   152  		"invalid %sRedisClusterConfig.%s: %s%s",
   153  		key,
   154  		e.field,
   155  		e.reason,
   156  		cause)
   157  }
   158  
   159  var _ error = RedisClusterConfigValidationError{}
   160  
   161  var _ interface {
   162  	Field() string
   163  	Reason() string
   164  	Key() bool
   165  	Cause() error
   166  	ErrorName() string
   167  } = RedisClusterConfigValidationError{}