1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: xds/data/orca/v3/orca_load_report.proto
3
4package v3
5
6import (
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	"google.golang.org/protobuf/types/known/anypb"
19)
20
21// ensure the imports are used
22var (
23	_ = bytes.MinRead
24	_ = errors.New("")
25	_ = fmt.Print
26	_ = utf8.UTFMax
27	_ = (*regexp.Regexp)(nil)
28	_ = (*strings.Reader)(nil)
29	_ = net.IPv4len
30	_ = time.Duration(0)
31	_ = (*url.URL)(nil)
32	_ = (*mail.Address)(nil)
33	_ = anypb.Any{}
34)
35
36// Validate checks the field values on OrcaLoadReport with the rules defined in
37// the proto definition for this message. If any rules are violated, an error
38// is returned.
39func (m *OrcaLoadReport) Validate() error {
40	if m == nil {
41		return nil
42	}
43
44	if m.GetCpuUtilization() < 0 {
45		return OrcaLoadReportValidationError{
46			field:  "CpuUtilization",
47			reason: "value must be greater than or equal to 0",
48		}
49	}
50
51	if val := m.GetMemUtilization(); val < 0 || val > 1 {
52		return OrcaLoadReportValidationError{
53			field:  "MemUtilization",
54			reason: "value must be inside range [0, 1]",
55		}
56	}
57
58	// no validation rules for Rps
59
60	// no validation rules for RequestCost
61
62	for key, val := range m.GetUtilization() {
63		_ = val
64
65		// no validation rules for Utilization[key]
66
67		if val := val; val < 0 || val > 1 {
68			return OrcaLoadReportValidationError{
69				field:  fmt.Sprintf("Utilization[%v]", key),
70				reason: "value must be inside range [0, 1]",
71			}
72		}
73
74	}
75
76	if m.GetRpsFractional() < 0 {
77		return OrcaLoadReportValidationError{
78			field:  "RpsFractional",
79			reason: "value must be greater than or equal to 0",
80		}
81	}
82
83	if m.GetEps() < 0 {
84		return OrcaLoadReportValidationError{
85			field:  "Eps",
86			reason: "value must be greater than or equal to 0",
87		}
88	}
89
90	// no validation rules for NamedMetrics
91
92	if m.GetApplicationUtilization() < 0 {
93		return OrcaLoadReportValidationError{
94			field:  "ApplicationUtilization",
95			reason: "value must be greater than or equal to 0",
96		}
97	}
98
99	return nil
100}
101
102// OrcaLoadReportValidationError is the validation error returned by
103// OrcaLoadReport.Validate if the designated constraints aren't met.
104type OrcaLoadReportValidationError struct {
105	field  string
106	reason string
107	cause  error
108	key    bool
109}
110
111// Field function returns field value.
112func (e OrcaLoadReportValidationError) Field() string { return e.field }
113
114// Reason function returns reason value.
115func (e OrcaLoadReportValidationError) Reason() string { return e.reason }
116
117// Cause function returns cause value.
118func (e OrcaLoadReportValidationError) Cause() error { return e.cause }
119
120// Key function returns key value.
121func (e OrcaLoadReportValidationError) Key() bool { return e.key }
122
123// ErrorName returns error name.
124func (e OrcaLoadReportValidationError) ErrorName() string { return "OrcaLoadReportValidationError" }
125
126// Error satisfies the builtin error interface
127func (e OrcaLoadReportValidationError) Error() string {
128	cause := ""
129	if e.cause != nil {
130		cause = fmt.Sprintf(" | caused by: %v", e.cause)
131	}
132
133	key := ""
134	if e.key {
135		key = "key for "
136	}
137
138	return fmt.Sprintf(
139		"invalid %sOrcaLoadReport.%s: %s%s",
140		key,
141		e.field,
142		e.reason,
143		cause)
144}
145
146var _ error = OrcaLoadReportValidationError{}
147
148var _ interface {
149	Field() string
150	Reason() string
151	Key() bool
152	Cause() error
153	ErrorName() string
154} = OrcaLoadReportValidationError{}
155