Debian Codegraph @

envoy/extensions/tracers/opentelemetry/samplers/v3/dynatrace_sampler.pb.validate.go

raw
1 //go:build !disable_pgv
2 // Code generated by protoc-gen-validate. DO NOT EDIT.
3 // source: envoy/extensions/tracers/opentelemetry/samplers/v3/dynatrace_sampler.proto
4
5 package samplersv3
6
7 import (
8 "bytes"
9 "errors"
10 "fmt"
11 "net"
12 "net/mail"
13 "net/url"
14 "regexp"
15 "sort"
16 "strings"
17 "time"
18 "unicode/utf8"
19
20 "google.golang.org/protobuf/types/known/anypb"
21 )
22
23 // ensure the imports are used
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 _ = anypb.Any{}
36 _ = sort.Sort
37 )
38
39 // Validate checks the field values on DynatraceSamplerConfig with the rules
40 // defined in the proto definition for this message. If any rules are
41 // violated, the first error encountered is returned, or nil if there are no violations.
42 func (m *DynatraceSamplerConfig) Validate() error {
43 return m.validate(false)
44 }
45
46 // ValidateAll checks the field values on DynatraceSamplerConfig with the rules
47 // defined in the proto definition for this message. If any rules are
48 // violated, the result is a list of violation errors wrapped in
49 // DynatraceSamplerConfigMultiError, or nil if none found.
50 func (m *DynatraceSamplerConfig) ValidateAll() error {
51 return m.validate(true)
52 }
53
54 func (m *DynatraceSamplerConfig) validate(all bool) error {
55 if m == nil {
56 return nil
57 }
58
59 var errors []error
60
61 // no validation rules for Tenant
62
63 // no validation rules for ClusterId
64
65 if all {
66 switch v := interface{}(m.GetHttpService()).(type) {
67 case interface{ ValidateAll() error }:
68 if err := v.ValidateAll(); err != nil {
69 errors = append(errors, DynatraceSamplerConfigValidationError{
70 field: "HttpService",
71 reason: "embedded message failed validation",
72 cause: err,
73 })
74 }
75 case interface{ Validate() error }:
76 if err := v.Validate(); err != nil {
77 errors = append(errors, DynatraceSamplerConfigValidationError{
78 field: "HttpService",
79 reason: "embedded message failed validation",
80 cause: err,
81 })
82 }
83 }
84 } else if v, ok := interface{}(m.GetHttpService()).(interface{ Validate() error }); ok {
85 if err := v.Validate(); err != nil {
86 return DynatraceSamplerConfigValidationError{
87 field: "HttpService",
88 reason: "embedded message failed validation",
89 cause: err,
90 }
91 }
92 }
93
94 // no validation rules for RootSpansPerMinute
95
96 if len(errors) > 0 {
97 return DynatraceSamplerConfigMultiError(errors)
98 }
99
100 return nil
101 }
102
103 // DynatraceSamplerConfigMultiError is an error wrapping multiple validation
104 // errors returned by DynatraceSamplerConfig.ValidateAll() if the designated
105 // constraints aren't met.
106 type DynatraceSamplerConfigMultiError []error
107
108 // Error returns a concatenation of all the error messages it wraps.
109 func (m DynatraceSamplerConfigMultiError) Error() string {
110 var msgs []string
111 for _, err := range m {
112 msgs = append(msgs, err.Error())
113 }
114 return strings.Join(msgs, "; ")
115 }
116
117 // AllErrors returns a list of validation violation errors.
118 func (m DynatraceSamplerConfigMultiError) AllErrors() []error { return m }
119
120 // DynatraceSamplerConfigValidationError is the validation error returned by
121 // DynatraceSamplerConfig.Validate if the designated constraints aren't met.
122 type DynatraceSamplerConfigValidationError struct {
123 field string
124 reason string
125 cause error
126 key bool
127 }
128
129 // Field function returns field value.
130 func (e DynatraceSamplerConfigValidationError) Field() string { return e.field }
131
132 // Reason function returns reason value.
133 func (e DynatraceSamplerConfigValidationError) Reason() string { return e.reason }
134
135 // Cause function returns cause value.
136 func (e DynatraceSamplerConfigValidationError) Cause() error { return e.cause }
137
138 // Key function returns key value.
139 func (e DynatraceSamplerConfigValidationError) Key() bool { return e.key }
140
141 // ErrorName returns error name.
142 func (e DynatraceSamplerConfigValidationError) ErrorName() string {
143 return "DynatraceSamplerConfigValidationError"
144 }
145
146 // Error satisfies the builtin error interface
147 func (e DynatraceSamplerConfigValidationError) Error() string {
148 cause := ""
149 if e.cause != nil {
150 cause = fmt.Sprintf(" | caused by: %v", e.cause)
151 }
152
153 key := ""
154 if e.key {
155 key = "key for "
156 }
157
158 return fmt.Sprintf(
159 "invalid %sDynatraceSamplerConfig.%s: %s%s",
160 key,
161 e.field,
162 e.reason,
163 cause)
164 }
165
166 var _ error = DynatraceSamplerConfigValidationError{}
167
168 var _ interface {
169 Field() string
170 Reason() string
171 Key() bool
172 Cause() error
173 ErrorName() string
174 } = DynatraceSamplerConfigValidationError{}