Debian Codegraph @

go/xds/data/orca/v3/orca_load_report.pb.validate.go

raw symbols SCIP
1 // Code generated by protoc-gen-validate. DO NOT EDIT.
2 // source: xds/data/orca/v3/orca_load_report.proto
3
4 package v3
5
6 import (
7 "bytes"
8 "errors"
9 "fmt"
10 "net"
11 "net/mail"
12 "net/url"
13 "regexp"
14 "sort"
15 "strings"
16 "time"
17 "unicode/utf8"
18
19 "google.golang.org/protobuf/types/known/anypb"
20 )
21
22 // ensure the imports are used
23 var (
24 _ = bytes.MinRead
25 _ = errors.New("")
26 _ = fmt.Print
27 _ = utf8.UTFMax
28 _ = (*regexp.Regexp)(nil)
29 _ = (*strings.Reader)(nil)
30 _ = net.IPv4len
31 _ = time.Duration(0)
32 _ = (*url.URL)(nil)
33 _ = (*mail.Address)(nil)
34 _ = anypb.Any{}
35 _ = sort.Sort
36 )
37
38 // Validate checks the field values on OrcaLoadReport with the rules defined in
39 // the proto definition for this message. If any rules are violated, the first
40 // error encountered is returned, or nil if there are no violations.
41 func (m *OrcaLoadReport) Validate() error {
42 return m.validate(false)
43 }
44
45 // ValidateAll checks the field values on OrcaLoadReport with the rules defined
46 // in the proto definition for this message. If any rules are violated, the
47 // result is a list of violation errors wrapped in OrcaLoadReportMultiError,
48 // or nil if none found.
49 func (m *OrcaLoadReport) ValidateAll() error {
50 return m.validate(true)
51 }
52
53 func (m *OrcaLoadReport) validate(all bool) error {
54 if m == nil {
55 return nil
56 }
57
58 var errors []error
59
60 if m.GetCpuUtilization() < 0 {
61 err := OrcaLoadReportValidationError{
62 field: "CpuUtilization",
63 reason: "value must be greater than or equal to 0",
64 }
65 if !all {
66 return err
67 }
68 errors = append(errors, err)
69 }
70
71 if val := m.GetMemUtilization(); val < 0 || val > 1 {
72 err := OrcaLoadReportValidationError{
73 field: "MemUtilization",
74 reason: "value must be inside range [0, 1]",
75 }
76 if !all {
77 return err
78 }
79 errors = append(errors, err)
80 }
81
82 // no validation rules for Rps
83
84 // no validation rules for RequestCost
85
86 {
87 sorted_keys := make([]string, len(m.GetUtilization()))
88 i := 0
89 for key := range m.GetUtilization() {
90 sorted_keys[i] = key
91 i++
92 }
93 sort.Slice(sorted_keys, func(i, j int) bool { return sorted_keys[i] < sorted_keys[j] })
94 for _, key := range sorted_keys {
95 val := m.GetUtilization()[key]
96 _ = val
97
98 // no validation rules for Utilization[key]
99
100 if val := val; val < 0 || val > 1 {
101 err := OrcaLoadReportValidationError{
102 field: fmt.Sprintf("Utilization[%v]", key),
103 reason: "value must be inside range [0, 1]",
104 }
105 if !all {
106 return err
107 }
108 errors = append(errors, err)
109 }
110
111 }
112 }
113
114 if m.GetRpsFractional() < 0 {
115 err := OrcaLoadReportValidationError{
116 field: "RpsFractional",
117 reason: "value must be greater than or equal to 0",
118 }
119 if !all {
120 return err
121 }
122 errors = append(errors, err)
123 }
124
125 if m.GetEps() < 0 {
126 err := OrcaLoadReportValidationError{
127 field: "Eps",
128 reason: "value must be greater than or equal to 0",
129 }
130 if !all {
131 return err
132 }
133 errors = append(errors, err)
134 }
135
136 // no validation rules for NamedMetrics
137
138 if m.GetApplicationUtilization() < 0 {
139 err := OrcaLoadReportValidationError{
140 field: "ApplicationUtilization",
141 reason: "value must be greater than or equal to 0",
142 }
143 if !all {
144 return err
145 }
146 errors = append(errors, err)
147 }
148
149 if len(errors) > 0 {
150 return OrcaLoadReportMultiError(errors)
151 }
152
153 return nil
154 }
155
156 // OrcaLoadReportMultiError is an error wrapping multiple validation errors
157 // returned by OrcaLoadReport.ValidateAll() if the designated constraints
158 // aren't met.
159 type OrcaLoadReportMultiError []error
160
161 // Error returns a concatenation of all the error messages it wraps.
162 func (m OrcaLoadReportMultiError) Error() string {
163 msgs := make([]string, 0, len(m))
164 for _, err := range m {
165 msgs = append(msgs, err.Error())
166 }
167 return strings.Join(msgs, "; ")
168 }
169
170 // AllErrors returns a list of validation violation errors.
171 func (m OrcaLoadReportMultiError) AllErrors() []error { return m }
172
173 // OrcaLoadReportValidationError is the validation error returned by
174 // OrcaLoadReport.Validate if the designated constraints aren't met.
175 type OrcaLoadReportValidationError struct {
176 field string
177 reason string
178 cause error
179 key bool
180 }
181
182 // Field function returns field value.
183 func (e OrcaLoadReportValidationError) Field() string { return e.field }
184
185 // Reason function returns reason value.
186 func (e OrcaLoadReportValidationError) Reason() string { return e.reason }
187
188 // Cause function returns cause value.
189 func (e OrcaLoadReportValidationError) Cause() error { return e.cause }
190
191 // Key function returns key value.
192 func (e OrcaLoadReportValidationError) Key() bool { return e.key }
193
194 // ErrorName returns error name.
195 func (e OrcaLoadReportValidationError) ErrorName() string { return "OrcaLoadReportValidationError" }
196
197 // Error satisfies the builtin error interface
198 func (e OrcaLoadReportValidationError) Error() string {
199 cause := ""
200 if e.cause != nil {
201 cause = fmt.Sprintf(" | caused by: %v", e.cause)
202 }
203
204 key := ""
205 if e.key {
206 key = "key for "
207 }
208
209 return fmt.Sprintf(
210 "invalid %sOrcaLoadReport.%s: %s%s",
211 key,
212 e.field,
213 e.reason,
214 cause)
215 }
216
217 var _ error = OrcaLoadReportValidationError{}
218
219 var _ interface {
220 Field() string
221 Reason() string
222 Key() bool
223 Cause() error
224 ErrorName() string
225 } = OrcaLoadReportValidationError{}