Debian Codegraph @

go/udpa/data/orca/v1/orca_load_report.pb.validate.go

raw symbols SCIP
1 // Code generated by protoc-gen-validate. DO NOT EDIT.
2 // source: udpa/data/orca/v1/orca_load_report.proto
3
4 package v1
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 val := m.GetCpuUtilization(); val < 0 || val > 1 {
61 err := OrcaLoadReportValidationError{
62 field: "CpuUtilization",
63 reason: "value must be inside range [0, 1]",
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 len(errors) > 0 {
115 return OrcaLoadReportMultiError(errors)
116 }
117
118 return nil
119 }
120
121 // OrcaLoadReportMultiError is an error wrapping multiple validation errors
122 // returned by OrcaLoadReport.ValidateAll() if the designated constraints
123 // aren't met.
124 type OrcaLoadReportMultiError []error
125
126 // Error returns a concatenation of all the error messages it wraps.
127 func (m OrcaLoadReportMultiError) Error() string {
128 msgs := make([]string, 0, len(m))
129 for _, err := range m {
130 msgs = append(msgs, err.Error())
131 }
132 return strings.Join(msgs, "; ")
133 }
134
135 // AllErrors returns a list of validation violation errors.
136 func (m OrcaLoadReportMultiError) AllErrors() []error { return m }
137
138 // OrcaLoadReportValidationError is the validation error returned by
139 // OrcaLoadReport.Validate if the designated constraints aren't met.
140 type OrcaLoadReportValidationError struct {
141 field string
142 reason string
143 cause error
144 key bool
145 }
146
147 // Field function returns field value.
148 func (e OrcaLoadReportValidationError) Field() string { return e.field }
149
150 // Reason function returns reason value.
151 func (e OrcaLoadReportValidationError) Reason() string { return e.reason }
152
153 // Cause function returns cause value.
154 func (e OrcaLoadReportValidationError) Cause() error { return e.cause }
155
156 // Key function returns key value.
157 func (e OrcaLoadReportValidationError) Key() bool { return e.key }
158
159 // ErrorName returns error name.
160 func (e OrcaLoadReportValidationError) ErrorName() string { return "OrcaLoadReportValidationError" }
161
162 // Error satisfies the builtin error interface
163 func (e OrcaLoadReportValidationError) Error() string {
164 cause := ""
165 if e.cause != nil {
166 cause = fmt.Sprintf(" | caused by: %v", e.cause)
167 }
168
169 key := ""
170 if e.key {
171 key = "key for "
172 }
173
174 return fmt.Sprintf(
175 "invalid %sOrcaLoadReport.%s: %s%s",
176 key,
177 e.field,
178 e.reason,
179 cause)
180 }
181
182 var _ error = OrcaLoadReportValidationError{}
183
184 var _ interface {
185 Field() string
186 Reason() string
187 Key() bool
188 Cause() error
189 ErrorName() string
190 } = OrcaLoadReportValidationError{}