1// Code generated by protoc-gen-validate. DO NOT EDIT.
2// source: envoy/config/trace/v3/opencensus.proto
3
4package envoy_config_trace_v3
5
6import (
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
23var (
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 OpenCensusConfig with the rules defined
39// in the proto definition for this message. If any rules are violated, the
40// first error encountered is returned, or nil if there are no violations.
41func (m *OpenCensusConfig) Validate() error {
42	return m.validate(false)
43}
44
45// ValidateAll checks the field values on OpenCensusConfig with the rules
46// defined in the proto definition for this message. If any rules are
47// violated, the result is a list of violation errors wrapped in
48// OpenCensusConfigMultiError, or nil if none found.
49func (m *OpenCensusConfig) ValidateAll() error {
50	return m.validate(true)
51}
52
53func (m *OpenCensusConfig) validate(all bool) error {
54	if m == nil {
55		return nil
56	}
57
58	var errors []error
59
60	if all {
61		switch v := interface{}(m.GetTraceConfig()).(type) {
62		case interface{ ValidateAll() error }:
63			if err := v.ValidateAll(); err != nil {
64				errors = append(errors, OpenCensusConfigValidationError{
65					field:  "TraceConfig",
66					reason: "embedded message failed validation",
67					cause:  err,
68				})
69			}
70		case interface{ Validate() error }:
71			if err := v.Validate(); err != nil {
72				errors = append(errors, OpenCensusConfigValidationError{
73					field:  "TraceConfig",
74					reason: "embedded message failed validation",
75					cause:  err,
76				})
77			}
78		}
79	} else if v, ok := interface{}(m.GetTraceConfig()).(interface{ Validate() error }); ok {
80		if err := v.Validate(); err != nil {
81			return OpenCensusConfigValidationError{
82				field:  "TraceConfig",
83				reason: "embedded message failed validation",
84				cause:  err,
85			}
86		}
87	}
88
89	// no validation rules for StdoutExporterEnabled
90
91	// no validation rules for StackdriverExporterEnabled
92
93	// no validation rules for StackdriverProjectId
94
95	// no validation rules for StackdriverAddress
96
97	if all {
98		switch v := interface{}(m.GetStackdriverGrpcService()).(type) {
99		case interface{ ValidateAll() error }:
100			if err := v.ValidateAll(); err != nil {
101				errors = append(errors, OpenCensusConfigValidationError{
102					field:  "StackdriverGrpcService",
103					reason: "embedded message failed validation",
104					cause:  err,
105				})
106			}
107		case interface{ Validate() error }:
108			if err := v.Validate(); err != nil {
109				errors = append(errors, OpenCensusConfigValidationError{
110					field:  "StackdriverGrpcService",
111					reason: "embedded message failed validation",
112					cause:  err,
113				})
114			}
115		}
116	} else if v, ok := interface{}(m.GetStackdriverGrpcService()).(interface{ Validate() error }); ok {
117		if err := v.Validate(); err != nil {
118			return OpenCensusConfigValidationError{
119				field:  "StackdriverGrpcService",
120				reason: "embedded message failed validation",
121				cause:  err,
122			}
123		}
124	}
125
126	// no validation rules for ZipkinExporterEnabled
127
128	// no validation rules for ZipkinUrl
129
130	// no validation rules for OcagentExporterEnabled
131
132	// no validation rules for OcagentAddress
133
134	if all {
135		switch v := interface{}(m.GetOcagentGrpcService()).(type) {
136		case interface{ ValidateAll() error }:
137			if err := v.ValidateAll(); err != nil {
138				errors = append(errors, OpenCensusConfigValidationError{
139					field:  "OcagentGrpcService",
140					reason: "embedded message failed validation",
141					cause:  err,
142				})
143			}
144		case interface{ Validate() error }:
145			if err := v.Validate(); err != nil {
146				errors = append(errors, OpenCensusConfigValidationError{
147					field:  "OcagentGrpcService",
148					reason: "embedded message failed validation",
149					cause:  err,
150				})
151			}
152		}
153	} else if v, ok := interface{}(m.GetOcagentGrpcService()).(interface{ Validate() error }); ok {
154		if err := v.Validate(); err != nil {
155			return OpenCensusConfigValidationError{
156				field:  "OcagentGrpcService",
157				reason: "embedded message failed validation",
158				cause:  err,
159			}
160		}
161	}
162
163	if len(errors) > 0 {
164		return OpenCensusConfigMultiError(errors)
165	}
166	return nil
167}
168
169// OpenCensusConfigMultiError is an error wrapping multiple validation errors
170// returned by OpenCensusConfig.ValidateAll() if the designated constraints
171// aren't met.
172type OpenCensusConfigMultiError []error
173
174// Error returns a concatenation of all the error messages it wraps.
175func (m OpenCensusConfigMultiError) Error() string {
176	var msgs []string
177	for _, err := range m {
178		msgs = append(msgs, err.Error())
179	}
180	return strings.Join(msgs, "; ")
181}
182
183// AllErrors returns a list of validation violation errors.
184func (m OpenCensusConfigMultiError) AllErrors() []error { return m }
185
186// OpenCensusConfigValidationError is the validation error returned by
187// OpenCensusConfig.Validate if the designated constraints aren't met.
188type OpenCensusConfigValidationError struct {
189	field  string
190	reason string
191	cause  error
192	key    bool
193}
194
195// Field function returns field value.
196func (e OpenCensusConfigValidationError) Field() string { return e.field }
197
198// Reason function returns reason value.
199func (e OpenCensusConfigValidationError) Reason() string { return e.reason }
200
201// Cause function returns cause value.
202func (e OpenCensusConfigValidationError) Cause() error { return e.cause }
203
204// Key function returns key value.
205func (e OpenCensusConfigValidationError) Key() bool { return e.key }
206
207// ErrorName returns error name.
208func (e OpenCensusConfigValidationError) ErrorName() string { return "OpenCensusConfigValidationError" }
209
210// Error satisfies the builtin error interface
211func (e OpenCensusConfigValidationError) Error() string {
212	cause := ""
213	if e.cause != nil {
214		cause = fmt.Sprintf(" | caused by: %v", e.cause)
215	}
216
217	key := ""
218	if e.key {
219		key = "key for "
220	}
221
222	return fmt.Sprintf(
223		"invalid %sOpenCensusConfig.%s: %s%s",
224		key,
225		e.field,
226		e.reason,
227		cause)
228}
229
230var _ error = OpenCensusConfigValidationError{}
231
232var _ interface {
233	Field() string
234	Reason() string
235	Key() bool
236	Cause() error
237	ErrorName() string
238} = OpenCensusConfigValidationError{}
239