...
1
2
3
4 package envoy_config_ratelimit_v3
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "strings"
15 "time"
16 "unicode/utf8"
17
18 "github.com/golang/protobuf/ptypes"
19
20 v3 "github.com/datawire/ambassador/v2/pkg/api/envoy/config/core/v3"
21 )
22
23
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 _ = ptypes.DynamicAny{}
36
37 _ = v3.ApiVersion(0)
38 )
39
40
41
42
43 func (m *RateLimitServiceConfig) Validate() error {
44 if m == nil {
45 return nil
46 }
47
48 if m.GetGrpcService() == nil {
49 return RateLimitServiceConfigValidationError{
50 field: "GrpcService",
51 reason: "value is required",
52 }
53 }
54
55 if v, ok := interface{}(m.GetGrpcService()).(interface{ Validate() error }); ok {
56 if err := v.Validate(); err != nil {
57 return RateLimitServiceConfigValidationError{
58 field: "GrpcService",
59 reason: "embedded message failed validation",
60 cause: err,
61 }
62 }
63 }
64
65 if _, ok := v3.ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
66 return RateLimitServiceConfigValidationError{
67 field: "TransportApiVersion",
68 reason: "value must be one of the defined enum values",
69 }
70 }
71
72
73
74 return nil
75 }
76
77
78
79 type RateLimitServiceConfigValidationError struct {
80 field string
81 reason string
82 cause error
83 key bool
84 }
85
86
87 func (e RateLimitServiceConfigValidationError) Field() string { return e.field }
88
89
90 func (e RateLimitServiceConfigValidationError) Reason() string { return e.reason }
91
92
93 func (e RateLimitServiceConfigValidationError) Cause() error { return e.cause }
94
95
96 func (e RateLimitServiceConfigValidationError) Key() bool { return e.key }
97
98
99 func (e RateLimitServiceConfigValidationError) ErrorName() string {
100 return "RateLimitServiceConfigValidationError"
101 }
102
103
104 func (e RateLimitServiceConfigValidationError) Error() string {
105 cause := ""
106 if e.cause != nil {
107 cause = fmt.Sprintf(" | caused by: %v", e.cause)
108 }
109
110 key := ""
111 if e.key {
112 key = "key for "
113 }
114
115 return fmt.Sprintf(
116 "invalid %sRateLimitServiceConfig.%s: %s%s",
117 key,
118 e.field,
119 e.reason,
120 cause)
121 }
122
123 var _ error = RateLimitServiceConfigValidationError{}
124
125 var _ interface {
126 Field() string
127 Reason() string
128 Key() bool
129 Cause() error
130 ErrorName() string
131 } = RateLimitServiceConfigValidationError{}
132
View as plain text