...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/cluster/aggregate/v2alpha/cluster.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/config/cluster/aggregate/v2alpha

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/config/cluster/aggregate/v2alpha/cluster.proto
     3  
     4  package v2alpha
     5  
     6  import (
     7  	"bytes"
     8  	"errors"
     9  	"fmt"
    10  	"net"
    11  	"net/mail"
    12  	"net/url"
    13  	"regexp"
    14  	"sort"
    15  	"strings"
    16  	"time"
    17  	"unicode/utf8"
    18  
    19  	"google.golang.org/protobuf/types/known/anypb"
    20  )
    21  
    22  // ensure the imports are used
    23  var (
    24  	_ = bytes.MinRead
    25  	_ = errors.New("")
    26  	_ = fmt.Print
    27  	_ = utf8.UTFMax
    28  	_ = (*regexp.Regexp)(nil)
    29  	_ = (*strings.Reader)(nil)
    30  	_ = net.IPv4len
    31  	_ = time.Duration(0)
    32  	_ = (*url.URL)(nil)
    33  	_ = (*mail.Address)(nil)
    34  	_ = anypb.Any{}
    35  	_ = sort.Sort
    36  )
    37  
    38  // Validate checks the field values on ClusterConfig with the rules defined in
    39  // the proto definition for this message. If any rules are violated, the first
    40  // error encountered is returned, or nil if there are no violations.
    41  func (m *ClusterConfig) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on ClusterConfig with the rules defined
    46  // in the proto definition for this message. If any rules are violated, the
    47  // result is a list of violation errors wrapped in ClusterConfigMultiError, or
    48  // nil if none found.
    49  func (m *ClusterConfig) ValidateAll() error {
    50  	return m.validate(true)
    51  }
    52  
    53  func (m *ClusterConfig) validate(all bool) error {
    54  	if m == nil {
    55  		return nil
    56  	}
    57  
    58  	var errors []error
    59  
    60  	if len(m.GetClusters()) < 1 {
    61  		err := ClusterConfigValidationError{
    62  			field:  "Clusters",
    63  			reason: "value must contain at least 1 item(s)",
    64  		}
    65  		if !all {
    66  			return err
    67  		}
    68  		errors = append(errors, err)
    69  	}
    70  
    71  	if len(errors) > 0 {
    72  		return ClusterConfigMultiError(errors)
    73  	}
    74  
    75  	return nil
    76  }
    77  
    78  // ClusterConfigMultiError is an error wrapping multiple validation errors
    79  // returned by ClusterConfig.ValidateAll() if the designated constraints
    80  // aren't met.
    81  type ClusterConfigMultiError []error
    82  
    83  // Error returns a concatenation of all the error messages it wraps.
    84  func (m ClusterConfigMultiError) Error() string {
    85  	var msgs []string
    86  	for _, err := range m {
    87  		msgs = append(msgs, err.Error())
    88  	}
    89  	return strings.Join(msgs, "; ")
    90  }
    91  
    92  // AllErrors returns a list of validation violation errors.
    93  func (m ClusterConfigMultiError) AllErrors() []error { return m }
    94  
    95  // ClusterConfigValidationError is the validation error returned by
    96  // ClusterConfig.Validate if the designated constraints aren't met.
    97  type ClusterConfigValidationError struct {
    98  	field  string
    99  	reason string
   100  	cause  error
   101  	key    bool
   102  }
   103  
   104  // Field function returns field value.
   105  func (e ClusterConfigValidationError) Field() string { return e.field }
   106  
   107  // Reason function returns reason value.
   108  func (e ClusterConfigValidationError) Reason() string { return e.reason }
   109  
   110  // Cause function returns cause value.
   111  func (e ClusterConfigValidationError) Cause() error { return e.cause }
   112  
   113  // Key function returns key value.
   114  func (e ClusterConfigValidationError) Key() bool { return e.key }
   115  
   116  // ErrorName returns error name.
   117  func (e ClusterConfigValidationError) ErrorName() string { return "ClusterConfigValidationError" }
   118  
   119  // Error satisfies the builtin error interface
   120  func (e ClusterConfigValidationError) Error() string {
   121  	cause := ""
   122  	if e.cause != nil {
   123  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   124  	}
   125  
   126  	key := ""
   127  	if e.key {
   128  		key = "key for "
   129  	}
   130  
   131  	return fmt.Sprintf(
   132  		"invalid %sClusterConfig.%s: %s%s",
   133  		key,
   134  		e.field,
   135  		e.reason,
   136  		cause)
   137  }
   138  
   139  var _ error = ClusterConfigValidationError{}
   140  
   141  var _ interface {
   142  	Field() string
   143  	Reason() string
   144  	Key() bool
   145  	Cause() error
   146  	ErrorName() string
   147  } = ClusterConfigValidationError{}
   148  

View as plain text