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