...

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

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

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

View as plain text