...
1
2
3
4 package envoy_extensions_tracers_lightstep_v4alpha
5
6 import (
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 "github.com/golang/protobuf/ptypes"
19 )
20
21
22 var (
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 _ = ptypes.DynamicAny{}
34 )
35
36
37
38
39 func (m *LightstepConfig) Validate() error {
40 if m == nil {
41 return nil
42 }
43
44 if utf8.RuneCountInString(m.GetCollectorCluster()) < 1 {
45 return LightstepConfigValidationError{
46 field: "CollectorCluster",
47 reason: "value length must be at least 1 runes",
48 }
49 }
50
51 if utf8.RuneCountInString(m.GetAccessTokenFile()) < 1 {
52 return LightstepConfigValidationError{
53 field: "AccessTokenFile",
54 reason: "value length must be at least 1 runes",
55 }
56 }
57
58 for idx, item := range m.GetPropagationModes() {
59 _, _ = idx, item
60
61 if _, ok := LightstepConfig_PropagationMode_name[int32(item)]; !ok {
62 return LightstepConfigValidationError{
63 field: fmt.Sprintf("PropagationModes[%v]", idx),
64 reason: "value must be one of the defined enum values",
65 }
66 }
67
68 }
69
70 return nil
71 }
72
73
74
75 type LightstepConfigValidationError struct {
76 field string
77 reason string
78 cause error
79 key bool
80 }
81
82
83 func (e LightstepConfigValidationError) Field() string { return e.field }
84
85
86 func (e LightstepConfigValidationError) Reason() string { return e.reason }
87
88
89 func (e LightstepConfigValidationError) Cause() error { return e.cause }
90
91
92 func (e LightstepConfigValidationError) Key() bool { return e.key }
93
94
95 func (e LightstepConfigValidationError) ErrorName() string { return "LightstepConfigValidationError" }
96
97
98 func (e LightstepConfigValidationError) Error() string {
99 cause := ""
100 if e.cause != nil {
101 cause = fmt.Sprintf(" | caused by: %v", e.cause)
102 }
103
104 key := ""
105 if e.key {
106 key = "key for "
107 }
108
109 return fmt.Sprintf(
110 "invalid %sLightstepConfig.%s: %s%s",
111 key,
112 e.field,
113 e.reason,
114 cause)
115 }
116
117 var _ error = LightstepConfigValidationError{}
118
119 var _ interface {
120 Field() string
121 Reason() string
122 Key() bool
123 Cause() error
124 ErrorName() string
125 } = LightstepConfigValidationError{}
126
View as plain text