| 1 |
//go:build !disable_pgv |
| 2 |
// Code generated by protoc-gen-validate. DO NOT EDIT. |
| 3 |
// source: envoy/config/common/dynamic_forward_proxy/v2alpha/dns_cache.proto |
| 4 |
|
| 5 |
package v2alpha |
| 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 |
v2 "github.com/envoyproxy/go-control-plane/envoy/api/v2" |
| 23 |
) |
| 24 |
|
| 25 |
// ensure the imports are used |
| 26 |
var ( |
| 27 |
_ = bytes.MinRead |
| 28 |
_ = errors.New("") |
| 29 |
_ = fmt.Print |
| 30 |
_ = utf8.UTFMax |
| 31 |
_ = (*regexp.Regexp)(nil) |
| 32 |
_ = (*strings.Reader)(nil) |
| 33 |
_ = net.IPv4len |
| 34 |
_ = time.Duration(0) |
| 35 |
_ = (*url.URL)(nil) |
| 36 |
_ = (*mail.Address)(nil) |
| 37 |
_ = anypb.Any{} |
| 38 |
_ = sort.Sort |
| 39 |
|
| 40 |
_ = v2.Cluster_DnsLookupFamily(0) |
| 41 |
) |
| 42 |
|
| 43 |
// Validate checks the field values on DnsCacheConfig with the rules defined in |
| 44 |
// the proto definition for this message. If any rules are violated, the first |
| 45 |
// error encountered is returned, or nil if there are no violations. |
| 46 |
func (m *DnsCacheConfig) Validate() error { |
| 47 |
return m.validate(false) |
| 48 |
} |
| 49 |
|
| 50 |
// ValidateAll checks the field values on DnsCacheConfig with the rules defined |
| 51 |
// in the proto definition for this message. If any rules are violated, the |
| 52 |
// result is a list of violation errors wrapped in DnsCacheConfigMultiError, |
| 53 |
// or nil if none found. |
| 54 |
func (m *DnsCacheConfig) ValidateAll() error { |
| 55 |
return m.validate(true) |
| 56 |
} |
| 57 |
|
| 58 |
func (m *DnsCacheConfig) validate(all bool) error { |
| 59 |
if m == nil { |
| 60 |
return nil |
| 61 |
} |
| 62 |
|
| 63 |
var errors []error |
| 64 |
|
| 65 |
if len(m.GetName()) < 1 { |
| 66 |
err := DnsCacheConfigValidationError{ |
| 67 |
field: "Name", |
| 68 |
reason: "value length must be at least 1 bytes", |
| 69 |
} |
| 70 |
if !all { |
| 71 |
return err |
| 72 |
} |
| 73 |
errors = append(errors, err) |
| 74 |
} |
| 75 |
|
| 76 |
if _, ok := v2.Cluster_DnsLookupFamily_name[int32(m.GetDnsLookupFamily())]; !ok { |
| 77 |
err := DnsCacheConfigValidationError{ |
| 78 |
field: "DnsLookupFamily", |
| 79 |
reason: "value must be one of the defined enum values", |
| 80 |
} |
| 81 |
if !all { |
| 82 |
return err |
| 83 |
} |
| 84 |
errors = append(errors, err) |
| 85 |
} |
| 86 |
|
| 87 |
if d := m.GetDnsRefreshRate(); d != nil { |
| 88 |
dur, err := d.AsDuration(), d.CheckValid() |
| 89 |
if err != nil { |
| 90 |
err = DnsCacheConfigValidationError{ |
| 91 |
field: "DnsRefreshRate", |
| 92 |
reason: "value is not a valid duration", |
| 93 |
cause: err, |
| 94 |
} |
| 95 |
if !all { |
| 96 |
return err |
| 97 |
} |
| 98 |
errors = append(errors, err) |
| 99 |
} else { |
| 100 |
|
| 101 |
gte := time.Duration(0*time.Second + 1000000*time.Nanosecond) |
| 102 |
|
| 103 |
if dur < gte { |
| 104 |
err := DnsCacheConfigValidationError{ |
| 105 |
field: "DnsRefreshRate", |
| 106 |
reason: "value must be greater than or equal to 1ms", |
| 107 |
} |
| 108 |
if !all { |
| 109 |
return err |
| 110 |
} |
| 111 |
errors = append(errors, err) |
| 112 |
} |
| 113 |
|
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
if d := m.GetHostTtl(); d != nil { |
| 118 |
dur, err := d.AsDuration(), d.CheckValid() |
| 119 |
if err != nil { |
| 120 |
err = DnsCacheConfigValidationError{ |
| 121 |
field: "HostTtl", |
| 122 |
reason: "value is not a valid duration", |
| 123 |
cause: err, |
| 124 |
} |
| 125 |
if !all { |
| 126 |
return err |
| 127 |
} |
| 128 |
errors = append(errors, err) |
| 129 |
} else { |
| 130 |
|
| 131 |
gt := time.Duration(0*time.Second + 0*time.Nanosecond) |
| 132 |
|
| 133 |
if dur <= gt { |
| 134 |
err := DnsCacheConfigValidationError{ |
| 135 |
field: "HostTtl", |
| 136 |
reason: "value must be greater than 0s", |
| 137 |
} |
| 138 |
if !all { |
| 139 |
return err |
| 140 |
} |
| 141 |
errors = append(errors, err) |
| 142 |
} |
| 143 |
|
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
if wrapper := m.GetMaxHosts(); wrapper != nil { |
| 148 |
|
| 149 |
if wrapper.GetValue() <= 0 { |
| 150 |
err := DnsCacheConfigValidationError{ |
| 151 |
field: "MaxHosts", |
| 152 |
reason: "value must be greater than 0", |
| 153 |
} |
| 154 |
if !all { |
| 155 |
return err |
| 156 |
} |
| 157 |
errors = append(errors, err) |
| 158 |
} |
| 159 |
|
| 160 |
} |
| 161 |
|
| 162 |
if all { |
| 163 |
switch v := interface{}(m.GetDnsFailureRefreshRate()).(type) { |
| 164 |
case interface{ ValidateAll() error }: |
| 165 |
if err := v.ValidateAll(); err != nil { |
| 166 |
errors = append(errors, DnsCacheConfigValidationError{ |
| 167 |
field: "DnsFailureRefreshRate", |
| 168 |
reason: "embedded message failed validation", |
| 169 |
cause: err, |
| 170 |
}) |
| 171 |
} |
| 172 |
case interface{ Validate() error }: |
| 173 |
if err := v.Validate(); err != nil { |
| 174 |
errors = append(errors, DnsCacheConfigValidationError{ |
| 175 |
field: "DnsFailureRefreshRate", |
| 176 |
reason: "embedded message failed validation", |
| 177 |
cause: err, |
| 178 |
}) |
| 179 |
} |
| 180 |
} |
| 181 |
} else if v, ok := interface{}(m.GetDnsFailureRefreshRate()).(interface{ Validate() error }); ok { |
| 182 |
if err := v.Validate(); err != nil { |
| 183 |
return DnsCacheConfigValidationError{ |
| 184 |
field: "DnsFailureRefreshRate", |
| 185 |
reason: "embedded message failed validation", |
| 186 |
cause: err, |
| 187 |
} |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
if len(errors) > 0 { |
| 192 |
return DnsCacheConfigMultiError(errors) |
| 193 |
} |
| 194 |
|
| 195 |
return nil |
| 196 |
} |
| 197 |
|
| 198 |
// DnsCacheConfigMultiError is an error wrapping multiple validation errors |
| 199 |
// returned by DnsCacheConfig.ValidateAll() if the designated constraints |
| 200 |
// aren't met. |
| 201 |
type DnsCacheConfigMultiError []error |
| 202 |
|
| 203 |
// Error returns a concatenation of all the error messages it wraps. |
| 204 |
func (m DnsCacheConfigMultiError) Error() string { |
| 205 |
var msgs []string |
| 206 |
for _, err := range m { |
| 207 |
msgs = append(msgs, err.Error()) |
| 208 |
} |
| 209 |
return strings.Join(msgs, "; ") |
| 210 |
} |
| 211 |
|
| 212 |
// AllErrors returns a list of validation violation errors. |
| 213 |
func (m DnsCacheConfigMultiError) AllErrors() []error { return m } |
| 214 |
|
| 215 |
// DnsCacheConfigValidationError is the validation error returned by |
| 216 |
// DnsCacheConfig.Validate if the designated constraints aren't met. |
| 217 |
type DnsCacheConfigValidationError struct { |
| 218 |
field string |
| 219 |
reason string |
| 220 |
cause error |
| 221 |
key bool |
| 222 |
} |
| 223 |
|
| 224 |
// Field function returns field value. |
| 225 |
func (e DnsCacheConfigValidationError) Field() string { return e.field } |
| 226 |
|
| 227 |
// Reason function returns reason value. |
| 228 |
func (e DnsCacheConfigValidationError) Reason() string { return e.reason } |
| 229 |
|
| 230 |
// Cause function returns cause value. |
| 231 |
func (e DnsCacheConfigValidationError) Cause() error { return e.cause } |
| 232 |
|
| 233 |
// Key function returns key value. |
| 234 |
func (e DnsCacheConfigValidationError) Key() bool { return e.key } |
| 235 |
|
| 236 |
// ErrorName returns error name. |
| 237 |
func (e DnsCacheConfigValidationError) ErrorName() string { return "DnsCacheConfigValidationError" } |
| 238 |
|
| 239 |
// Error satisfies the builtin error interface |
| 240 |
func (e DnsCacheConfigValidationError) Error() string { |
| 241 |
cause := "" |
| 242 |
if e.cause != nil { |
| 243 |
cause = fmt.Sprintf(" | caused by: %v", e.cause) |
| 244 |
} |
| 245 |
|
| 246 |
key := "" |
| 247 |
if e.key { |
| 248 |
key = "key for " |
| 249 |
} |
| 250 |
|
| 251 |
return fmt.Sprintf( |
| 252 |
"invalid %sDnsCacheConfig.%s: %s%s", |
| 253 |
key, |
| 254 |
e.field, |
| 255 |
e.reason, |
| 256 |
cause) |
| 257 |
} |
| 258 |
|
| 259 |
var _ error = DnsCacheConfigValidationError{} |
| 260 |
|
| 261 |
var _ interface { |
| 262 |
Field() string |
| 263 |
Reason() string |
| 264 |
Key() bool |
| 265 |
Cause() error |
| 266 |
ErrorName() string |
| 267 |
} = DnsCacheConfigValidationError{} |