...
1
2
3
4 package envoy_config_metrics_v4alpha
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 v4alpha "github.com/datawire/ambassador/v2/pkg/api/envoy/config/core/v4alpha"
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 _ = v4alpha.ApiVersion(0)
38 )
39
40
41
42
43 func (m *MetricsServiceConfig) Validate() error {
44 if m == nil {
45 return nil
46 }
47
48 if m.GetGrpcService() == nil {
49 return MetricsServiceConfigValidationError{
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 MetricsServiceConfigValidationError{
58 field: "GrpcService",
59 reason: "embedded message failed validation",
60 cause: err,
61 }
62 }
63 }
64
65 if _, ok := v4alpha.ApiVersion_name[int32(m.GetTransportApiVersion())]; !ok {
66 return MetricsServiceConfigValidationError{
67 field: "TransportApiVersion",
68 reason: "value must be one of the defined enum values",
69 }
70 }
71
72 if v, ok := interface{}(m.GetReportCountersAsDeltas()).(interface{ Validate() error }); ok {
73 if err := v.Validate(); err != nil {
74 return MetricsServiceConfigValidationError{
75 field: "ReportCountersAsDeltas",
76 reason: "embedded message failed validation",
77 cause: err,
78 }
79 }
80 }
81
82 return nil
83 }
84
85
86
87 type MetricsServiceConfigValidationError struct {
88 field string
89 reason string
90 cause error
91 key bool
92 }
93
94
95 func (e MetricsServiceConfigValidationError) Field() string { return e.field }
96
97
98 func (e MetricsServiceConfigValidationError) Reason() string { return e.reason }
99
100
101 func (e MetricsServiceConfigValidationError) Cause() error { return e.cause }
102
103
104 func (e MetricsServiceConfigValidationError) Key() bool { return e.key }
105
106
107 func (e MetricsServiceConfigValidationError) ErrorName() string {
108 return "MetricsServiceConfigValidationError"
109 }
110
111
112 func (e MetricsServiceConfigValidationError) Error() string {
113 cause := ""
114 if e.cause != nil {
115 cause = fmt.Sprintf(" | caused by: %v", e.cause)
116 }
117
118 key := ""
119 if e.key {
120 key = "key for "
121 }
122
123 return fmt.Sprintf(
124 "invalid %sMetricsServiceConfig.%s: %s%s",
125 key,
126 e.field,
127 e.reason,
128 cause)
129 }
130
131 var _ error = MetricsServiceConfigValidationError{}
132
133 var _ interface {
134 Field() string
135 Reason() string
136 Key() bool
137 Cause() error
138 ErrorName() string
139 } = MetricsServiceConfigValidationError{}
140
View as plain text