...

Source file src/github.com/emissary-ingress/emissary/v3/pkg/api/envoy/admin/v2alpha/memory.pb.validate.go

Documentation: github.com/emissary-ingress/emissary/v3/pkg/api/envoy/admin/v2alpha

     1  // Code generated by protoc-gen-validate. DO NOT EDIT.
     2  // source: envoy/admin/v2alpha/memory.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 Memory with the rules defined in the
    39  // 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 *Memory) Validate() error {
    42  	return m.validate(false)
    43  }
    44  
    45  // ValidateAll checks the field values on Memory with the rules defined in the
    46  // proto definition for this message. If any rules are violated, the result is
    47  // a list of violation errors wrapped in MemoryMultiError, or nil if none found.
    48  func (m *Memory) ValidateAll() error {
    49  	return m.validate(true)
    50  }
    51  
    52  func (m *Memory) validate(all bool) error {
    53  	if m == nil {
    54  		return nil
    55  	}
    56  
    57  	var errors []error
    58  
    59  	// no validation rules for Allocated
    60  
    61  	// no validation rules for HeapSize
    62  
    63  	// no validation rules for PageheapUnmapped
    64  
    65  	// no validation rules for PageheapFree
    66  
    67  	// no validation rules for TotalThreadCache
    68  
    69  	// no validation rules for TotalPhysicalBytes
    70  
    71  	if len(errors) > 0 {
    72  		return MemoryMultiError(errors)
    73  	}
    74  
    75  	return nil
    76  }
    77  
    78  // MemoryMultiError is an error wrapping multiple validation errors returned by
    79  // Memory.ValidateAll() if the designated constraints aren't met.
    80  type MemoryMultiError []error
    81  
    82  // Error returns a concatenation of all the error messages it wraps.
    83  func (m MemoryMultiError) Error() string {
    84  	var msgs []string
    85  	for _, err := range m {
    86  		msgs = append(msgs, err.Error())
    87  	}
    88  	return strings.Join(msgs, "; ")
    89  }
    90  
    91  // AllErrors returns a list of validation violation errors.
    92  func (m MemoryMultiError) AllErrors() []error { return m }
    93  
    94  // MemoryValidationError is the validation error returned by Memory.Validate if
    95  // the designated constraints aren't met.
    96  type MemoryValidationError struct {
    97  	field  string
    98  	reason string
    99  	cause  error
   100  	key    bool
   101  }
   102  
   103  // Field function returns field value.
   104  func (e MemoryValidationError) Field() string { return e.field }
   105  
   106  // Reason function returns reason value.
   107  func (e MemoryValidationError) Reason() string { return e.reason }
   108  
   109  // Cause function returns cause value.
   110  func (e MemoryValidationError) Cause() error { return e.cause }
   111  
   112  // Key function returns key value.
   113  func (e MemoryValidationError) Key() bool { return e.key }
   114  
   115  // ErrorName returns error name.
   116  func (e MemoryValidationError) ErrorName() string { return "MemoryValidationError" }
   117  
   118  // Error satisfies the builtin error interface
   119  func (e MemoryValidationError) Error() string {
   120  	cause := ""
   121  	if e.cause != nil {
   122  		cause = fmt.Sprintf(" | caused by: %v", e.cause)
   123  	}
   124  
   125  	key := ""
   126  	if e.key {
   127  		key = "key for "
   128  	}
   129  
   130  	return fmt.Sprintf(
   131  		"invalid %sMemory.%s: %s%s",
   132  		key,
   133  		e.field,
   134  		e.reason,
   135  		cause)
   136  }
   137  
   138  var _ error = MemoryValidationError{}
   139  
   140  var _ interface {
   141  	Field() string
   142  	Reason() string
   143  	Key() bool
   144  	Cause() error
   145  	ErrorName() string
   146  } = MemoryValidationError{}
   147  

View as plain text