| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/config/core/v3/http_uri.proto |
| 4 |
|
| 5 |
package corev3 |
| 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 HttpUri with the rules defined in the |
| 40 |
// proto definition for this message. If any rules are violated, the first |
| 41 |
// error encountered is returned, or nil if there are no violations. |
| 42 |
func (m *HttpUri) Validate() error { |
| 43 |
return m.validate(false) |
| 44 |
} |
| 45 |
|
| 46 |
// ValidateAll checks the field values on HttpUri with the rules defined in the |
| 47 |
// proto definition for this message. If any rules are violated, the result is |
| 48 |
// a list of violation errors wrapped in HttpUriMultiError, or nil if none found. |
| 49 |
func (m *HttpUri) ValidateAll() error { |
| 50 |
return m.validate(true) |
| 51 |
} |
| 52 |
|
| 53 |
func (m *HttpUri) validate(all bool) error { |
| 54 |
if m == nil { |
| 55 |
return nil |
| 56 |
} |
| 57 |
|
| 58 |
var errors []error |
| 59 |
|
| 60 |
if utf8.RuneCountInString(m.GetUri()) < 1 { |
| 61 |
err := HttpUriValidationError{ |
| 62 |
field: "Uri", |
| 63 |
reason: "value length must be at least 1 runes", |
| 64 |
} |
| 65 |
if !all { |
| 66 |
return err |
| 67 |
} |
| 68 |
errors = append(errors, err) |
| 69 |
} |
| 70 |
|
| 71 |
if m.GetTimeout() == nil { |
| 72 |
err := HttpUriValidationError{ |
| 73 |
field: "Timeout", |
| 74 |
reason: "value is required", |
| 75 |
} |
| 76 |
if !all { |
| 77 |
return err |
| 78 |
} |
| 79 |
errors = append(errors, err) |
| 80 |
} |
| 81 |
|
| 82 |
if d := m.GetTimeout(); d != nil { |
| 83 |
dur, err := d.AsDuration(), d.CheckValid() |
| 84 |
if err != nil { |
| 85 |
err = HttpUriValidationError{ |
| 86 |
field: "Timeout", |
| 87 |
reason: "value is not a valid duration", |
| 88 |
cause: err, |
| 89 |
} |
| 90 |
if !all { |
| 91 |
return err |
| 92 |
} |
| 93 |
errors = append(errors, err) |
| 94 |
} else { |
| 95 |
|
| 96 |
lt := time.Duration(4294967296*time.Second + 0*time.Nanosecond) |
| 97 |
gte := time.Duration(0*time.Second + 0*time.Nanosecond) |
| 98 |
|
| 99 |
if dur < gte || dur >= lt { |
| 100 |
err := HttpUriValidationError{ |
| 101 |
field: "Timeout", |
| 102 |
reason: "value must be inside range [0s, 1193046h28m16s)", |
| 103 |
} |
| 104 |
if !all { |
| 105 |
return err |
| 106 |
} |
| 107 |
errors = append(errors, err) |
| 108 |
} |
| 109 |
|
| 110 |
} |
| 111 |
} |
| 112 |
|
| 113 |
oneofHttpUpstreamTypePresent := false |
| 114 |
switch v := m.HttpUpstreamType.(type) { |
| 115 |
case *HttpUri_Cluster: |
| 116 |
if v == nil { |
| 117 |
err := HttpUriValidationError{ |
| 118 |
field: "HttpUpstreamType", |
| 119 |
reason: "oneof value cannot be a typed-nil", |
| 120 |
} |
| 121 |
if !all { |
| 122 |
return err |
| 123 |
} |
| 124 |
errors = append(errors, err) |
| 125 |
} |
| 126 |
oneofHttpUpstreamTypePresent = true |
| 127 |
|
| 128 |
if utf8.RuneCountInString(m.GetCluster()) < 1 { |
| 129 |
err := HttpUriValidationError{ |
| 130 |
field: "Cluster", |
| 131 |
reason: "value length must be at least 1 runes", |
| 132 |
} |
| 133 |
if !all { |
| 134 |
return err |
| 135 |
} |
| 136 |
errors = append(errors, err) |
| 137 |
} |
| 138 |
|
| 139 |
default: |
| 140 |
_ = v // ensures v is used |
| 141 |
} |
| 142 |
if !oneofHttpUpstreamTypePresent { |
| 143 |
err := HttpUriValidationError{ |
| 144 |
field: "HttpUpstreamType", |
| 145 |
reason: "value is required", |
| 146 |
} |
| 147 |
if !all { |
| 148 |
return err |
| 149 |
} |
| 150 |
errors = append(errors, err) |
| 151 |
} |
| 152 |
|
| 153 |
if len(errors) > 0 { |
| 154 |
return HttpUriMultiError(errors) |
| 155 |
} |
| 156 |
|
| 157 |
return nil |
| 158 |
} |
| 159 |
|
| 160 |
// HttpUriMultiError is an error wrapping multiple validation errors returned |
| 161 |
// by HttpUri.ValidateAll() if the designated constraints aren't met. |
| 162 |
type HttpUriMultiError []error |
| 163 |
|
| 164 |
// Error returns a concatenation of all the error messages it wraps. |
| 165 |
func (m HttpUriMultiError) Error() string { |
| 166 |
var msgs []string |
| 167 |
for _, err := range m { |
| 168 |
msgs = append(msgs, err.Error()) |
| 169 |
} |
| 170 |
return strings.Join(msgs, "; ") |
| 171 |
} |
| 172 |
|
| 173 |
// AllErrors returns a list of validation violation errors. |
| 174 |
func (m HttpUriMultiError) AllErrors() []error { return m } |
| 175 |
|
| 176 |
// HttpUriValidationError is the validation error returned by HttpUri.Validate |
| 177 |
// if the designated constraints aren't met. |
| 178 |
type HttpUriValidationError struct { |
| 179 |
field string |
| 180 |
reason string |
| 181 |
cause error |
| 182 |
key bool |
| 183 |
} |
| 184 |
|
| 185 |
// Field function returns field value. |
| 186 |
func (e HttpUriValidationError) Field() string { return e.field } |
| 187 |
|
| 188 |
// Reason function returns reason value. |
| 189 |
func (e HttpUriValidationError) Reason() string { return e.reason } |
| 190 |
|
| 191 |
// Cause function returns cause value. |
| 192 |
func (e HttpUriValidationError) Cause() error { return e.cause } |
| 193 |
|
| 194 |
// Key function returns key value. |
| 195 |
func (e HttpUriValidationError) Key() bool { return e.key } |
| 196 |
|
| 197 |
// ErrorName returns error name. |
| 198 |
func (e HttpUriValidationError) ErrorName() string { return "HttpUriValidationError" } |
| 199 |
|
| 200 |
// Error satisfies the builtin error interface |
| 201 |
func (e HttpUriValidationError) Error() string { |
| 202 |
cause := "" |
| 203 |
if e.cause != nil { |
| 204 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 205 |
} |
| 206 |
|
| 207 |
key := "" |
| 208 |
if e.key { |
| 209 |
key = "key for " |
| 210 |
} |
| 211 |
|
| 212 |
return fmt.Sprintf( |
| 213 |
"invalid %sHttpUri.%s: %s%s", |
| 214 |
key, |
| 215 |
e.field, |
| 216 |
e.reason, |
| 217 |
cause) |
| 218 |
} |
| 219 |
|
| 220 |
var _ error = HttpUriValidationError{} |
| 221 |
|
| 222 |
var _ interface { |
| 223 |
Field() string |
| 224 |
Reason() string |
| 225 |
Key() bool |
| 226 |
Cause() error |
| 227 |
ErrorName() string |
| 228 |
} = HttpUriValidationError{} |