...
1
2
3
4 package envoy_extensions_tracers_zipkin_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 *ZipkinConfig) Validate() error {
40 if m == nil {
41 return nil
42 }
43
44 if utf8.RuneCountInString(m.GetCollectorCluster()) < 1 {
45 return ZipkinConfigValidationError{
46 field: "CollectorCluster",
47 reason: "value length must be at least 1 runes",
48 }
49 }
50
51 if utf8.RuneCountInString(m.GetCollectorEndpoint()) < 1 {
52 return ZipkinConfigValidationError{
53 field: "CollectorEndpoint",
54 reason: "value length must be at least 1 runes",
55 }
56 }
57
58
59
60 if v, ok := interface{}(m.GetSharedSpanContext()).(interface{ Validate() error }); ok {
61 if err := v.Validate(); err != nil {
62 return ZipkinConfigValidationError{
63 field: "SharedSpanContext",
64 reason: "embedded message failed validation",
65 cause: err,
66 }
67 }
68 }
69
70
71
72
73
74 return nil
75 }
76
77
78
79 type ZipkinConfigValidationError struct {
80 field string
81 reason string
82 cause error
83 key bool
84 }
85
86
87 func (e ZipkinConfigValidationError) Field() string { return e.field }
88
89
90 func (e ZipkinConfigValidationError) Reason() string { return e.reason }
91
92
93 func (e ZipkinConfigValidationError) Cause() error { return e.cause }
94
95
96 func (e ZipkinConfigValidationError) Key() bool { return e.key }
97
98
99 func (e ZipkinConfigValidationError) ErrorName() string { return "ZipkinConfigValidationError" }
100
101
102 func (e ZipkinConfigValidationError) Error() string {
103 cause := ""
104 if e.cause != nil {
105 cause = fmt.Sprintf(" | caused by: %v", e.cause)
106 }
107
108 key := ""
109 if e.key {
110 key = "key for "
111 }
112
113 return fmt.Sprintf(
114 "invalid %sZipkinConfig.%s: %s%s",
115 key,
116 e.field,
117 e.reason,
118 cause)
119 }
120
121 var _ error = ZipkinConfigValidationError{}
122
123 var _ interface {
124 Field() string
125 Reason() string
126 Key() bool
127 Cause() error
128 ErrorName() string
129 } = ZipkinConfigValidationError{}
130
View as plain text