id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequencelengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
sequencelengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
147,200
envoyproxy/go-control-plane
envoy/config/bootstrap/v2/bootstrap.pb.validate.go
Validate
func (m *Bootstrap_DynamicResources) Validate() error { if m == nil { return nil } { tmp := m.GetLdsConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Bootstrap_DynamicResourcesValidationError{ field: "LdsConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetCdsConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Bootstrap_DynamicResourcesValidationError{ field: "CdsConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetAdsConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Bootstrap_DynamicResourcesValidationError{ field: "AdsConfig", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *Bootstrap_DynamicResources) Validate() error { if m == nil { return nil } { tmp := m.GetLdsConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Bootstrap_DynamicResourcesValidationError{ field: "LdsConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetCdsConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Bootstrap_DynamicResourcesValidationError{ field: "CdsConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetAdsConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Bootstrap_DynamicResourcesValidationError{ field: "AdsConfig", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "Bootstrap_DynamicResources", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLdsConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "Bootstrap_DynamicResourcesValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetCdsConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "Bootstrap_DynamicResourcesValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetAdsConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "Bootstrap_DynamicResourcesValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on Bootstrap_DynamicResources with the // rules defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "Bootstrap_DynamicResources", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/bootstrap/v2/bootstrap.pb.validate.go#L828-L879
147,201
envoyproxy/go-control-plane
pkg/server/server.go
NewServer
func NewServer(config cache.Cache, callbacks Callbacks) Server { return &server{cache: config, callbacks: callbacks} }
go
func NewServer(config cache.Cache, callbacks Callbacks) Server { return &server{cache: config, callbacks: callbacks} }
[ "func", "NewServer", "(", "config", "cache", ".", "Cache", ",", "callbacks", "Callbacks", ")", "Server", "{", "return", "&", "server", "{", "cache", ":", "config", ",", "callbacks", ":", "callbacks", "}", "\n", "}" ]
// NewServer creates handlers from a config watcher and callbacks.
[ "NewServer", "creates", "handlers", "from", "a", "config", "watcher", "and", "callbacks", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/server/server.go#L69-L71
147,202
envoyproxy/go-control-plane
pkg/server/server.go
Cancel
func (values watches) Cancel() { if values.endpointCancel != nil { values.endpointCancel() } if values.clusterCancel != nil { values.clusterCancel() } if values.routeCancel != nil { values.routeCancel() } if values.listenerCancel != nil { values.listenerCancel() } if values.secretCancel != nil { values.secretCancel() } }
go
func (values watches) Cancel() { if values.endpointCancel != nil { values.endpointCancel() } if values.clusterCancel != nil { values.clusterCancel() } if values.routeCancel != nil { values.routeCancel() } if values.listenerCancel != nil { values.listenerCancel() } if values.secretCancel != nil { values.secretCancel() } }
[ "func", "(", "values", "watches", ")", "Cancel", "(", ")", "{", "if", "values", ".", "endpointCancel", "!=", "nil", "{", "values", ".", "endpointCancel", "(", ")", "\n", "}", "\n", "if", "values", ".", "clusterCancel", "!=", "nil", "{", "values", ".", "clusterCancel", "(", ")", "\n", "}", "\n", "if", "values", ".", "routeCancel", "!=", "nil", "{", "values", ".", "routeCancel", "(", ")", "\n", "}", "\n", "if", "values", ".", "listenerCancel", "!=", "nil", "{", "values", ".", "listenerCancel", "(", ")", "\n", "}", "\n", "if", "values", ".", "secretCancel", "!=", "nil", "{", "values", ".", "secretCancel", "(", ")", "\n", "}", "\n", "}" ]
// Cancel all watches
[ "Cancel", "all", "watches" ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/server/server.go#L110-L126
147,203
envoyproxy/go-control-plane
pkg/server/server.go
handler
func (s *server) handler(stream stream, typeURL string) error { // a channel for receiving incoming requests reqCh := make(chan *v2.DiscoveryRequest) reqStop := int32(0) go func() { for { req, err := stream.Recv() if atomic.LoadInt32(&reqStop) != 0 { return } if err != nil { close(reqCh) return } reqCh <- req } }() err := s.process(stream, reqCh, typeURL) // prevents writing to a closed channel if send failed on blocked recv // TODO(kuat) figure out how to unblock recv through gRPC API atomic.StoreInt32(&reqStop, 1) return err }
go
func (s *server) handler(stream stream, typeURL string) error { // a channel for receiving incoming requests reqCh := make(chan *v2.DiscoveryRequest) reqStop := int32(0) go func() { for { req, err := stream.Recv() if atomic.LoadInt32(&reqStop) != 0 { return } if err != nil { close(reqCh) return } reqCh <- req } }() err := s.process(stream, reqCh, typeURL) // prevents writing to a closed channel if send failed on blocked recv // TODO(kuat) figure out how to unblock recv through gRPC API atomic.StoreInt32(&reqStop, 1) return err }
[ "func", "(", "s", "*", "server", ")", "handler", "(", "stream", "stream", ",", "typeURL", "string", ")", "error", "{", "// a channel for receiving incoming requests", "reqCh", ":=", "make", "(", "chan", "*", "v2", ".", "DiscoveryRequest", ")", "\n", "reqStop", ":=", "int32", "(", "0", ")", "\n", "go", "func", "(", ")", "{", "for", "{", "req", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "atomic", ".", "LoadInt32", "(", "&", "reqStop", ")", "!=", "0", "{", "return", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "close", "(", "reqCh", ")", "\n", "return", "\n", "}", "\n", "reqCh", "<-", "req", "\n", "}", "\n", "}", "(", ")", "\n\n", "err", ":=", "s", ".", "process", "(", "stream", ",", "reqCh", ",", "typeURL", ")", "\n\n", "// prevents writing to a closed channel if send failed on blocked recv", "// TODO(kuat) figure out how to unblock recv through gRPC API", "atomic", ".", "StoreInt32", "(", "&", "reqStop", ",", "1", ")", "\n\n", "return", "err", "\n", "}" ]
// handler converts a blocking read call to channels and initiates stream processing
[ "handler", "converts", "a", "blocking", "read", "call", "to", "channels", "and", "initiates", "stream", "processing" ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/server/server.go#L304-L329
147,204
envoyproxy/go-control-plane
pkg/server/server.go
Fetch
func (s *server) Fetch(ctx context.Context, req *v2.DiscoveryRequest) (*v2.DiscoveryResponse, error) { if s.callbacks != nil { if err := s.callbacks.OnFetchRequest(ctx, req); err != nil { return nil, err } } resp, err := s.cache.Fetch(ctx, *req) if err != nil { return nil, err } out, err := createResponse(resp, req.TypeUrl) if s.callbacks != nil { s.callbacks.OnFetchResponse(req, out) } return out, err }
go
func (s *server) Fetch(ctx context.Context, req *v2.DiscoveryRequest) (*v2.DiscoveryResponse, error) { if s.callbacks != nil { if err := s.callbacks.OnFetchRequest(ctx, req); err != nil { return nil, err } } resp, err := s.cache.Fetch(ctx, *req) if err != nil { return nil, err } out, err := createResponse(resp, req.TypeUrl) if s.callbacks != nil { s.callbacks.OnFetchResponse(req, out) } return out, err }
[ "func", "(", "s", "*", "server", ")", "Fetch", "(", "ctx", "context", ".", "Context", ",", "req", "*", "v2", ".", "DiscoveryRequest", ")", "(", "*", "v2", ".", "DiscoveryResponse", ",", "error", ")", "{", "if", "s", ".", "callbacks", "!=", "nil", "{", "if", "err", ":=", "s", ".", "callbacks", ".", "OnFetchRequest", "(", "ctx", ",", "req", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "resp", ",", "err", ":=", "s", ".", "cache", ".", "Fetch", "(", "ctx", ",", "*", "req", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "out", ",", "err", ":=", "createResponse", "(", "resp", ",", "req", ".", "TypeUrl", ")", "\n", "if", "s", ".", "callbacks", "!=", "nil", "{", "s", ".", "callbacks", ".", "OnFetchResponse", "(", "req", ",", "out", ")", "\n", "}", "\n", "return", "out", ",", "err", "\n", "}" ]
// Fetch is the universal fetch method.
[ "Fetch", "is", "the", "universal", "fetch", "method", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/server/server.go#L356-L371
147,205
envoyproxy/go-control-plane
envoy/api/v2/core/grpc_service.pb.validate.go
Validate
func (m *GrpcService) Validate() error { if m == nil { return nil } { tmp := m.GetTimeout() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: "Timeout", reason: "embedded message failed validation", cause: err, } } } } for idx, item := range m.GetInitialMetadata() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: fmt.Sprintf("InitialMetadata[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } switch m.TargetSpecifier.(type) { case *GrpcService_EnvoyGrpc_: { tmp := m.GetEnvoyGrpc() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: "EnvoyGrpc", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_: { tmp := m.GetGoogleGrpc() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: "GoogleGrpc", reason: "embedded message failed validation", cause: err, } } } } default: return GrpcServiceValidationError{ field: "TargetSpecifier", reason: "value is required", } } return nil }
go
func (m *GrpcService) Validate() error { if m == nil { return nil } { tmp := m.GetTimeout() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: "Timeout", reason: "embedded message failed validation", cause: err, } } } } for idx, item := range m.GetInitialMetadata() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: fmt.Sprintf("InitialMetadata[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } switch m.TargetSpecifier.(type) { case *GrpcService_EnvoyGrpc_: { tmp := m.GetEnvoyGrpc() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: "EnvoyGrpc", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_: { tmp := m.GetGoogleGrpc() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcServiceValidationError{ field: "GoogleGrpc", reason: "embedded message failed validation", cause: err, } } } } default: return GrpcServiceValidationError{ field: "TargetSpecifier", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "GrpcService", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetTimeout", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcServiceValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetInitialMetadata", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcServiceValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "switch", "m", ".", "TargetSpecifier", ".", "(", "type", ")", "{", "case", "*", "GrpcService_EnvoyGrpc_", ":", "{", "tmp", ":=", "m", ".", "GetEnvoyGrpc", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcServiceValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "GrpcService_GoogleGrpc_", ":", "{", "tmp", ":=", "m", ".", "GetGoogleGrpc", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcServiceValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "default", ":", "return", "GrpcServiceValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on GrpcService with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcService", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/core/grpc_service.pb.validate.go#L39-L124
147,206
envoyproxy/go-control-plane
envoy/api/v2/core/grpc_service.pb.validate.go
Validate
func (m *GrpcService_EnvoyGrpc) Validate() error { if m == nil { return nil } if len(m.GetClusterName()) < 1 { return GrpcService_EnvoyGrpcValidationError{ field: "ClusterName", reason: "value length must be at least 1 bytes", } } return nil }
go
func (m *GrpcService_EnvoyGrpc) Validate() error { if m == nil { return nil } if len(m.GetClusterName()) < 1 { return GrpcService_EnvoyGrpcValidationError{ field: "ClusterName", reason: "value length must be at least 1 bytes", } } return nil }
[ "func", "(", "m", "*", "GrpcService_EnvoyGrpc", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetClusterName", "(", ")", ")", "<", "1", "{", "return", "GrpcService_EnvoyGrpcValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on GrpcService_EnvoyGrpc with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcService_EnvoyGrpc", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/core/grpc_service.pb.validate.go#L183-L196
147,207
envoyproxy/go-control-plane
envoy/api/v2/core/grpc_service.pb.validate.go
Validate
func (m *GrpcService_GoogleGrpc) Validate() error { if m == nil { return nil } if len(m.GetTargetUri()) < 1 { return GrpcService_GoogleGrpcValidationError{ field: "TargetUri", reason: "value length must be at least 1 bytes", } } { tmp := m.GetChannelCredentials() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpcValidationError{ field: "ChannelCredentials", reason: "embedded message failed validation", cause: err, } } } } for idx, item := range m.GetCallCredentials() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpcValidationError{ field: fmt.Sprintf("CallCredentials[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } if len(m.GetStatPrefix()) < 1 { return GrpcService_GoogleGrpcValidationError{ field: "StatPrefix", reason: "value length must be at least 1 bytes", } } // no validation rules for CredentialsFactoryName { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpcValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *GrpcService_GoogleGrpc) Validate() error { if m == nil { return nil } if len(m.GetTargetUri()) < 1 { return GrpcService_GoogleGrpcValidationError{ field: "TargetUri", reason: "value length must be at least 1 bytes", } } { tmp := m.GetChannelCredentials() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpcValidationError{ field: "ChannelCredentials", reason: "embedded message failed validation", cause: err, } } } } for idx, item := range m.GetCallCredentials() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpcValidationError{ field: fmt.Sprintf("CallCredentials[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } if len(m.GetStatPrefix()) < 1 { return GrpcService_GoogleGrpcValidationError{ field: "StatPrefix", reason: "value length must be at least 1 bytes", } } // no validation rules for CredentialsFactoryName { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpcValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "GrpcService_GoogleGrpc", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetTargetUri", "(", ")", ")", "<", "1", "{", "return", "GrpcService_GoogleGrpcValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetChannelCredentials", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpcValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetCallCredentials", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpcValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetStatPrefix", "(", ")", ")", "<", "1", "{", "return", "GrpcService_GoogleGrpcValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "// no validation rules for CredentialsFactoryName", "{", "tmp", ":=", "m", ".", "GetConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpcValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on GrpcService_GoogleGrpc with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcService_GoogleGrpc", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/core/grpc_service.pb.validate.go#L257-L329
147,208
envoyproxy/go-control-plane
envoy/api/v2/core/grpc_service.pb.validate.go
Validate
func (m *GrpcService_GoogleGrpc_SslCredentials) Validate() error { if m == nil { return nil } { tmp := m.GetRootCerts() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_SslCredentialsValidationError{ field: "RootCerts", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetPrivateKey() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_SslCredentialsValidationError{ field: "PrivateKey", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetCertChain() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_SslCredentialsValidationError{ field: "CertChain", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *GrpcService_GoogleGrpc_SslCredentials) Validate() error { if m == nil { return nil } { tmp := m.GetRootCerts() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_SslCredentialsValidationError{ field: "RootCerts", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetPrivateKey() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_SslCredentialsValidationError{ field: "PrivateKey", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetCertChain() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_SslCredentialsValidationError{ field: "CertChain", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "GrpcService_GoogleGrpc_SslCredentials", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetRootCerts", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_SslCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetPrivateKey", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_SslCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetCertChain", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_SslCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on GrpcService_GoogleGrpc_SslCredentials // with the rules defined in the proto definition for this message. If any // rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcService_GoogleGrpc_SslCredentials", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/core/grpc_service.pb.validate.go#L390-L441
147,209
envoyproxy/go-control-plane
envoy/api/v2/core/grpc_service.pb.validate.go
Validate
func (m *GrpcService_GoogleGrpc_ChannelCredentials) Validate() error { if m == nil { return nil } switch m.CredentialSpecifier.(type) { case *GrpcService_GoogleGrpc_ChannelCredentials_SslCredentials: { tmp := m.GetSslCredentials() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "SslCredentials", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_ChannelCredentials_GoogleDefault: { tmp := m.GetGoogleDefault() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "GoogleDefault", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_ChannelCredentials_LocalCredentials: { tmp := m.GetLocalCredentials() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "LocalCredentials", reason: "embedded message failed validation", cause: err, } } } } default: return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "CredentialSpecifier", reason: "value is required", } } return nil }
go
func (m *GrpcService_GoogleGrpc_ChannelCredentials) Validate() error { if m == nil { return nil } switch m.CredentialSpecifier.(type) { case *GrpcService_GoogleGrpc_ChannelCredentials_SslCredentials: { tmp := m.GetSslCredentials() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "SslCredentials", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_ChannelCredentials_GoogleDefault: { tmp := m.GetGoogleDefault() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "GoogleDefault", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_ChannelCredentials_LocalCredentials: { tmp := m.GetLocalCredentials() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "LocalCredentials", reason: "embedded message failed validation", cause: err, } } } } default: return GrpcService_GoogleGrpc_ChannelCredentialsValidationError{ field: "CredentialSpecifier", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "GrpcService_GoogleGrpc_ChannelCredentials", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "switch", "m", ".", "CredentialSpecifier", ".", "(", "type", ")", "{", "case", "*", "GrpcService_GoogleGrpc_ChannelCredentials_SslCredentials", ":", "{", "tmp", ":=", "m", ".", "GetSslCredentials", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_ChannelCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "GrpcService_GoogleGrpc_ChannelCredentials_GoogleDefault", ":", "{", "tmp", ":=", "m", ".", "GetGoogleDefault", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_ChannelCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "GrpcService_GoogleGrpc_ChannelCredentials_LocalCredentials", ":", "{", "tmp", ":=", "m", ".", "GetLocalCredentials", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_ChannelCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "default", ":", "return", "GrpcService_GoogleGrpc_ChannelCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on // GrpcService_GoogleGrpc_ChannelCredentials with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcService_GoogleGrpc_ChannelCredentials", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/core/grpc_service.pb.validate.go#L572-L639
147,210
envoyproxy/go-control-plane
envoy/api/v2/core/grpc_service.pb.validate.go
Validate
func (m *GrpcService_GoogleGrpc_CallCredentials) Validate() error { if m == nil { return nil } switch m.CredentialSpecifier.(type) { case *GrpcService_GoogleGrpc_CallCredentials_AccessToken: // no validation rules for AccessToken case *GrpcService_GoogleGrpc_CallCredentials_GoogleComputeEngine: { tmp := m.GetGoogleComputeEngine() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "GoogleComputeEngine", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_GoogleRefreshToken: // no validation rules for GoogleRefreshToken case *GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJwtAccess: { tmp := m.GetServiceAccountJwtAccess() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "ServiceAccountJwtAccess", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_GoogleIam: { tmp := m.GetGoogleIam() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "GoogleIam", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_FromPlugin: { tmp := m.GetFromPlugin() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "FromPlugin", reason: "embedded message failed validation", cause: err, } } } } default: return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "CredentialSpecifier", reason: "value is required", } } return nil }
go
func (m *GrpcService_GoogleGrpc_CallCredentials) Validate() error { if m == nil { return nil } switch m.CredentialSpecifier.(type) { case *GrpcService_GoogleGrpc_CallCredentials_AccessToken: // no validation rules for AccessToken case *GrpcService_GoogleGrpc_CallCredentials_GoogleComputeEngine: { tmp := m.GetGoogleComputeEngine() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "GoogleComputeEngine", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_GoogleRefreshToken: // no validation rules for GoogleRefreshToken case *GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJwtAccess: { tmp := m.GetServiceAccountJwtAccess() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "ServiceAccountJwtAccess", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_GoogleIam: { tmp := m.GetGoogleIam() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "GoogleIam", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_FromPlugin: { tmp := m.GetFromPlugin() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "FromPlugin", reason: "embedded message failed validation", cause: err, } } } } default: return GrpcService_GoogleGrpc_CallCredentialsValidationError{ field: "CredentialSpecifier", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "GrpcService_GoogleGrpc_CallCredentials", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "switch", "m", ".", "CredentialSpecifier", ".", "(", "type", ")", "{", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_AccessToken", ":", "// no validation rules for AccessToken", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_GoogleComputeEngine", ":", "{", "tmp", ":=", "m", ".", "GetGoogleComputeEngine", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_CallCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_GoogleRefreshToken", ":", "// no validation rules for GoogleRefreshToken", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_ServiceAccountJwtAccess", ":", "{", "tmp", ":=", "m", ".", "GetServiceAccountJwtAccess", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_CallCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_GoogleIam", ":", "{", "tmp", ":=", "m", ".", "GetGoogleIam", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_CallCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_FromPlugin", ":", "{", "tmp", ":=", "m", ".", "GetFromPlugin", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_CallCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "default", ":", "return", "GrpcService_GoogleGrpc_CallCredentialsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on GrpcService_GoogleGrpc_CallCredentials // with the rules defined in the proto definition for this message. If any // rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcService_GoogleGrpc_CallCredentials", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/core/grpc_service.pb.validate.go#L701-L791
147,211
envoyproxy/go-control-plane
envoy/api/v2/core/grpc_service.pb.validate.go
Validate
func (m *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin) Validate() error { if m == nil { return nil } // no validation rules for Name switch m.ConfigType.(type) { case *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_Config: { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_TypedConfig: { tmp := m.GetTypedConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError{ field: "TypedConfig", reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin) Validate() error { if m == nil { return nil } // no validation rules for Name switch m.ConfigType.(type) { case *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_Config: { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } case *GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_TypedConfig: { tmp := m.GetTypedConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError{ field: "TypedConfig", reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for Name", "switch", "m", ".", "ConfigType", ".", "(", "type", ")", "{", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_Config", ":", "{", "tmp", ":=", "m", ".", "GetConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin_TypedConfig", ":", "{", "tmp", ":=", "m", ".", "GetTypedConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPluginValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on // GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin with // the rules defined in the proto definition for this message. If any rules // are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcService_GoogleGrpc_CallCredentials_MetadataCredentialsFromPlugin", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/core/grpc_service.pb.validate.go#L1018-L1064
147,212
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *ConfigDump) Validate() error { if m == nil { return nil } for idx, item := range m.GetConfigs() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ConfigDumpValidationError{ field: fmt.Sprintf("Configs[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *ConfigDump) Validate() error { if m == nil { return nil } for idx, item := range m.GetConfigs() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ConfigDumpValidationError{ field: fmt.Sprintf("Configs[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "ConfigDump", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetConfigs", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ConfigDump with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ConfigDump", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L38-L64
147,213
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *BootstrapConfigDump) Validate() error { if m == nil { return nil } { tmp := m.GetBootstrap() if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapConfigDumpValidationError{ field: "Bootstrap", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapConfigDumpValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *BootstrapConfigDump) Validate() error { if m == nil { return nil } { tmp := m.GetBootstrap() if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapConfigDumpValidationError{ field: "Bootstrap", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return BootstrapConfigDumpValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "BootstrapConfigDump", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetBootstrap", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "BootstrapConfigDumpValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLastUpdated", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "BootstrapConfigDumpValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on BootstrapConfigDump with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "BootstrapConfigDump", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L123-L159
147,214
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *ListenersConfigDump) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo for idx, item := range m.GetStaticListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("StaticListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicActiveListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("DynamicActiveListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicWarmingListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("DynamicWarmingListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicDrainingListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("DynamicDrainingListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *ListenersConfigDump) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo for idx, item := range m.GetStaticListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("StaticListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicActiveListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("DynamicActiveListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicWarmingListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("DynamicWarmingListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicDrainingListeners() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDumpValidationError{ field: fmt.Sprintf("DynamicDrainingListeners[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "ListenersConfigDump", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for VersionInfo", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetStaticListeners", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetDynamicActiveListeners", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetDynamicWarmingListeners", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetDynamicDrainingListeners", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ListenersConfigDump with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ListenersConfigDump", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L220-L308
147,215
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *ClustersConfigDump) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo for idx, item := range m.GetStaticClusters() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDumpValidationError{ field: fmt.Sprintf("StaticClusters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicActiveClusters() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDumpValidationError{ field: fmt.Sprintf("DynamicActiveClusters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicWarmingClusters() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDumpValidationError{ field: fmt.Sprintf("DynamicWarmingClusters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *ClustersConfigDump) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo for idx, item := range m.GetStaticClusters() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDumpValidationError{ field: fmt.Sprintf("StaticClusters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicActiveClusters() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDumpValidationError{ field: fmt.Sprintf("DynamicActiveClusters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicWarmingClusters() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDumpValidationError{ field: fmt.Sprintf("DynamicWarmingClusters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "ClustersConfigDump", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for VersionInfo", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetStaticClusters", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClustersConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetDynamicActiveClusters", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClustersConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetDynamicWarmingClusters", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClustersConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ClustersConfigDump with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ClustersConfigDump", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L369-L437
147,216
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *RoutesConfigDump) Validate() error { if m == nil { return nil } for idx, item := range m.GetStaticRouteConfigs() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDumpValidationError{ field: fmt.Sprintf("StaticRouteConfigs[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicRouteConfigs() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDumpValidationError{ field: fmt.Sprintf("DynamicRouteConfigs[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *RoutesConfigDump) Validate() error { if m == nil { return nil } for idx, item := range m.GetStaticRouteConfigs() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDumpValidationError{ field: fmt.Sprintf("StaticRouteConfigs[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetDynamicRouteConfigs() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDumpValidationError{ field: fmt.Sprintf("DynamicRouteConfigs[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "RoutesConfigDump", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetStaticRouteConfigs", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RoutesConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetDynamicRouteConfigs", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RoutesConfigDumpValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on RoutesConfigDump with the rules defined // in the proto definition for this message. If any rules are violated, an // error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "RoutesConfigDump", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L498-L544
147,217
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *ListenersConfigDump_StaticListener) Validate() error { if m == nil { return nil } { tmp := m.GetListener() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_StaticListenerValidationError{ field: "Listener", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_StaticListenerValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *ListenersConfigDump_StaticListener) Validate() error { if m == nil { return nil } { tmp := m.GetListener() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_StaticListenerValidationError{ field: "Listener", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_StaticListenerValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "ListenersConfigDump_StaticListener", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetListener", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDump_StaticListenerValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLastUpdated", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDump_StaticListenerValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ListenersConfigDump_StaticListener with // the rules defined in the proto definition for this message. If any rules // are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ListenersConfigDump_StaticListener", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L603-L639
147,218
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *ListenersConfigDump_DynamicListener) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo { tmp := m.GetListener() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_DynamicListenerValidationError{ field: "Listener", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_DynamicListenerValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *ListenersConfigDump_DynamicListener) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo { tmp := m.GetListener() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_DynamicListenerValidationError{ field: "Listener", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ListenersConfigDump_DynamicListenerValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "ListenersConfigDump_DynamicListener", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for VersionInfo", "{", "tmp", ":=", "m", ".", "GetListener", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDump_DynamicListenerValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLastUpdated", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ListenersConfigDump_DynamicListenerValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ListenersConfigDump_DynamicListener with // the rules defined in the proto definition for this message. If any rules // are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ListenersConfigDump_DynamicListener", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L701-L739
147,219
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *ClustersConfigDump_StaticCluster) Validate() error { if m == nil { return nil } { tmp := m.GetCluster() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_StaticClusterValidationError{ field: "Cluster", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_StaticClusterValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *ClustersConfigDump_StaticCluster) Validate() error { if m == nil { return nil } { tmp := m.GetCluster() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_StaticClusterValidationError{ field: "Cluster", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_StaticClusterValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "ClustersConfigDump_StaticCluster", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetCluster", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClustersConfigDump_StaticClusterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLastUpdated", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClustersConfigDump_StaticClusterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ClustersConfigDump_StaticCluster with // the rules defined in the proto definition for this message. If any rules // are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ClustersConfigDump_StaticCluster", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L801-L837
147,220
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *ClustersConfigDump_DynamicCluster) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo { tmp := m.GetCluster() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_DynamicClusterValidationError{ field: "Cluster", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_DynamicClusterValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *ClustersConfigDump_DynamicCluster) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo { tmp := m.GetCluster() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_DynamicClusterValidationError{ field: "Cluster", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClustersConfigDump_DynamicClusterValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "ClustersConfigDump_DynamicCluster", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for VersionInfo", "{", "tmp", ":=", "m", ".", "GetCluster", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClustersConfigDump_DynamicClusterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLastUpdated", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClustersConfigDump_DynamicClusterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ClustersConfigDump_DynamicCluster with // the rules defined in the proto definition for this message. If any rules // are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ClustersConfigDump_DynamicCluster", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L899-L937
147,221
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *RoutesConfigDump_StaticRouteConfig) Validate() error { if m == nil { return nil } { tmp := m.GetRouteConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_StaticRouteConfigValidationError{ field: "RouteConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_StaticRouteConfigValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *RoutesConfigDump_StaticRouteConfig) Validate() error { if m == nil { return nil } { tmp := m.GetRouteConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_StaticRouteConfigValidationError{ field: "RouteConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_StaticRouteConfigValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "RoutesConfigDump_StaticRouteConfig", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetRouteConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RoutesConfigDump_StaticRouteConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLastUpdated", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RoutesConfigDump_StaticRouteConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on RoutesConfigDump_StaticRouteConfig with // the rules defined in the proto definition for this message. If any rules // are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "RoutesConfigDump_StaticRouteConfig", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L999-L1035
147,222
envoyproxy/go-control-plane
envoy/admin/v2alpha/config_dump.pb.validate.go
Validate
func (m *RoutesConfigDump_DynamicRouteConfig) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo { tmp := m.GetRouteConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_DynamicRouteConfigValidationError{ field: "RouteConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_DynamicRouteConfigValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *RoutesConfigDump_DynamicRouteConfig) Validate() error { if m == nil { return nil } // no validation rules for VersionInfo { tmp := m.GetRouteConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_DynamicRouteConfigValidationError{ field: "RouteConfig", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetLastUpdated() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RoutesConfigDump_DynamicRouteConfigValidationError{ field: "LastUpdated", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "RoutesConfigDump_DynamicRouteConfig", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for VersionInfo", "{", "tmp", ":=", "m", ".", "GetRouteConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RoutesConfigDump_DynamicRouteConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetLastUpdated", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RoutesConfigDump_DynamicRouteConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on RoutesConfigDump_DynamicRouteConfig with // the rules defined in the proto definition for this message. If any rules // are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "RoutesConfigDump_DynamicRouteConfig", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/config_dump.pb.validate.go#L1097-L1135
147,223
envoyproxy/go-control-plane
envoy/admin/v2alpha/certs.pb.validate.go
Validate
func (m *Certificates) Validate() error { if m == nil { return nil } for idx, item := range m.GetCertificates() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificatesValidationError{ field: fmt.Sprintf("Certificates[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *Certificates) Validate() error { if m == nil { return nil } for idx, item := range m.GetCertificates() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificatesValidationError{ field: fmt.Sprintf("Certificates[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "Certificates", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetCertificates", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "CertificatesValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on Certificates with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "Certificates", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/certs.pb.validate.go#L39-L65
147,224
envoyproxy/go-control-plane
envoy/admin/v2alpha/certs.pb.validate.go
Validate
func (m *Certificate) Validate() error { if m == nil { return nil } for idx, item := range m.GetCaCert() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateValidationError{ field: fmt.Sprintf("CaCert[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetCertChain() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateValidationError{ field: fmt.Sprintf("CertChain[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *Certificate) Validate() error { if m == nil { return nil } for idx, item := range m.GetCaCert() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateValidationError{ field: fmt.Sprintf("CaCert[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } for idx, item := range m.GetCertChain() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateValidationError{ field: fmt.Sprintf("CertChain[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "Certificate", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetCaCert", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "CertificateValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetCertChain", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "CertificateValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on Certificate with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "Certificate", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/certs.pb.validate.go#L124-L170
147,225
envoyproxy/go-control-plane
envoy/admin/v2alpha/certs.pb.validate.go
Validate
func (m *CertificateDetails) Validate() error { if m == nil { return nil } // no validation rules for Path // no validation rules for SerialNumber for idx, item := range m.GetSubjectAltNames() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateDetailsValidationError{ field: fmt.Sprintf("SubjectAltNames[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } // no validation rules for DaysUntilExpiration { tmp := m.GetValidFrom() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateDetailsValidationError{ field: "ValidFrom", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetExpirationTime() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateDetailsValidationError{ field: "ExpirationTime", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *CertificateDetails) Validate() error { if m == nil { return nil } // no validation rules for Path // no validation rules for SerialNumber for idx, item := range m.GetSubjectAltNames() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateDetailsValidationError{ field: fmt.Sprintf("SubjectAltNames[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } // no validation rules for DaysUntilExpiration { tmp := m.GetValidFrom() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateDetailsValidationError{ field: "ValidFrom", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetExpirationTime() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return CertificateDetailsValidationError{ field: "ExpirationTime", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "CertificateDetails", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for Path", "// no validation rules for SerialNumber", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetSubjectAltNames", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "CertificateDetailsValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "// no validation rules for DaysUntilExpiration", "{", "tmp", ":=", "m", ".", "GetValidFrom", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "CertificateDetailsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetExpirationTime", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "CertificateDetailsValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on CertificateDetails with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "CertificateDetails", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/certs.pb.validate.go#L229-L291
147,226
envoyproxy/go-control-plane
envoy/admin/v2alpha/certs.pb.validate.go
Validate
func (m *SubjectAlternateName) Validate() error { if m == nil { return nil } switch m.Name.(type) { case *SubjectAlternateName_Dns: // no validation rules for Dns case *SubjectAlternateName_Uri: // no validation rules for Uri } return nil }
go
func (m *SubjectAlternateName) Validate() error { if m == nil { return nil } switch m.Name.(type) { case *SubjectAlternateName_Dns: // no validation rules for Dns case *SubjectAlternateName_Uri: // no validation rules for Uri } return nil }
[ "func", "(", "m", "*", "SubjectAlternateName", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "switch", "m", ".", "Name", ".", "(", "type", ")", "{", "case", "*", "SubjectAlternateName_Dns", ":", "// no validation rules for Dns", "case", "*", "SubjectAlternateName_Uri", ":", "// no validation rules for Uri", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on SubjectAlternateName with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "SubjectAlternateName", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/admin/v2alpha/certs.pb.validate.go#L352-L368
147,227
envoyproxy/go-control-plane
envoy/api/v2/lds.pb.validate.go
Validate
func (m *Listener_DeprecatedV1) Validate() error { if m == nil { return nil } { tmp := m.GetBindToPort() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Listener_DeprecatedV1ValidationError{ field: "BindToPort", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *Listener_DeprecatedV1) Validate() error { if m == nil { return nil } { tmp := m.GetBindToPort() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return Listener_DeprecatedV1ValidationError{ field: "BindToPort", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "Listener_DeprecatedV1", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetBindToPort", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "Listener_DeprecatedV1ValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on Listener_DeprecatedV1 with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "Listener_DeprecatedV1", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/lds.pb.validate.go#L309-L330
147,228
envoyproxy/go-control-plane
envoy/api/v2/eds.pb.validate.go
Validate
func (m *ClusterLoadAssignment) Validate() error { if m == nil { return nil } if len(m.GetClusterName()) < 1 { return ClusterLoadAssignmentValidationError{ field: "ClusterName", reason: "value length must be at least 1 bytes", } } for idx, item := range m.GetEndpoints() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignmentValidationError{ field: fmt.Sprintf("Endpoints[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } // no validation rules for NamedEndpoints { tmp := m.GetPolicy() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignmentValidationError{ field: "Policy", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *ClusterLoadAssignment) Validate() error { if m == nil { return nil } if len(m.GetClusterName()) < 1 { return ClusterLoadAssignmentValidationError{ field: "ClusterName", reason: "value length must be at least 1 bytes", } } for idx, item := range m.GetEndpoints() { _, _ = idx, item { tmp := item if v, ok := interface{}(&tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignmentValidationError{ field: fmt.Sprintf("Endpoints[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } // no validation rules for NamedEndpoints { tmp := m.GetPolicy() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignmentValidationError{ field: "Policy", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "ClusterLoadAssignment", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetClusterName", "(", ")", ")", "<", "1", "{", "return", "ClusterLoadAssignmentValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetEndpoints", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "&", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClusterLoadAssignmentValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "// no validation rules for NamedEndpoints", "{", "tmp", ":=", "m", ".", "GetPolicy", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClusterLoadAssignmentValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ClusterLoadAssignment with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ClusterLoadAssignment", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/eds.pb.validate.go#L39-L89
147,229
envoyproxy/go-control-plane
envoy/api/v2/eds.pb.validate.go
Validate
func (m *ClusterLoadAssignment_Policy) Validate() error { if m == nil { return nil } for idx, item := range m.GetDropOverloads() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignment_PolicyValidationError{ field: fmt.Sprintf("DropOverloads[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } if wrapper := m.GetOverprovisioningFactor(); wrapper != nil { if wrapper.GetValue() <= 0 { return ClusterLoadAssignment_PolicyValidationError{ field: "OverprovisioningFactor", reason: "value must be greater than 0", } } } if d := m.GetEndpointStaleAfter(); d != nil { dur, err := types.DurationFromProto(d) if err != nil { return ClusterLoadAssignment_PolicyValidationError{ field: "EndpointStaleAfter", reason: "value is not a valid duration", cause: err, } } gt := time.Duration(0*time.Second + 0*time.Nanosecond) if dur <= gt { return ClusterLoadAssignment_PolicyValidationError{ field: "EndpointStaleAfter", reason: "value must be greater than 0s", } } } return nil }
go
func (m *ClusterLoadAssignment_Policy) Validate() error { if m == nil { return nil } for idx, item := range m.GetDropOverloads() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignment_PolicyValidationError{ field: fmt.Sprintf("DropOverloads[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } if wrapper := m.GetOverprovisioningFactor(); wrapper != nil { if wrapper.GetValue() <= 0 { return ClusterLoadAssignment_PolicyValidationError{ field: "OverprovisioningFactor", reason: "value must be greater than 0", } } } if d := m.GetEndpointStaleAfter(); d != nil { dur, err := types.DurationFromProto(d) if err != nil { return ClusterLoadAssignment_PolicyValidationError{ field: "EndpointStaleAfter", reason: "value is not a valid duration", cause: err, } } gt := time.Duration(0*time.Second + 0*time.Nanosecond) if dur <= gt { return ClusterLoadAssignment_PolicyValidationError{ field: "EndpointStaleAfter", reason: "value must be greater than 0s", } } } return nil }
[ "func", "(", "m", "*", "ClusterLoadAssignment_Policy", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetDropOverloads", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClusterLoadAssignment_PolicyValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "if", "wrapper", ":=", "m", ".", "GetOverprovisioningFactor", "(", ")", ";", "wrapper", "!=", "nil", "{", "if", "wrapper", ".", "GetValue", "(", ")", "<=", "0", "{", "return", "ClusterLoadAssignment_PolicyValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "}", "\n\n", "if", "d", ":=", "m", ".", "GetEndpointStaleAfter", "(", ")", ";", "d", "!=", "nil", "{", "dur", ",", "err", ":=", "types", ".", "DurationFromProto", "(", "d", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ClusterLoadAssignment_PolicyValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n\n", "gt", ":=", "time", ".", "Duration", "(", "0", "*", "time", ".", "Second", "+", "0", "*", "time", ".", "Nanosecond", ")", "\n\n", "if", "dur", "<=", "gt", "{", "return", "ClusterLoadAssignment_PolicyValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ClusterLoadAssignment_Policy with the // rules defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ClusterLoadAssignment_Policy", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/eds.pb.validate.go#L150-L208
147,230
envoyproxy/go-control-plane
envoy/api/v2/eds.pb.validate.go
Validate
func (m *ClusterLoadAssignment_Policy_DropOverload) Validate() error { if m == nil { return nil } if len(m.GetCategory()) < 1 { return ClusterLoadAssignment_Policy_DropOverloadValidationError{ field: "Category", reason: "value length must be at least 1 bytes", } } { tmp := m.GetDropPercentage() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignment_Policy_DropOverloadValidationError{ field: "DropPercentage", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *ClusterLoadAssignment_Policy_DropOverload) Validate() error { if m == nil { return nil } if len(m.GetCategory()) < 1 { return ClusterLoadAssignment_Policy_DropOverloadValidationError{ field: "Category", reason: "value length must be at least 1 bytes", } } { tmp := m.GetDropPercentage() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ClusterLoadAssignment_Policy_DropOverloadValidationError{ field: "DropPercentage", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "ClusterLoadAssignment_Policy_DropOverload", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetCategory", "(", ")", ")", "<", "1", "{", "return", "ClusterLoadAssignment_Policy_DropOverloadValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetDropPercentage", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ClusterLoadAssignment_Policy_DropOverloadValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on // ClusterLoadAssignment_Policy_DropOverload with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ClusterLoadAssignment_Policy_DropOverload", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/api/v2/eds.pb.validate.go#L270-L298
147,231
envoyproxy/go-control-plane
envoy/config/filter/network/mysql_proxy/v1alpha1/mysql_proxy.pb.validate.go
Validate
func (m *MySQLProxy) Validate() error { if m == nil { return nil } if len(m.GetStatPrefix()) < 1 { return MySQLProxyValidationError{ field: "StatPrefix", reason: "value length must be at least 1 bytes", } } // no validation rules for AccessLog return nil }
go
func (m *MySQLProxy) Validate() error { if m == nil { return nil } if len(m.GetStatPrefix()) < 1 { return MySQLProxyValidationError{ field: "StatPrefix", reason: "value length must be at least 1 bytes", } } // no validation rules for AccessLog return nil }
[ "func", "(", "m", "*", "MySQLProxy", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetStatPrefix", "(", ")", ")", "<", "1", "{", "return", "MySQLProxyValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "// no validation rules for AccessLog", "return", "nil", "\n", "}" ]
// Validate checks the field values on MySQLProxy with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "MySQLProxy", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/network/mysql_proxy/v1alpha1/mysql_proxy.pb.validate.go#L38-L53
147,232
envoyproxy/go-control-plane
pkg/cache/simple.go
SetSnapshot
func (cache *snapshotCache) SetSnapshot(node string, snapshot Snapshot) error { cache.mu.Lock() defer cache.mu.Unlock() // update the existing entry cache.snapshots[node] = snapshot // trigger existing watches for which version changed if info, ok := cache.status[node]; ok { info.mu.Lock() for id, watch := range info.watches { version := snapshot.GetVersion(watch.Request.TypeUrl) if version != watch.Request.VersionInfo { if cache.log != nil { cache.log.Infof("respond open watch %d%v with new version %q", id, watch.Request.ResourceNames, version) } cache.respond(watch.Request, watch.Response, snapshot.GetResources(watch.Request.TypeUrl), version) // discard the watch delete(info.watches, id) } } info.mu.Unlock() } return nil }
go
func (cache *snapshotCache) SetSnapshot(node string, snapshot Snapshot) error { cache.mu.Lock() defer cache.mu.Unlock() // update the existing entry cache.snapshots[node] = snapshot // trigger existing watches for which version changed if info, ok := cache.status[node]; ok { info.mu.Lock() for id, watch := range info.watches { version := snapshot.GetVersion(watch.Request.TypeUrl) if version != watch.Request.VersionInfo { if cache.log != nil { cache.log.Infof("respond open watch %d%v with new version %q", id, watch.Request.ResourceNames, version) } cache.respond(watch.Request, watch.Response, snapshot.GetResources(watch.Request.TypeUrl), version) // discard the watch delete(info.watches, id) } } info.mu.Unlock() } return nil }
[ "func", "(", "cache", "*", "snapshotCache", ")", "SetSnapshot", "(", "node", "string", ",", "snapshot", "Snapshot", ")", "error", "{", "cache", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "// update the existing entry", "cache", ".", "snapshots", "[", "node", "]", "=", "snapshot", "\n\n", "// trigger existing watches for which version changed", "if", "info", ",", "ok", ":=", "cache", ".", "status", "[", "node", "]", ";", "ok", "{", "info", ".", "mu", ".", "Lock", "(", ")", "\n", "for", "id", ",", "watch", ":=", "range", "info", ".", "watches", "{", "version", ":=", "snapshot", ".", "GetVersion", "(", "watch", ".", "Request", ".", "TypeUrl", ")", "\n", "if", "version", "!=", "watch", ".", "Request", ".", "VersionInfo", "{", "if", "cache", ".", "log", "!=", "nil", "{", "cache", ".", "log", ".", "Infof", "(", "\"", "\"", ",", "id", ",", "watch", ".", "Request", ".", "ResourceNames", ",", "version", ")", "\n", "}", "\n", "cache", ".", "respond", "(", "watch", ".", "Request", ",", "watch", ".", "Response", ",", "snapshot", ".", "GetResources", "(", "watch", ".", "Request", ".", "TypeUrl", ")", ",", "version", ")", "\n\n", "// discard the watch", "delete", "(", "info", ".", "watches", ",", "id", ")", "\n", "}", "\n", "}", "\n", "info", ".", "mu", ".", "Unlock", "(", ")", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// SetSnapshotCache updates a snapshot for a node.
[ "SetSnapshotCache", "updates", "a", "snapshot", "for", "a", "node", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L100-L126
147,233
envoyproxy/go-control-plane
pkg/cache/simple.go
GetSnapshot
func (cache *snapshotCache) GetSnapshot(node string) (Snapshot, error) { cache.mu.RLock() defer cache.mu.RUnlock() snap, ok := cache.snapshots[node] if !ok { return Snapshot{}, fmt.Errorf("no snapshot found for node %s", node) } return snap, nil }
go
func (cache *snapshotCache) GetSnapshot(node string) (Snapshot, error) { cache.mu.RLock() defer cache.mu.RUnlock() snap, ok := cache.snapshots[node] if !ok { return Snapshot{}, fmt.Errorf("no snapshot found for node %s", node) } return snap, nil }
[ "func", "(", "cache", "*", "snapshotCache", ")", "GetSnapshot", "(", "node", "string", ")", "(", "Snapshot", ",", "error", ")", "{", "cache", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "snap", ",", "ok", ":=", "cache", ".", "snapshots", "[", "node", "]", "\n", "if", "!", "ok", "{", "return", "Snapshot", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "node", ")", "\n", "}", "\n", "return", "snap", ",", "nil", "\n", "}" ]
// GetSnapshots gets the snapshot for a node, and returns an error if not found.
[ "GetSnapshots", "gets", "the", "snapshot", "for", "a", "node", "and", "returns", "an", "error", "if", "not", "found", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L129-L138
147,234
envoyproxy/go-control-plane
pkg/cache/simple.go
ClearSnapshot
func (cache *snapshotCache) ClearSnapshot(node string) { cache.mu.Lock() defer cache.mu.Unlock() delete(cache.snapshots, node) delete(cache.status, node) }
go
func (cache *snapshotCache) ClearSnapshot(node string) { cache.mu.Lock() defer cache.mu.Unlock() delete(cache.snapshots, node) delete(cache.status, node) }
[ "func", "(", "cache", "*", "snapshotCache", ")", "ClearSnapshot", "(", "node", "string", ")", "{", "cache", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "delete", "(", "cache", ".", "snapshots", ",", "node", ")", "\n", "delete", "(", "cache", ".", "status", ",", "node", ")", "\n", "}" ]
// ClearSnapshot clears snapshot and info for a node.
[ "ClearSnapshot", "clears", "snapshot", "and", "info", "for", "a", "node", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L141-L147
147,235
envoyproxy/go-control-plane
pkg/cache/simple.go
nameSet
func nameSet(names []string) map[string]bool { set := make(map[string]bool) for _, name := range names { set[name] = true } return set }
go
func nameSet(names []string) map[string]bool { set := make(map[string]bool) for _, name := range names { set[name] = true } return set }
[ "func", "nameSet", "(", "names", "[", "]", "string", ")", "map", "[", "string", "]", "bool", "{", "set", ":=", "make", "(", "map", "[", "string", "]", "bool", ")", "\n", "for", "_", ",", "name", ":=", "range", "names", "{", "set", "[", "name", "]", "=", "true", "\n", "}", "\n", "return", "set", "\n", "}" ]
// nameSet creates a map from a string slice to value true.
[ "nameSet", "creates", "a", "map", "from", "a", "string", "slice", "to", "value", "true", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L150-L156
147,236
envoyproxy/go-control-plane
pkg/cache/simple.go
superset
func superset(names map[string]bool, resources map[string]Resource) error { for resourceName := range resources { if _, exists := names[resourceName]; !exists { return fmt.Errorf("%q not listed", resourceName) } } return nil }
go
func superset(names map[string]bool, resources map[string]Resource) error { for resourceName := range resources { if _, exists := names[resourceName]; !exists { return fmt.Errorf("%q not listed", resourceName) } } return nil }
[ "func", "superset", "(", "names", "map", "[", "string", "]", "bool", ",", "resources", "map", "[", "string", "]", "Resource", ")", "error", "{", "for", "resourceName", ":=", "range", "resources", "{", "if", "_", ",", "exists", ":=", "names", "[", "resourceName", "]", ";", "!", "exists", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "resourceName", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// superset checks that all resources are listed in the names set.
[ "superset", "checks", "that", "all", "resources", "are", "listed", "in", "the", "names", "set", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L159-L166
147,237
envoyproxy/go-control-plane
pkg/cache/simple.go
CreateWatch
func (cache *snapshotCache) CreateWatch(request Request) (chan Response, func()) { nodeID := cache.hash.ID(request.Node) cache.mu.Lock() defer cache.mu.Unlock() info, ok := cache.status[nodeID] if !ok { info = newStatusInfo(request.Node) cache.status[nodeID] = info } // update last watch request time info.mu.Lock() info.lastWatchRequestTime = time.Now() info.mu.Unlock() // allocate capacity 1 to allow one-time non-blocking use value := make(chan Response, 1) snapshot, exists := cache.snapshots[nodeID] version := snapshot.GetVersion(request.TypeUrl) // if the requested version is up-to-date or missing a response, leave an open watch if !exists || request.VersionInfo == version { watchID := cache.nextWatchID() if cache.log != nil { cache.log.Infof("open watch %d for %s%v from nodeID %q, version %q", watchID, request.TypeUrl, request.ResourceNames, nodeID, request.VersionInfo) } info.mu.Lock() info.watches[watchID] = ResponseWatch{Request: request, Response: value} info.mu.Unlock() return value, cache.cancelWatch(nodeID, watchID) } // otherwise, the watch may be responded immediately cache.respond(request, value, snapshot.GetResources(request.TypeUrl), version) return value, nil }
go
func (cache *snapshotCache) CreateWatch(request Request) (chan Response, func()) { nodeID := cache.hash.ID(request.Node) cache.mu.Lock() defer cache.mu.Unlock() info, ok := cache.status[nodeID] if !ok { info = newStatusInfo(request.Node) cache.status[nodeID] = info } // update last watch request time info.mu.Lock() info.lastWatchRequestTime = time.Now() info.mu.Unlock() // allocate capacity 1 to allow one-time non-blocking use value := make(chan Response, 1) snapshot, exists := cache.snapshots[nodeID] version := snapshot.GetVersion(request.TypeUrl) // if the requested version is up-to-date or missing a response, leave an open watch if !exists || request.VersionInfo == version { watchID := cache.nextWatchID() if cache.log != nil { cache.log.Infof("open watch %d for %s%v from nodeID %q, version %q", watchID, request.TypeUrl, request.ResourceNames, nodeID, request.VersionInfo) } info.mu.Lock() info.watches[watchID] = ResponseWatch{Request: request, Response: value} info.mu.Unlock() return value, cache.cancelWatch(nodeID, watchID) } // otherwise, the watch may be responded immediately cache.respond(request, value, snapshot.GetResources(request.TypeUrl), version) return value, nil }
[ "func", "(", "cache", "*", "snapshotCache", ")", "CreateWatch", "(", "request", "Request", ")", "(", "chan", "Response", ",", "func", "(", ")", ")", "{", "nodeID", ":=", "cache", ".", "hash", ".", "ID", "(", "request", ".", "Node", ")", "\n\n", "cache", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "info", ",", "ok", ":=", "cache", ".", "status", "[", "nodeID", "]", "\n", "if", "!", "ok", "{", "info", "=", "newStatusInfo", "(", "request", ".", "Node", ")", "\n", "cache", ".", "status", "[", "nodeID", "]", "=", "info", "\n", "}", "\n\n", "// update last watch request time", "info", ".", "mu", ".", "Lock", "(", ")", "\n", "info", ".", "lastWatchRequestTime", "=", "time", ".", "Now", "(", ")", "\n", "info", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "// allocate capacity 1 to allow one-time non-blocking use", "value", ":=", "make", "(", "chan", "Response", ",", "1", ")", "\n\n", "snapshot", ",", "exists", ":=", "cache", ".", "snapshots", "[", "nodeID", "]", "\n", "version", ":=", "snapshot", ".", "GetVersion", "(", "request", ".", "TypeUrl", ")", "\n\n", "// if the requested version is up-to-date or missing a response, leave an open watch", "if", "!", "exists", "||", "request", ".", "VersionInfo", "==", "version", "{", "watchID", ":=", "cache", ".", "nextWatchID", "(", ")", "\n", "if", "cache", ".", "log", "!=", "nil", "{", "cache", ".", "log", ".", "Infof", "(", "\"", "\"", ",", "watchID", ",", "request", ".", "TypeUrl", ",", "request", ".", "ResourceNames", ",", "nodeID", ",", "request", ".", "VersionInfo", ")", "\n", "}", "\n", "info", ".", "mu", ".", "Lock", "(", ")", "\n", "info", ".", "watches", "[", "watchID", "]", "=", "ResponseWatch", "{", "Request", ":", "request", ",", "Response", ":", "value", "}", "\n", "info", ".", "mu", ".", "Unlock", "(", ")", "\n", "return", "value", ",", "cache", ".", "cancelWatch", "(", "nodeID", ",", "watchID", ")", "\n", "}", "\n\n", "// otherwise, the watch may be responded immediately", "cache", ".", "respond", "(", "request", ",", "value", ",", "snapshot", ".", "GetResources", "(", "request", ".", "TypeUrl", ")", ",", "version", ")", "\n\n", "return", "value", ",", "nil", "\n", "}" ]
// CreateWatch returns a watch for an xDS request.
[ "CreateWatch", "returns", "a", "watch", "for", "an", "xDS", "request", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L169-L209
147,238
envoyproxy/go-control-plane
pkg/cache/simple.go
cancelWatch
func (cache *snapshotCache) cancelWatch(nodeID string, watchID int64) func() { return func() { // uses the cache mutex cache.mu.Lock() defer cache.mu.Unlock() if info, ok := cache.status[nodeID]; ok { info.mu.Lock() delete(info.watches, watchID) info.mu.Unlock() } } }
go
func (cache *snapshotCache) cancelWatch(nodeID string, watchID int64) func() { return func() { // uses the cache mutex cache.mu.Lock() defer cache.mu.Unlock() if info, ok := cache.status[nodeID]; ok { info.mu.Lock() delete(info.watches, watchID) info.mu.Unlock() } } }
[ "func", "(", "cache", "*", "snapshotCache", ")", "cancelWatch", "(", "nodeID", "string", ",", "watchID", "int64", ")", "func", "(", ")", "{", "return", "func", "(", ")", "{", "// uses the cache mutex", "cache", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "Unlock", "(", ")", "\n", "if", "info", ",", "ok", ":=", "cache", ".", "status", "[", "nodeID", "]", ";", "ok", "{", "info", ".", "mu", ".", "Lock", "(", ")", "\n", "delete", "(", "info", ".", "watches", ",", "watchID", ")", "\n", "info", ".", "mu", ".", "Unlock", "(", ")", "\n", "}", "\n", "}", "\n", "}" ]
// cancellation function for cleaning stale watches
[ "cancellation", "function", "for", "cleaning", "stale", "watches" ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L216-L227
147,239
envoyproxy/go-control-plane
pkg/cache/simple.go
Fetch
func (cache *snapshotCache) Fetch(ctx context.Context, request Request) (*Response, error) { nodeID := cache.hash.ID(request.Node) cache.mu.RLock() defer cache.mu.RUnlock() if snapshot, exists := cache.snapshots[nodeID]; exists { // Respond only if the request version is distinct from the current snapshot state. // It might be beneficial to hold the request since Envoy will re-attempt the refresh. version := snapshot.GetVersion(request.TypeUrl) if request.VersionInfo == version { return nil, errors.New("skip fetch: version up to date") } resources := snapshot.GetResources(request.TypeUrl) out := createResponse(request, resources, version) return &out, nil } return nil, fmt.Errorf("missing snapshot for %q", nodeID) }
go
func (cache *snapshotCache) Fetch(ctx context.Context, request Request) (*Response, error) { nodeID := cache.hash.ID(request.Node) cache.mu.RLock() defer cache.mu.RUnlock() if snapshot, exists := cache.snapshots[nodeID]; exists { // Respond only if the request version is distinct from the current snapshot state. // It might be beneficial to hold the request since Envoy will re-attempt the refresh. version := snapshot.GetVersion(request.TypeUrl) if request.VersionInfo == version { return nil, errors.New("skip fetch: version up to date") } resources := snapshot.GetResources(request.TypeUrl) out := createResponse(request, resources, version) return &out, nil } return nil, fmt.Errorf("missing snapshot for %q", nodeID) }
[ "func", "(", "cache", "*", "snapshotCache", ")", "Fetch", "(", "ctx", "context", ".", "Context", ",", "request", "Request", ")", "(", "*", "Response", ",", "error", ")", "{", "nodeID", ":=", "cache", ".", "hash", ".", "ID", "(", "request", ".", "Node", ")", "\n\n", "cache", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "if", "snapshot", ",", "exists", ":=", "cache", ".", "snapshots", "[", "nodeID", "]", ";", "exists", "{", "// Respond only if the request version is distinct from the current snapshot state.", "// It might be beneficial to hold the request since Envoy will re-attempt the refresh.", "version", ":=", "snapshot", ".", "GetVersion", "(", "request", ".", "TypeUrl", ")", "\n", "if", "request", ".", "VersionInfo", "==", "version", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "resources", ":=", "snapshot", ".", "GetResources", "(", "request", ".", "TypeUrl", ")", "\n", "out", ":=", "createResponse", "(", "request", ",", "resources", ",", "version", ")", "\n", "return", "&", "out", ",", "nil", "\n", "}", "\n\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "nodeID", ")", "\n", "}" ]
// Fetch implements the cache fetch function. // Fetch is called on multiple streams, so responding to individual names with the same version works.
[ "Fetch", "implements", "the", "cache", "fetch", "function", ".", "Fetch", "is", "called", "on", "multiple", "streams", "so", "responding", "to", "individual", "names", "with", "the", "same", "version", "works", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L278-L298
147,240
envoyproxy/go-control-plane
pkg/cache/simple.go
GetStatusInfo
func (cache *snapshotCache) GetStatusInfo(node string) StatusInfo { cache.mu.RLock() defer cache.mu.RUnlock() info, exists := cache.status[node] if !exists { return nil } return info }
go
func (cache *snapshotCache) GetStatusInfo(node string) StatusInfo { cache.mu.RLock() defer cache.mu.RUnlock() info, exists := cache.status[node] if !exists { return nil } return info }
[ "func", "(", "cache", "*", "snapshotCache", ")", "GetStatusInfo", "(", "node", "string", ")", "StatusInfo", "{", "cache", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "info", ",", "exists", ":=", "cache", ".", "status", "[", "node", "]", "\n", "if", "!", "exists", "{", "return", "nil", "\n", "}", "\n\n", "return", "info", "\n", "}" ]
// GetStatusInfo retrieves the status info for the node.
[ "GetStatusInfo", "retrieves", "the", "status", "info", "for", "the", "node", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L301-L311
147,241
envoyproxy/go-control-plane
pkg/cache/simple.go
GetStatusKeys
func (cache *snapshotCache) GetStatusKeys() []string { cache.mu.RLock() defer cache.mu.RUnlock() out := make([]string, 0, len(cache.status)) for id := range cache.status { out = append(out, id) } return out }
go
func (cache *snapshotCache) GetStatusKeys() []string { cache.mu.RLock() defer cache.mu.RUnlock() out := make([]string, 0, len(cache.status)) for id := range cache.status { out = append(out, id) } return out }
[ "func", "(", "cache", "*", "snapshotCache", ")", "GetStatusKeys", "(", ")", "[", "]", "string", "{", "cache", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "cache", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "out", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "cache", ".", "status", ")", ")", "\n", "for", "id", ":=", "range", "cache", ".", "status", "{", "out", "=", "append", "(", "out", ",", "id", ")", "\n", "}", "\n\n", "return", "out", "\n", "}" ]
// GetStatusKeys retrieves all node IDs in the status map.
[ "GetStatusKeys", "retrieves", "all", "node", "IDs", "in", "the", "status", "map", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/simple.go#L314-L324
147,242
envoyproxy/go-control-plane
envoy/config/ratelimit/v2/rls.pb.validate.go
Validate
func (m *RateLimitServiceConfig) Validate() error { if m == nil { return nil } if m.GetGrpcService() == nil { return RateLimitServiceConfigValidationError{ field: "GrpcService", reason: "value is required", } } { tmp := m.GetGrpcService() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RateLimitServiceConfigValidationError{ field: "GrpcService", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *RateLimitServiceConfig) Validate() error { if m == nil { return nil } if m.GetGrpcService() == nil { return RateLimitServiceConfigValidationError{ field: "GrpcService", reason: "value is required", } } { tmp := m.GetGrpcService() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RateLimitServiceConfigValidationError{ field: "GrpcService", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "RateLimitServiceConfig", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "m", ".", "GetGrpcService", "(", ")", "==", "nil", "{", "return", "RateLimitServiceConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetGrpcService", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RateLimitServiceConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on RateLimitServiceConfig with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "RateLimitServiceConfig", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/ratelimit/v2/rls.pb.validate.go#L39-L67
147,243
envoyproxy/go-control-plane
envoy/type/matcher/number.pb.validate.go
Validate
func (m *DoubleMatcher) Validate() error { if m == nil { return nil } switch m.MatchPattern.(type) { case *DoubleMatcher_Range: { tmp := m.GetRange() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DoubleMatcherValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, } } } } case *DoubleMatcher_Exact: // no validation rules for Exact default: return DoubleMatcherValidationError{ field: "MatchPattern", reason: "value is required", } } return nil }
go
func (m *DoubleMatcher) Validate() error { if m == nil { return nil } switch m.MatchPattern.(type) { case *DoubleMatcher_Range: { tmp := m.GetRange() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DoubleMatcherValidationError{ field: "Range", reason: "embedded message failed validation", cause: err, } } } } case *DoubleMatcher_Exact: // no validation rules for Exact default: return DoubleMatcherValidationError{ field: "MatchPattern", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "DoubleMatcher", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "switch", "m", ".", "MatchPattern", ".", "(", "type", ")", "{", "case", "*", "DoubleMatcher_Range", ":", "{", "tmp", ":=", "m", ".", "GetRange", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "DoubleMatcherValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "DoubleMatcher_Exact", ":", "// no validation rules for Exact", "default", ":", "return", "DoubleMatcherValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on DoubleMatcher with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "DoubleMatcher", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/type/matcher/number.pb.validate.go#L39-L75
147,244
envoyproxy/go-control-plane
envoy/config/metrics/v2/stats.pb.validate.go
Validate
func (m *StatsSink) Validate() error { if m == nil { return nil } // no validation rules for Name switch m.ConfigType.(type) { case *StatsSink_Config: { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsSinkValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } case *StatsSink_TypedConfig: { tmp := m.GetTypedConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsSinkValidationError{ field: "TypedConfig", reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *StatsSink) Validate() error { if m == nil { return nil } // no validation rules for Name switch m.ConfigType.(type) { case *StatsSink_Config: { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsSinkValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } case *StatsSink_TypedConfig: { tmp := m.GetTypedConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsSinkValidationError{ field: "TypedConfig", reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "StatsSink", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for Name", "switch", "m", ".", "ConfigType", ".", "(", "type", ")", "{", "case", "*", "StatsSink_Config", ":", "{", "tmp", ":=", "m", ".", "GetConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "StatsSink_TypedConfig", ":", "{", "tmp", ":=", "m", ".", "GetTypedConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on StatsSink with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "StatsSink", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/metrics/v2/stats.pb.validate.go#L38-L84
147,245
envoyproxy/go-control-plane
envoy/config/metrics/v2/stats.pb.validate.go
Validate
func (m *StatsConfig) Validate() error { if m == nil { return nil } for idx, item := range m.GetStatsTags() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsConfigValidationError{ field: fmt.Sprintf("StatsTags[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } { tmp := m.GetUseAllDefaultTags() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsConfigValidationError{ field: "UseAllDefaultTags", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetStatsMatcher() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsConfigValidationError{ field: "StatsMatcher", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *StatsConfig) Validate() error { if m == nil { return nil } for idx, item := range m.GetStatsTags() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsConfigValidationError{ field: fmt.Sprintf("StatsTags[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } { tmp := m.GetUseAllDefaultTags() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsConfigValidationError{ field: "UseAllDefaultTags", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetStatsMatcher() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsConfigValidationError{ field: "StatsMatcher", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "StatsConfig", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetStatsTags", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsConfigValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetUseAllDefaultTags", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetStatsMatcher", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on StatsConfig with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "StatsConfig", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/metrics/v2/stats.pb.validate.go#L143-L199
147,246
envoyproxy/go-control-plane
envoy/config/metrics/v2/stats.pb.validate.go
Validate
func (m *StatsMatcher) Validate() error { if m == nil { return nil } switch m.StatsMatcher.(type) { case *StatsMatcher_RejectAll: // no validation rules for RejectAll case *StatsMatcher_ExclusionList: { tmp := m.GetExclusionList() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsMatcherValidationError{ field: "ExclusionList", reason: "embedded message failed validation", cause: err, } } } } case *StatsMatcher_InclusionList: { tmp := m.GetInclusionList() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsMatcherValidationError{ field: "InclusionList", reason: "embedded message failed validation", cause: err, } } } } default: return StatsMatcherValidationError{ field: "StatsMatcher", reason: "value is required", } } return nil }
go
func (m *StatsMatcher) Validate() error { if m == nil { return nil } switch m.StatsMatcher.(type) { case *StatsMatcher_RejectAll: // no validation rules for RejectAll case *StatsMatcher_ExclusionList: { tmp := m.GetExclusionList() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsMatcherValidationError{ field: "ExclusionList", reason: "embedded message failed validation", cause: err, } } } } case *StatsMatcher_InclusionList: { tmp := m.GetInclusionList() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsMatcherValidationError{ field: "InclusionList", reason: "embedded message failed validation", cause: err, } } } } default: return StatsMatcherValidationError{ field: "StatsMatcher", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "StatsMatcher", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "switch", "m", ".", "StatsMatcher", ".", "(", "type", ")", "{", "case", "*", "StatsMatcher_RejectAll", ":", "// no validation rules for RejectAll", "case", "*", "StatsMatcher_ExclusionList", ":", "{", "tmp", ":=", "m", ".", "GetExclusionList", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsMatcherValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "StatsMatcher_InclusionList", ":", "{", "tmp", ":=", "m", ".", "GetInclusionList", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsMatcherValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "default", ":", "return", "StatsMatcherValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on StatsMatcher with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "StatsMatcher", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/metrics/v2/stats.pb.validate.go#L258-L311
147,247
envoyproxy/go-control-plane
envoy/config/metrics/v2/stats.pb.validate.go
Validate
func (m *TagSpecifier) Validate() error { if m == nil { return nil } // no validation rules for TagName switch m.TagValue.(type) { case *TagSpecifier_Regex: if len(m.GetRegex()) > 1024 { return TagSpecifierValidationError{ field: "Regex", reason: "value length must be at most 1024 bytes", } } case *TagSpecifier_FixedValue: // no validation rules for FixedValue } return nil }
go
func (m *TagSpecifier) Validate() error { if m == nil { return nil } // no validation rules for TagName switch m.TagValue.(type) { case *TagSpecifier_Regex: if len(m.GetRegex()) > 1024 { return TagSpecifierValidationError{ field: "Regex", reason: "value length must be at most 1024 bytes", } } case *TagSpecifier_FixedValue: // no validation rules for FixedValue } return nil }
[ "func", "(", "m", "*", "TagSpecifier", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for TagName", "switch", "m", ".", "TagValue", ".", "(", "type", ")", "{", "case", "*", "TagSpecifier_Regex", ":", "if", "len", "(", "m", ".", "GetRegex", "(", ")", ")", ">", "1024", "{", "return", "TagSpecifierValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "case", "*", "TagSpecifier_FixedValue", ":", "// no validation rules for FixedValue", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on TagSpecifier with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "TagSpecifier", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/metrics/v2/stats.pb.validate.go#L370-L394
147,248
envoyproxy/go-control-plane
envoy/config/metrics/v2/stats.pb.validate.go
Validate
func (m *StatsdSink) Validate() error { if m == nil { return nil } // no validation rules for Prefix switch m.StatsdSpecifier.(type) { case *StatsdSink_Address: { tmp := m.GetAddress() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsdSinkValidationError{ field: "Address", reason: "embedded message failed validation", cause: err, } } } } case *StatsdSink_TcpClusterName: // no validation rules for TcpClusterName default: return StatsdSinkValidationError{ field: "StatsdSpecifier", reason: "value is required", } } return nil }
go
func (m *StatsdSink) Validate() error { if m == nil { return nil } // no validation rules for Prefix switch m.StatsdSpecifier.(type) { case *StatsdSink_Address: { tmp := m.GetAddress() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatsdSinkValidationError{ field: "Address", reason: "embedded message failed validation", cause: err, } } } } case *StatsdSink_TcpClusterName: // no validation rules for TcpClusterName default: return StatsdSinkValidationError{ field: "StatsdSpecifier", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "StatsdSink", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for Prefix", "switch", "m", ".", "StatsdSpecifier", ".", "(", "type", ")", "{", "case", "*", "StatsdSink_Address", ":", "{", "tmp", ":=", "m", ".", "GetAddress", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatsdSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "StatsdSink_TcpClusterName", ":", "// no validation rules for TcpClusterName", "default", ":", "return", "StatsdSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on StatsdSink with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "StatsdSink", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/metrics/v2/stats.pb.validate.go#L452-L490
147,249
envoyproxy/go-control-plane
envoy/config/metrics/v2/stats.pb.validate.go
Validate
func (m *DogStatsdSink) Validate() error { if m == nil { return nil } // no validation rules for Prefix switch m.DogStatsdSpecifier.(type) { case *DogStatsdSink_Address: { tmp := m.GetAddress() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DogStatsdSinkValidationError{ field: "Address", reason: "embedded message failed validation", cause: err, } } } } default: return DogStatsdSinkValidationError{ field: "DogStatsdSpecifier", reason: "value is required", } } return nil }
go
func (m *DogStatsdSink) Validate() error { if m == nil { return nil } // no validation rules for Prefix switch m.DogStatsdSpecifier.(type) { case *DogStatsdSink_Address: { tmp := m.GetAddress() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DogStatsdSinkValidationError{ field: "Address", reason: "embedded message failed validation", cause: err, } } } } default: return DogStatsdSinkValidationError{ field: "DogStatsdSpecifier", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "DogStatsdSink", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for Prefix", "switch", "m", ".", "DogStatsdSpecifier", ".", "(", "type", ")", "{", "case", "*", "DogStatsdSink_Address", ":", "{", "tmp", ":=", "m", ".", "GetAddress", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "DogStatsdSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "default", ":", "return", "DogStatsdSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on DogStatsdSink with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "DogStatsdSink", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/metrics/v2/stats.pb.validate.go#L549-L584
147,250
envoyproxy/go-control-plane
pkg/cache/snapshot.go
IndexResourcesByName
func IndexResourcesByName(items []Resource) map[string]Resource { indexed := make(map[string]Resource, len(items)) for _, item := range items { indexed[GetResourceName(item)] = item } return indexed }
go
func IndexResourcesByName(items []Resource) map[string]Resource { indexed := make(map[string]Resource, len(items)) for _, item := range items { indexed[GetResourceName(item)] = item } return indexed }
[ "func", "IndexResourcesByName", "(", "items", "[", "]", "Resource", ")", "map", "[", "string", "]", "Resource", "{", "indexed", ":=", "make", "(", "map", "[", "string", "]", "Resource", ",", "len", "(", "items", ")", ")", "\n", "for", "_", ",", "item", ":=", "range", "items", "{", "indexed", "[", "GetResourceName", "(", "item", ")", "]", "=", "item", "\n", "}", "\n", "return", "indexed", "\n", "}" ]
// IndexResourcesByName creates a map from the resource name to the resource.
[ "IndexResourcesByName", "creates", "a", "map", "from", "the", "resource", "name", "to", "the", "resource", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/snapshot.go#L32-L38
147,251
envoyproxy/go-control-plane
pkg/cache/snapshot.go
NewResources
func NewResources(version string, items []Resource) Resources { return Resources{ Version: version, Items: IndexResourcesByName(items), } }
go
func NewResources(version string, items []Resource) Resources { return Resources{ Version: version, Items: IndexResourcesByName(items), } }
[ "func", "NewResources", "(", "version", "string", ",", "items", "[", "]", "Resource", ")", "Resources", "{", "return", "Resources", "{", "Version", ":", "version", ",", "Items", ":", "IndexResourcesByName", "(", "items", ")", ",", "}", "\n", "}" ]
// NewResources creates a new resource group.
[ "NewResources", "creates", "a", "new", "resource", "group", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/snapshot.go#L41-L46
147,252
envoyproxy/go-control-plane
pkg/cache/snapshot.go
NewSnapshot
func NewSnapshot(version string, endpoints []Resource, clusters []Resource, routes []Resource, listeners []Resource) Snapshot { return Snapshot{ Endpoints: NewResources(version, endpoints), Clusters: NewResources(version, clusters), Routes: NewResources(version, routes), Listeners: NewResources(version, listeners), } }
go
func NewSnapshot(version string, endpoints []Resource, clusters []Resource, routes []Resource, listeners []Resource) Snapshot { return Snapshot{ Endpoints: NewResources(version, endpoints), Clusters: NewResources(version, clusters), Routes: NewResources(version, routes), Listeners: NewResources(version, listeners), } }
[ "func", "NewSnapshot", "(", "version", "string", ",", "endpoints", "[", "]", "Resource", ",", "clusters", "[", "]", "Resource", ",", "routes", "[", "]", "Resource", ",", "listeners", "[", "]", "Resource", ")", "Snapshot", "{", "return", "Snapshot", "{", "Endpoints", ":", "NewResources", "(", "version", ",", "endpoints", ")", ",", "Clusters", ":", "NewResources", "(", "version", ",", "clusters", ")", ",", "Routes", ":", "NewResources", "(", "version", ",", "routes", ")", ",", "Listeners", ":", "NewResources", "(", "version", ",", "listeners", ")", ",", "}", "\n", "}" ]
// NewSnapshot creates a snapshot from response types and a version.
[ "NewSnapshot", "creates", "a", "snapshot", "from", "response", "types", "and", "a", "version", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/snapshot.go#L69-L80
147,253
envoyproxy/go-control-plane
pkg/cache/snapshot.go
GetResources
func (s *Snapshot) GetResources(typ string) map[string]Resource { if s == nil { return nil } switch typ { case EndpointType: return s.Endpoints.Items case ClusterType: return s.Clusters.Items case RouteType: return s.Routes.Items case ListenerType: return s.Listeners.Items case SecretType: return s.Secrets.Items } return nil }
go
func (s *Snapshot) GetResources(typ string) map[string]Resource { if s == nil { return nil } switch typ { case EndpointType: return s.Endpoints.Items case ClusterType: return s.Clusters.Items case RouteType: return s.Routes.Items case ListenerType: return s.Listeners.Items case SecretType: return s.Secrets.Items } return nil }
[ "func", "(", "s", "*", "Snapshot", ")", "GetResources", "(", "typ", "string", ")", "map", "[", "string", "]", "Resource", "{", "if", "s", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "switch", "typ", "{", "case", "EndpointType", ":", "return", "s", ".", "Endpoints", ".", "Items", "\n", "case", "ClusterType", ":", "return", "s", ".", "Clusters", ".", "Items", "\n", "case", "RouteType", ":", "return", "s", ".", "Routes", ".", "Items", "\n", "case", "ListenerType", ":", "return", "s", ".", "Listeners", ".", "Items", "\n", "case", "SecretType", ":", "return", "s", ".", "Secrets", ".", "Items", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// GetResources selects snapshot resources by type.
[ "GetResources", "selects", "snapshot", "resources", "by", "type", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/snapshot.go#L110-L127
147,254
envoyproxy/go-control-plane
pkg/cache/snapshot.go
GetVersion
func (s *Snapshot) GetVersion(typ string) string { if s == nil { return "" } switch typ { case EndpointType: return s.Endpoints.Version case ClusterType: return s.Clusters.Version case RouteType: return s.Routes.Version case ListenerType: return s.Listeners.Version case SecretType: return s.Secrets.Version } return "" }
go
func (s *Snapshot) GetVersion(typ string) string { if s == nil { return "" } switch typ { case EndpointType: return s.Endpoints.Version case ClusterType: return s.Clusters.Version case RouteType: return s.Routes.Version case ListenerType: return s.Listeners.Version case SecretType: return s.Secrets.Version } return "" }
[ "func", "(", "s", "*", "Snapshot", ")", "GetVersion", "(", "typ", "string", ")", "string", "{", "if", "s", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "switch", "typ", "{", "case", "EndpointType", ":", "return", "s", ".", "Endpoints", ".", "Version", "\n", "case", "ClusterType", ":", "return", "s", ".", "Clusters", ".", "Version", "\n", "case", "RouteType", ":", "return", "s", ".", "Routes", ".", "Version", "\n", "case", "ListenerType", ":", "return", "s", ".", "Listeners", ".", "Version", "\n", "case", "SecretType", ":", "return", "s", ".", "Secrets", ".", "Version", "\n", "}", "\n", "return", "\"", "\"", "\n", "}" ]
// GetVersion returns the version for a resource type.
[ "GetVersion", "returns", "the", "version", "for", "a", "resource", "type", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/pkg/cache/snapshot.go#L130-L147
147,255
envoyproxy/go-control-plane
envoy/config/metrics/v2/metrics_service.pb.validate.go
Validate
func (m *MetricsServiceConfig) Validate() error { if m == nil { return nil } if m.GetGrpcService() == nil { return MetricsServiceConfigValidationError{ field: "GrpcService", reason: "value is required", } } { tmp := m.GetGrpcService() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return MetricsServiceConfigValidationError{ field: "GrpcService", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *MetricsServiceConfig) Validate() error { if m == nil { return nil } if m.GetGrpcService() == nil { return MetricsServiceConfigValidationError{ field: "GrpcService", reason: "value is required", } } { tmp := m.GetGrpcService() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return MetricsServiceConfigValidationError{ field: "GrpcService", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "MetricsServiceConfig", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "m", ".", "GetGrpcService", "(", ")", "==", "nil", "{", "return", "MetricsServiceConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetGrpcService", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "MetricsServiceConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on MetricsServiceConfig with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "MetricsServiceConfig", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/metrics/v2/metrics_service.pb.validate.go#L39-L67
147,256
envoyproxy/go-control-plane
envoy/config/filter/http/lua/v2/lua.pb.validate.go
Validate
func (m *Lua) Validate() error { if m == nil { return nil } if len(m.GetInlineCode()) < 1 { return LuaValidationError{ field: "InlineCode", reason: "value length must be at least 1 bytes", } } return nil }
go
func (m *Lua) Validate() error { if m == nil { return nil } if len(m.GetInlineCode()) < 1 { return LuaValidationError{ field: "InlineCode", reason: "value length must be at least 1 bytes", } } return nil }
[ "func", "(", "m", "*", "Lua", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetInlineCode", "(", ")", ")", "<", "1", "{", "return", "LuaValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on Lua with the rules defined in the proto // definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "Lua", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/http/lua/v2/lua.pb.validate.go#L38-L51
147,257
envoyproxy/go-control-plane
envoy/service/tap/v2alpha/common.pb.validate.go
Validate
func (m *TapConfig) Validate() error { if m == nil { return nil } if m.GetMatchConfig() == nil { return TapConfigValidationError{ field: "MatchConfig", reason: "value is required", } } { tmp := m.GetMatchConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return TapConfigValidationError{ field: "MatchConfig", reason: "embedded message failed validation", cause: err, } } } } if m.GetOutputConfig() == nil { return TapConfigValidationError{ field: "OutputConfig", reason: "value is required", } } { tmp := m.GetOutputConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return TapConfigValidationError{ field: "OutputConfig", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *TapConfig) Validate() error { if m == nil { return nil } if m.GetMatchConfig() == nil { return TapConfigValidationError{ field: "MatchConfig", reason: "value is required", } } { tmp := m.GetMatchConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return TapConfigValidationError{ field: "MatchConfig", reason: "embedded message failed validation", cause: err, } } } } if m.GetOutputConfig() == nil { return TapConfigValidationError{ field: "OutputConfig", reason: "value is required", } } { tmp := m.GetOutputConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return TapConfigValidationError{ field: "OutputConfig", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "TapConfig", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "m", ".", "GetMatchConfig", "(", ")", "==", "nil", "{", "return", "TapConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetMatchConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "TapConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "if", "m", ".", "GetOutputConfig", "(", ")", "==", "nil", "{", "return", "TapConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetOutputConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "TapConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on TapConfig with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "TapConfig", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/tap/v2alpha/common.pb.validate.go#L38-L88
147,258
envoyproxy/go-control-plane
envoy/service/tap/v2alpha/common.pb.validate.go
Validate
func (m *OutputConfig) Validate() error { if m == nil { return nil } if len(m.GetSinks()) != 1 { return OutputConfigValidationError{ field: "Sinks", reason: "value must contain exactly 1 item(s)", } } for idx, item := range m.GetSinks() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputConfigValidationError{ field: fmt.Sprintf("Sinks[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } { tmp := m.GetMaxBufferedRxBytes() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputConfigValidationError{ field: "MaxBufferedRxBytes", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetMaxBufferedTxBytes() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputConfigValidationError{ field: "MaxBufferedTxBytes", reason: "embedded message failed validation", cause: err, } } } } // no validation rules for Streaming return nil }
go
func (m *OutputConfig) Validate() error { if m == nil { return nil } if len(m.GetSinks()) != 1 { return OutputConfigValidationError{ field: "Sinks", reason: "value must contain exactly 1 item(s)", } } for idx, item := range m.GetSinks() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputConfigValidationError{ field: fmt.Sprintf("Sinks[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } { tmp := m.GetMaxBufferedRxBytes() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputConfigValidationError{ field: "MaxBufferedRxBytes", reason: "embedded message failed validation", cause: err, } } } } { tmp := m.GetMaxBufferedTxBytes() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputConfigValidationError{ field: "MaxBufferedTxBytes", reason: "embedded message failed validation", cause: err, } } } } // no validation rules for Streaming return nil }
[ "func", "(", "m", "*", "OutputConfig", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetSinks", "(", ")", ")", "!=", "1", "{", "return", "OutputConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetSinks", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "OutputConfigValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetMaxBufferedRxBytes", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "OutputConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetMaxBufferedTxBytes", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "OutputConfigValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// no validation rules for Streaming", "return", "nil", "\n", "}" ]
// Validate checks the field values on OutputConfig with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "OutputConfig", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/tap/v2alpha/common.pb.validate.go#L435-L500
147,259
envoyproxy/go-control-plane
envoy/service/tap/v2alpha/common.pb.validate.go
Validate
func (m *OutputSink) Validate() error { if m == nil { return nil } if _, ok := OutputSink_Format_name[int32(m.GetFormat())]; !ok { return OutputSinkValidationError{ field: "Format", reason: "value must be one of the defined enum values", } } switch m.OutputSinkType.(type) { case *OutputSink_StreamingAdmin: { tmp := m.GetStreamingAdmin() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputSinkValidationError{ field: "StreamingAdmin", reason: "embedded message failed validation", cause: err, } } } } case *OutputSink_FilePerTap: { tmp := m.GetFilePerTap() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputSinkValidationError{ field: "FilePerTap", reason: "embedded message failed validation", cause: err, } } } } default: return OutputSinkValidationError{ field: "OutputSinkType", reason: "value is required", } } return nil }
go
func (m *OutputSink) Validate() error { if m == nil { return nil } if _, ok := OutputSink_Format_name[int32(m.GetFormat())]; !ok { return OutputSinkValidationError{ field: "Format", reason: "value must be one of the defined enum values", } } switch m.OutputSinkType.(type) { case *OutputSink_StreamingAdmin: { tmp := m.GetStreamingAdmin() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputSinkValidationError{ field: "StreamingAdmin", reason: "embedded message failed validation", cause: err, } } } } case *OutputSink_FilePerTap: { tmp := m.GetFilePerTap() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OutputSinkValidationError{ field: "FilePerTap", reason: "embedded message failed validation", cause: err, } } } } default: return OutputSinkValidationError{ field: "OutputSinkType", reason: "value is required", } } return nil }
[ "func", "(", "m", "*", "OutputSink", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "_", ",", "ok", ":=", "OutputSink_Format_name", "[", "int32", "(", "m", ".", "GetFormat", "(", ")", ")", "]", ";", "!", "ok", "{", "return", "OutputSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "switch", "m", ".", "OutputSinkType", ".", "(", "type", ")", "{", "case", "*", "OutputSink_StreamingAdmin", ":", "{", "tmp", ":=", "m", ".", "GetStreamingAdmin", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "OutputSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "OutputSink_FilePerTap", ":", "{", "tmp", ":=", "m", ".", "GetFilePerTap", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "OutputSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "default", ":", "return", "OutputSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on OutputSink with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "OutputSink", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/tap/v2alpha/common.pb.validate.go#L558-L615
147,260
envoyproxy/go-control-plane
envoy/service/tap/v2alpha/common.pb.validate.go
Validate
func (m *FilePerTapSink) Validate() error { if m == nil { return nil } if len(m.GetPathPrefix()) < 1 { return FilePerTapSinkValidationError{ field: "PathPrefix", reason: "value length must be at least 1 bytes", } } return nil }
go
func (m *FilePerTapSink) Validate() error { if m == nil { return nil } if len(m.GetPathPrefix()) < 1 { return FilePerTapSinkValidationError{ field: "PathPrefix", reason: "value length must be at least 1 bytes", } } return nil }
[ "func", "(", "m", "*", "FilePerTapSink", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetPathPrefix", "(", ")", ")", "<", "1", "{", "return", "FilePerTapSinkValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on FilePerTapSink with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "FilePerTapSink", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/service/tap/v2alpha/common.pb.validate.go#L741-L754
147,261
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *AccessLog) Validate() error { if m == nil { return nil } // no validation rules for Name { tmp := m.GetFilter() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return AccessLogValidationError{ field: "Filter", reason: "embedded message failed validation", cause: err, } } } } switch m.ConfigType.(type) { case *AccessLog_Config: { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return AccessLogValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } case *AccessLog_TypedConfig: { tmp := m.GetTypedConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return AccessLogValidationError{ field: "TypedConfig", reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *AccessLog) Validate() error { if m == nil { return nil } // no validation rules for Name { tmp := m.GetFilter() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return AccessLogValidationError{ field: "Filter", reason: "embedded message failed validation", cause: err, } } } } switch m.ConfigType.(type) { case *AccessLog_Config: { tmp := m.GetConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return AccessLogValidationError{ field: "Config", reason: "embedded message failed validation", cause: err, } } } } case *AccessLog_TypedConfig: { tmp := m.GetTypedConfig() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return AccessLogValidationError{ field: "TypedConfig", reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "AccessLog", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// no validation rules for Name", "{", "tmp", ":=", "m", ".", "GetFilter", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "AccessLogValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "switch", "m", ".", "ConfigType", ".", "(", "type", ")", "{", "case", "*", "AccessLog_Config", ":", "{", "tmp", ":=", "m", ".", "GetConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "AccessLogValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "case", "*", "AccessLog_TypedConfig", ":", "{", "tmp", ":=", "m", ".", "GetTypedConfig", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "AccessLogValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on AccessLog with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "AccessLog", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L38-L99
147,262
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *ComparisonFilter) Validate() error { if m == nil { return nil } if _, ok := ComparisonFilter_Op_name[int32(m.GetOp())]; !ok { return ComparisonFilterValidationError{ field: "Op", reason: "value must be one of the defined enum values", } } { tmp := m.GetValue() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ComparisonFilterValidationError{ field: "Value", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *ComparisonFilter) Validate() error { if m == nil { return nil } if _, ok := ComparisonFilter_Op_name[int32(m.GetOp())]; !ok { return ComparisonFilterValidationError{ field: "Op", reason: "value must be one of the defined enum values", } } { tmp := m.GetValue() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return ComparisonFilterValidationError{ field: "Value", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "ComparisonFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "_", ",", "ok", ":=", "ComparisonFilter_Op_name", "[", "int32", "(", "m", ".", "GetOp", "(", ")", ")", "]", ";", "!", "ok", "{", "return", "ComparisonFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetValue", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "ComparisonFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ComparisonFilter with the rules defined // in the proto definition for this message. If any rules are violated, an // error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ComparisonFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L403-L431
147,263
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *StatusCodeFilter) Validate() error { if m == nil { return nil } if m.GetComparison() == nil { return StatusCodeFilterValidationError{ field: "Comparison", reason: "value is required", } } { tmp := m.GetComparison() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatusCodeFilterValidationError{ field: "Comparison", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *StatusCodeFilter) Validate() error { if m == nil { return nil } if m.GetComparison() == nil { return StatusCodeFilterValidationError{ field: "Comparison", reason: "value is required", } } { tmp := m.GetComparison() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return StatusCodeFilterValidationError{ field: "Comparison", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "StatusCodeFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "m", ".", "GetComparison", "(", ")", "==", "nil", "{", "return", "StatusCodeFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetComparison", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "StatusCodeFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on StatusCodeFilter with the rules defined // in the proto definition for this message. If any rules are violated, an // error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "StatusCodeFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L490-L518
147,264
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *DurationFilter) Validate() error { if m == nil { return nil } if m.GetComparison() == nil { return DurationFilterValidationError{ field: "Comparison", reason: "value is required", } } { tmp := m.GetComparison() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DurationFilterValidationError{ field: "Comparison", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *DurationFilter) Validate() error { if m == nil { return nil } if m.GetComparison() == nil { return DurationFilterValidationError{ field: "Comparison", reason: "value is required", } } { tmp := m.GetComparison() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return DurationFilterValidationError{ field: "Comparison", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "DurationFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "m", ".", "GetComparison", "(", ")", "==", "nil", "{", "return", "DurationFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetComparison", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "DurationFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on DurationFilter with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "DurationFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L577-L605
147,265
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *RuntimeFilter) Validate() error { if m == nil { return nil } if len(m.GetRuntimeKey()) < 1 { return RuntimeFilterValidationError{ field: "RuntimeKey", reason: "value length must be at least 1 bytes", } } { tmp := m.GetPercentSampled() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RuntimeFilterValidationError{ field: "PercentSampled", reason: "embedded message failed validation", cause: err, } } } } // no validation rules for UseIndependentRandomness return nil }
go
func (m *RuntimeFilter) Validate() error { if m == nil { return nil } if len(m.GetRuntimeKey()) < 1 { return RuntimeFilterValidationError{ field: "RuntimeKey", reason: "value length must be at least 1 bytes", } } { tmp := m.GetPercentSampled() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return RuntimeFilterValidationError{ field: "PercentSampled", reason: "embedded message failed validation", cause: err, } } } } // no validation rules for UseIndependentRandomness return nil }
[ "func", "(", "m", "*", "RuntimeFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetRuntimeKey", "(", ")", ")", "<", "1", "{", "return", "RuntimeFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetPercentSampled", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "RuntimeFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "// no validation rules for UseIndependentRandomness", "return", "nil", "\n", "}" ]
// Validate checks the field values on RuntimeFilter with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "RuntimeFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L796-L826
147,266
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *OrFilter) Validate() error { if m == nil { return nil } if len(m.GetFilters()) < 2 { return OrFilterValidationError{ field: "Filters", reason: "value must contain at least 2 item(s)", } } for idx, item := range m.GetFilters() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OrFilterValidationError{ field: fmt.Sprintf("Filters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
go
func (m *OrFilter) Validate() error { if m == nil { return nil } if len(m.GetFilters()) < 2 { return OrFilterValidationError{ field: "Filters", reason: "value must contain at least 2 item(s)", } } for idx, item := range m.GetFilters() { _, _ = idx, item { tmp := item if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return OrFilterValidationError{ field: fmt.Sprintf("Filters[%v]", idx), reason: "embedded message failed validation", cause: err, } } } } } return nil }
[ "func", "(", "m", "*", "OrFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "len", "(", "m", ".", "GetFilters", "(", ")", ")", "<", "2", "{", "return", "OrFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetFilters", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "{", "tmp", ":=", "item", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "OrFilterValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on OrFilter with the rules defined in the // proto definition for this message. If any rules are violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "OrFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L975-L1008
147,267
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *HeaderFilter) Validate() error { if m == nil { return nil } if m.GetHeader() == nil { return HeaderFilterValidationError{ field: "Header", reason: "value is required", } } { tmp := m.GetHeader() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return HeaderFilterValidationError{ field: "Header", reason: "embedded message failed validation", cause: err, } } } } return nil }
go
func (m *HeaderFilter) Validate() error { if m == nil { return nil } if m.GetHeader() == nil { return HeaderFilterValidationError{ field: "Header", reason: "value is required", } } { tmp := m.GetHeader() if v, ok := interface{}(tmp).(interface{ Validate() error }); ok { if err := v.Validate(); err != nil { return HeaderFilterValidationError{ field: "Header", reason: "embedded message failed validation", cause: err, } } } } return nil }
[ "func", "(", "m", "*", "HeaderFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "m", ".", "GetHeader", "(", ")", "==", "nil", "{", "return", "HeaderFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "{", "tmp", ":=", "m", ".", "GetHeader", "(", ")", "\n\n", "if", "v", ",", "ok", ":=", "interface", "{", "}", "(", "tmp", ")", ".", "(", "interface", "{", "Validate", "(", ")", "error", "}", ")", ";", "ok", "{", "if", "err", ":=", "v", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "HeaderFilterValidationError", "{", "field", ":", "\"", "\"", ",", "reason", ":", "\"", "\"", ",", "cause", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on HeaderFilter with the rules defined in // the proto definition for this message. If any rules are violated, an error // is returned.
[ "Validate", "checks", "the", "field", "values", "on", "HeaderFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L1067-L1095
147,268
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *ResponseFlagFilter) Validate() error { if m == nil { return nil } for idx, item := range m.GetFlags() { _, _ = idx, item if _, ok := _ResponseFlagFilter_Flags_InLookup[item]; !ok { return ResponseFlagFilterValidationError{ field: fmt.Sprintf("Flags[%v]", idx), reason: "value must be in list [LH UH UT LR UR UF UC UO NR DI FI RL UAEX RLSE DC URX SI]", } } } return nil }
go
func (m *ResponseFlagFilter) Validate() error { if m == nil { return nil } for idx, item := range m.GetFlags() { _, _ = idx, item if _, ok := _ResponseFlagFilter_Flags_InLookup[item]; !ok { return ResponseFlagFilterValidationError{ field: fmt.Sprintf("Flags[%v]", idx), reason: "value must be in list [LH UH UT LR UR UF UC UO NR DI FI RL UAEX RLSE DC URX SI]", } } } return nil }
[ "func", "(", "m", "*", "ResponseFlagFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetFlags", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "if", "_", ",", "ok", ":=", "_ResponseFlagFilter_Flags_InLookup", "[", "item", "]", ";", "!", "ok", "{", "return", "ResponseFlagFilterValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate checks the field values on ResponseFlagFilter with the rules // defined in the proto definition for this message. If any rules are // violated, an error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "ResponseFlagFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L1154-L1172
147,269
envoyproxy/go-control-plane
envoy/config/filter/accesslog/v2/accesslog.pb.validate.go
Validate
func (m *GrpcStatusFilter) Validate() error { if m == nil { return nil } for idx, item := range m.GetStatuses() { _, _ = idx, item if _, ok := GrpcStatusFilter_Status_name[int32(item)]; !ok { return GrpcStatusFilterValidationError{ field: fmt.Sprintf("Statuses[%v]", idx), reason: "value must be one of the defined enum values", } } } // no validation rules for Exclude return nil }
go
func (m *GrpcStatusFilter) Validate() error { if m == nil { return nil } for idx, item := range m.GetStatuses() { _, _ = idx, item if _, ok := GrpcStatusFilter_Status_name[int32(item)]; !ok { return GrpcStatusFilterValidationError{ field: fmt.Sprintf("Statuses[%v]", idx), reason: "value must be one of the defined enum values", } } } // no validation rules for Exclude return nil }
[ "func", "(", "m", "*", "GrpcStatusFilter", ")", "Validate", "(", ")", "error", "{", "if", "m", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "for", "idx", ",", "item", ":=", "range", "m", ".", "GetStatuses", "(", ")", "{", "_", ",", "_", "=", "idx", ",", "item", "\n\n", "if", "_", ",", "ok", ":=", "GrpcStatusFilter_Status_name", "[", "int32", "(", "item", ")", "]", ";", "!", "ok", "{", "return", "GrpcStatusFilterValidationError", "{", "field", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "idx", ")", ",", "reason", ":", "\"", "\"", ",", "}", "\n", "}", "\n\n", "}", "\n\n", "// no validation rules for Exclude", "return", "nil", "\n", "}" ]
// Validate checks the field values on GrpcStatusFilter with the rules defined // in the proto definition for this message. If any rules are violated, an // error is returned.
[ "Validate", "checks", "the", "field", "values", "on", "GrpcStatusFilter", "with", "the", "rules", "defined", "in", "the", "proto", "definition", "for", "this", "message", ".", "If", "any", "rules", "are", "violated", "an", "error", "is", "returned", "." ]
9ffbaf293221f9fef735838632a9109d00aa2f4c
https://github.com/envoyproxy/go-control-plane/blob/9ffbaf293221f9fef735838632a9109d00aa2f4c/envoy/config/filter/accesslog/v2/accesslog.pb.validate.go#L1253-L1273
147,270
rs/zerolog
log.go
ParseLevel
func ParseLevel(levelStr string) (Level, error) { switch levelStr { case LevelFieldMarshalFunc(DebugLevel): return DebugLevel, nil case LevelFieldMarshalFunc(InfoLevel): return InfoLevel, nil case LevelFieldMarshalFunc(WarnLevel): return WarnLevel, nil case LevelFieldMarshalFunc(ErrorLevel): return ErrorLevel, nil case LevelFieldMarshalFunc(FatalLevel): return FatalLevel, nil case LevelFieldMarshalFunc(PanicLevel): return PanicLevel, nil case LevelFieldMarshalFunc(NoLevel): return NoLevel, nil } return NoLevel, fmt.Errorf("Unknown Level String: '%s', defaulting to NoLevel", levelStr) }
go
func ParseLevel(levelStr string) (Level, error) { switch levelStr { case LevelFieldMarshalFunc(DebugLevel): return DebugLevel, nil case LevelFieldMarshalFunc(InfoLevel): return InfoLevel, nil case LevelFieldMarshalFunc(WarnLevel): return WarnLevel, nil case LevelFieldMarshalFunc(ErrorLevel): return ErrorLevel, nil case LevelFieldMarshalFunc(FatalLevel): return FatalLevel, nil case LevelFieldMarshalFunc(PanicLevel): return PanicLevel, nil case LevelFieldMarshalFunc(NoLevel): return NoLevel, nil } return NoLevel, fmt.Errorf("Unknown Level String: '%s', defaulting to NoLevel", levelStr) }
[ "func", "ParseLevel", "(", "levelStr", "string", ")", "(", "Level", ",", "error", ")", "{", "switch", "levelStr", "{", "case", "LevelFieldMarshalFunc", "(", "DebugLevel", ")", ":", "return", "DebugLevel", ",", "nil", "\n", "case", "LevelFieldMarshalFunc", "(", "InfoLevel", ")", ":", "return", "InfoLevel", ",", "nil", "\n", "case", "LevelFieldMarshalFunc", "(", "WarnLevel", ")", ":", "return", "WarnLevel", ",", "nil", "\n", "case", "LevelFieldMarshalFunc", "(", "ErrorLevel", ")", ":", "return", "ErrorLevel", ",", "nil", "\n", "case", "LevelFieldMarshalFunc", "(", "FatalLevel", ")", ":", "return", "FatalLevel", ",", "nil", "\n", "case", "LevelFieldMarshalFunc", "(", "PanicLevel", ")", ":", "return", "PanicLevel", ",", "nil", "\n", "case", "LevelFieldMarshalFunc", "(", "NoLevel", ")", ":", "return", "NoLevel", ",", "nil", "\n", "}", "\n", "return", "NoLevel", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "levelStr", ")", "\n", "}" ]
// ParseLevel converts a level string into a zerolog Level value. // returns an error if the input string does not match known values.
[ "ParseLevel", "converts", "a", "level", "string", "into", "a", "zerolog", "Level", "value", ".", "returns", "an", "error", "if", "the", "input", "string", "does", "not", "match", "known", "values", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L153-L171
147,271
rs/zerolog
log.go
New
func New(w io.Writer) Logger { if w == nil { w = ioutil.Discard } lw, ok := w.(LevelWriter) if !ok { lw = levelWriterAdapter{w} } return Logger{w: lw} }
go
func New(w io.Writer) Logger { if w == nil { w = ioutil.Discard } lw, ok := w.(LevelWriter) if !ok { lw = levelWriterAdapter{w} } return Logger{w: lw} }
[ "func", "New", "(", "w", "io", ".", "Writer", ")", "Logger", "{", "if", "w", "==", "nil", "{", "w", "=", "ioutil", ".", "Discard", "\n", "}", "\n", "lw", ",", "ok", ":=", "w", ".", "(", "LevelWriter", ")", "\n", "if", "!", "ok", "{", "lw", "=", "levelWriterAdapter", "{", "w", "}", "\n", "}", "\n", "return", "Logger", "{", "w", ":", "lw", "}", "\n", "}" ]
// New creates a root logger with given output writer. If the output writer implements // the LevelWriter interface, the WriteLevel method will be called instead of the Write // one. // // Each logging operation makes a single call to the Writer's Write method. There is no // guaranty on access serialization to the Writer. If your Writer is not thread safe, // you may consider using sync wrapper.
[ "New", "creates", "a", "root", "logger", "with", "given", "output", "writer", ".", "If", "the", "output", "writer", "implements", "the", "LevelWriter", "interface", "the", "WriteLevel", "method", "will", "be", "called", "instead", "of", "the", "Write", "one", ".", "Each", "logging", "operation", "makes", "a", "single", "call", "to", "the", "Writer", "s", "Write", "method", ".", "There", "is", "no", "guaranty", "on", "access", "serialization", "to", "the", "Writer", ".", "If", "your", "Writer", "is", "not", "thread", "safe", "you", "may", "consider", "using", "sync", "wrapper", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L193-L202
147,272
rs/zerolog
log.go
Output
func (l Logger) Output(w io.Writer) Logger { l2 := New(w) l2.level = l.level l2.sampler = l.sampler if len(l.hooks) > 0 { l2.hooks = append(l2.hooks, l.hooks...) } if l.context != nil { l2.context = make([]byte, len(l.context), cap(l.context)) copy(l2.context, l.context) } return l2 }
go
func (l Logger) Output(w io.Writer) Logger { l2 := New(w) l2.level = l.level l2.sampler = l.sampler if len(l.hooks) > 0 { l2.hooks = append(l2.hooks, l.hooks...) } if l.context != nil { l2.context = make([]byte, len(l.context), cap(l.context)) copy(l2.context, l.context) } return l2 }
[ "func", "(", "l", "Logger", ")", "Output", "(", "w", "io", ".", "Writer", ")", "Logger", "{", "l2", ":=", "New", "(", "w", ")", "\n", "l2", ".", "level", "=", "l", ".", "level", "\n", "l2", ".", "sampler", "=", "l", ".", "sampler", "\n", "if", "len", "(", "l", ".", "hooks", ")", ">", "0", "{", "l2", ".", "hooks", "=", "append", "(", "l2", ".", "hooks", ",", "l", ".", "hooks", "...", ")", "\n", "}", "\n", "if", "l", ".", "context", "!=", "nil", "{", "l2", ".", "context", "=", "make", "(", "[", "]", "byte", ",", "len", "(", "l", ".", "context", ")", ",", "cap", "(", "l", ".", "context", ")", ")", "\n", "copy", "(", "l2", ".", "context", ",", "l", ".", "context", ")", "\n", "}", "\n", "return", "l2", "\n", "}" ]
// Output duplicates the current logger and sets w as its output.
[ "Output", "duplicates", "the", "current", "logger", "and", "sets", "w", "as", "its", "output", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L210-L222
147,273
rs/zerolog
log.go
With
func (l Logger) With() Context { context := l.context l.context = make([]byte, 0, 500) if context != nil { l.context = append(l.context, context...) } return Context{l} }
go
func (l Logger) With() Context { context := l.context l.context = make([]byte, 0, 500) if context != nil { l.context = append(l.context, context...) } return Context{l} }
[ "func", "(", "l", "Logger", ")", "With", "(", ")", "Context", "{", "context", ":=", "l", ".", "context", "\n", "l", ".", "context", "=", "make", "(", "[", "]", "byte", ",", "0", ",", "500", ")", "\n", "if", "context", "!=", "nil", "{", "l", ".", "context", "=", "append", "(", "l", ".", "context", ",", "context", "...", ")", "\n", "}", "\n", "return", "Context", "{", "l", "}", "\n", "}" ]
// With creates a child logger with the field added to its context.
[ "With", "creates", "a", "child", "logger", "with", "the", "field", "added", "to", "its", "context", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L225-L232
147,274
rs/zerolog
log.go
UpdateContext
func (l *Logger) UpdateContext(update func(c Context) Context) { if l == disabledLogger { return } if cap(l.context) == 0 { l.context = make([]byte, 0, 500) } c := update(Context{*l}) l.context = c.l.context }
go
func (l *Logger) UpdateContext(update func(c Context) Context) { if l == disabledLogger { return } if cap(l.context) == 0 { l.context = make([]byte, 0, 500) } c := update(Context{*l}) l.context = c.l.context }
[ "func", "(", "l", "*", "Logger", ")", "UpdateContext", "(", "update", "func", "(", "c", "Context", ")", "Context", ")", "{", "if", "l", "==", "disabledLogger", "{", "return", "\n", "}", "\n", "if", "cap", "(", "l", ".", "context", ")", "==", "0", "{", "l", ".", "context", "=", "make", "(", "[", "]", "byte", ",", "0", ",", "500", ")", "\n", "}", "\n", "c", ":=", "update", "(", "Context", "{", "*", "l", "}", ")", "\n", "l", ".", "context", "=", "c", ".", "l", ".", "context", "\n", "}" ]
// UpdateContext updates the internal logger's context. // // Use this method with caution. If unsure, prefer the With method.
[ "UpdateContext", "updates", "the", "internal", "logger", "s", "context", ".", "Use", "this", "method", "with", "caution", ".", "If", "unsure", "prefer", "the", "With", "method", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L237-L246
147,275
rs/zerolog
log.go
Level
func (l Logger) Level(lvl Level) Logger { l.level = lvl return l }
go
func (l Logger) Level(lvl Level) Logger { l.level = lvl return l }
[ "func", "(", "l", "Logger", ")", "Level", "(", "lvl", "Level", ")", "Logger", "{", "l", ".", "level", "=", "lvl", "\n", "return", "l", "\n", "}" ]
// Level creates a child logger with the minimum accepted level set to level.
[ "Level", "creates", "a", "child", "logger", "with", "the", "minimum", "accepted", "level", "set", "to", "level", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L249-L252
147,276
rs/zerolog
log.go
Sample
func (l Logger) Sample(s Sampler) Logger { l.sampler = s return l }
go
func (l Logger) Sample(s Sampler) Logger { l.sampler = s return l }
[ "func", "(", "l", "Logger", ")", "Sample", "(", "s", "Sampler", ")", "Logger", "{", "l", ".", "sampler", "=", "s", "\n", "return", "l", "\n", "}" ]
// Sample returns a logger with the s sampler.
[ "Sample", "returns", "a", "logger", "with", "the", "s", "sampler", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L255-L258
147,277
rs/zerolog
log.go
Hook
func (l Logger) Hook(h Hook) Logger { l.hooks = append(l.hooks, h) return l }
go
func (l Logger) Hook(h Hook) Logger { l.hooks = append(l.hooks, h) return l }
[ "func", "(", "l", "Logger", ")", "Hook", "(", "h", "Hook", ")", "Logger", "{", "l", ".", "hooks", "=", "append", "(", "l", ".", "hooks", ",", "h", ")", "\n", "return", "l", "\n", "}" ]
// Hook returns a logger with the h Hook.
[ "Hook", "returns", "a", "logger", "with", "the", "h", "Hook", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L261-L264
147,278
rs/zerolog
log.go
Err
func (l *Logger) Err(err error) *Event { if err != nil { return l.Error().Err(err) } else { return l.Info() } }
go
func (l *Logger) Err(err error) *Event { if err != nil { return l.Error().Err(err) } else { return l.Info() } }
[ "func", "(", "l", "*", "Logger", ")", "Err", "(", "err", "error", ")", "*", "Event", "{", "if", "err", "!=", "nil", "{", "return", "l", ".", "Error", "(", ")", ".", "Err", "(", "err", ")", "\n", "}", "else", "{", "return", "l", ".", "Info", "(", ")", "\n", "}", "\n", "}" ]
// Err starts a new message with error level with err as a field if not nil or // with info level if err is nil. // // You must call Msg on the returned event in order to send the event.
[ "Err", "starts", "a", "new", "message", "with", "error", "level", "with", "err", "as", "a", "field", "if", "not", "nil", "or", "with", "info", "level", "if", "err", "is", "nil", ".", "You", "must", "call", "Msg", "on", "the", "returned", "event", "in", "order", "to", "send", "the", "event", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L298-L304
147,279
rs/zerolog
log.go
WithLevel
func (l *Logger) WithLevel(level Level) *Event { switch level { case DebugLevel: return l.Debug() case InfoLevel: return l.Info() case WarnLevel: return l.Warn() case ErrorLevel: return l.Error() case FatalLevel: return l.newEvent(FatalLevel, nil) case PanicLevel: return l.newEvent(PanicLevel, nil) case NoLevel: return l.Log() case Disabled: return nil default: panic("zerolog: WithLevel(): invalid level: " + strconv.Itoa(int(level))) } }
go
func (l *Logger) WithLevel(level Level) *Event { switch level { case DebugLevel: return l.Debug() case InfoLevel: return l.Info() case WarnLevel: return l.Warn() case ErrorLevel: return l.Error() case FatalLevel: return l.newEvent(FatalLevel, nil) case PanicLevel: return l.newEvent(PanicLevel, nil) case NoLevel: return l.Log() case Disabled: return nil default: panic("zerolog: WithLevel(): invalid level: " + strconv.Itoa(int(level))) } }
[ "func", "(", "l", "*", "Logger", ")", "WithLevel", "(", "level", "Level", ")", "*", "Event", "{", "switch", "level", "{", "case", "DebugLevel", ":", "return", "l", ".", "Debug", "(", ")", "\n", "case", "InfoLevel", ":", "return", "l", ".", "Info", "(", ")", "\n", "case", "WarnLevel", ":", "return", "l", ".", "Warn", "(", ")", "\n", "case", "ErrorLevel", ":", "return", "l", ".", "Error", "(", ")", "\n", "case", "FatalLevel", ":", "return", "l", ".", "newEvent", "(", "FatalLevel", ",", "nil", ")", "\n", "case", "PanicLevel", ":", "return", "l", ".", "newEvent", "(", "PanicLevel", ",", "nil", ")", "\n", "case", "NoLevel", ":", "return", "l", ".", "Log", "(", ")", "\n", "case", "Disabled", ":", "return", "nil", "\n", "default", ":", "panic", "(", "\"", "\"", "+", "strconv", ".", "Itoa", "(", "int", "(", "level", ")", ")", ")", "\n", "}", "\n", "}" ]
// WithLevel starts a new message with level. Unlike Fatal and Panic // methods, WithLevel does not terminate the program or stop the ordinary // flow of a gourotine when used with their respective levels. // // You must call Msg on the returned event in order to send the event.
[ "WithLevel", "starts", "a", "new", "message", "with", "level", ".", "Unlike", "Fatal", "and", "Panic", "methods", "WithLevel", "does", "not", "terminate", "the", "program", "or", "stop", "the", "ordinary", "flow", "of", "a", "gourotine", "when", "used", "with", "their", "respective", "levels", ".", "You", "must", "call", "Msg", "on", "the", "returned", "event", "in", "order", "to", "send", "the", "event", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L327-L348
147,280
rs/zerolog
log.go
Print
func (l *Logger) Print(v ...interface{}) { if e := l.Debug(); e.Enabled() { e.Msg(fmt.Sprint(v...)) } }
go
func (l *Logger) Print(v ...interface{}) { if e := l.Debug(); e.Enabled() { e.Msg(fmt.Sprint(v...)) } }
[ "func", "(", "l", "*", "Logger", ")", "Print", "(", "v", "...", "interface", "{", "}", ")", "{", "if", "e", ":=", "l", ".", "Debug", "(", ")", ";", "e", ".", "Enabled", "(", ")", "{", "e", ".", "Msg", "(", "fmt", ".", "Sprint", "(", "v", "...", ")", ")", "\n", "}", "\n", "}" ]
// Print sends a log event using debug level and no extra field. // Arguments are handled in the manner of fmt.Print.
[ "Print", "sends", "a", "log", "event", "using", "debug", "level", "and", "no", "extra", "field", ".", "Arguments", "are", "handled", "in", "the", "manner", "of", "fmt", ".", "Print", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L360-L364
147,281
rs/zerolog
log.go
Printf
func (l *Logger) Printf(format string, v ...interface{}) { if e := l.Debug(); e.Enabled() { e.Msg(fmt.Sprintf(format, v...)) } }
go
func (l *Logger) Printf(format string, v ...interface{}) { if e := l.Debug(); e.Enabled() { e.Msg(fmt.Sprintf(format, v...)) } }
[ "func", "(", "l", "*", "Logger", ")", "Printf", "(", "format", "string", ",", "v", "...", "interface", "{", "}", ")", "{", "if", "e", ":=", "l", ".", "Debug", "(", ")", ";", "e", ".", "Enabled", "(", ")", "{", "e", ".", "Msg", "(", "fmt", ".", "Sprintf", "(", "format", ",", "v", "...", ")", ")", "\n", "}", "\n", "}" ]
// Printf sends a log event using debug level and no extra field. // Arguments are handled in the manner of fmt.Printf.
[ "Printf", "sends", "a", "log", "event", "using", "debug", "level", "and", "no", "extra", "field", ".", "Arguments", "are", "handled", "in", "the", "manner", "of", "fmt", ".", "Printf", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L368-L372
147,282
rs/zerolog
log.go
Write
func (l Logger) Write(p []byte) (n int, err error) { n = len(p) if n > 0 && p[n-1] == '\n' { // Trim CR added by stdlog. p = p[0 : n-1] } l.Log().Msg(string(p)) return }
go
func (l Logger) Write(p []byte) (n int, err error) { n = len(p) if n > 0 && p[n-1] == '\n' { // Trim CR added by stdlog. p = p[0 : n-1] } l.Log().Msg(string(p)) return }
[ "func", "(", "l", "Logger", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "n", "=", "len", "(", "p", ")", "\n", "if", "n", ">", "0", "&&", "p", "[", "n", "-", "1", "]", "==", "'\\n'", "{", "// Trim CR added by stdlog.", "p", "=", "p", "[", "0", ":", "n", "-", "1", "]", "\n", "}", "\n", "l", ".", "Log", "(", ")", ".", "Msg", "(", "string", "(", "p", ")", ")", "\n", "return", "\n", "}" ]
// Write implements the io.Writer interface. This is useful to set as a writer // for the standard library log.
[ "Write", "implements", "the", "io", ".", "Writer", "interface", ".", "This", "is", "useful", "to", "set", "as", "a", "writer", "for", "the", "standard", "library", "log", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L376-L384
147,283
rs/zerolog
log.go
should
func (l *Logger) should(lvl Level) bool { if lvl < l.level || lvl < GlobalLevel() { return false } if l.sampler != nil && !samplingDisabled() { return l.sampler.Sample(lvl) } return true }
go
func (l *Logger) should(lvl Level) bool { if lvl < l.level || lvl < GlobalLevel() { return false } if l.sampler != nil && !samplingDisabled() { return l.sampler.Sample(lvl) } return true }
[ "func", "(", "l", "*", "Logger", ")", "should", "(", "lvl", "Level", ")", "bool", "{", "if", "lvl", "<", "l", ".", "level", "||", "lvl", "<", "GlobalLevel", "(", ")", "{", "return", "false", "\n", "}", "\n", "if", "l", ".", "sampler", "!=", "nil", "&&", "!", "samplingDisabled", "(", ")", "{", "return", "l", ".", "sampler", ".", "Sample", "(", "lvl", ")", "\n", "}", "\n", "return", "true", "\n", "}" ]
// should returns true if the log event should be logged.
[ "should", "returns", "true", "if", "the", "log", "event", "should", "be", "logged", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/log.go#L404-L412
147,284
rs/zerolog
console.go
NewConsoleWriter
func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter { w := ConsoleWriter{ Out: os.Stdout, TimeFormat: consoleDefaultTimeFormat, PartsOrder: consoleDefaultPartsOrder(), } for _, opt := range options { opt(&w) } return w }
go
func NewConsoleWriter(options ...func(w *ConsoleWriter)) ConsoleWriter { w := ConsoleWriter{ Out: os.Stdout, TimeFormat: consoleDefaultTimeFormat, PartsOrder: consoleDefaultPartsOrder(), } for _, opt := range options { opt(&w) } return w }
[ "func", "NewConsoleWriter", "(", "options", "...", "func", "(", "w", "*", "ConsoleWriter", ")", ")", "ConsoleWriter", "{", "w", ":=", "ConsoleWriter", "{", "Out", ":", "os", ".", "Stdout", ",", "TimeFormat", ":", "consoleDefaultTimeFormat", ",", "PartsOrder", ":", "consoleDefaultPartsOrder", "(", ")", ",", "}", "\n\n", "for", "_", ",", "opt", ":=", "range", "options", "{", "opt", "(", "&", "w", ")", "\n", "}", "\n\n", "return", "w", "\n", "}" ]
// NewConsoleWriter creates and initializes a new ConsoleWriter.
[ "NewConsoleWriter", "creates", "and", "initializes", "a", "new", "ConsoleWriter", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L71-L83
147,285
rs/zerolog
console.go
Write
func (w ConsoleWriter) Write(p []byte) (n int, err error) { if w.PartsOrder == nil { w.PartsOrder = consoleDefaultPartsOrder() } var buf = consoleBufPool.Get().(*bytes.Buffer) defer func() { buf.Reset() consoleBufPool.Put(buf) }() var evt map[string]interface{} p = decodeIfBinaryToBytes(p) d := json.NewDecoder(bytes.NewReader(p)) d.UseNumber() err = d.Decode(&evt) if err != nil { return n, fmt.Errorf("cannot decode event: %s", err) } for _, p := range w.PartsOrder { w.writePart(buf, evt, p) } w.writeFields(evt, buf) err = buf.WriteByte('\n') if err != nil { return n, err } _, err = buf.WriteTo(w.Out) return len(p), err }
go
func (w ConsoleWriter) Write(p []byte) (n int, err error) { if w.PartsOrder == nil { w.PartsOrder = consoleDefaultPartsOrder() } var buf = consoleBufPool.Get().(*bytes.Buffer) defer func() { buf.Reset() consoleBufPool.Put(buf) }() var evt map[string]interface{} p = decodeIfBinaryToBytes(p) d := json.NewDecoder(bytes.NewReader(p)) d.UseNumber() err = d.Decode(&evt) if err != nil { return n, fmt.Errorf("cannot decode event: %s", err) } for _, p := range w.PartsOrder { w.writePart(buf, evt, p) } w.writeFields(evt, buf) err = buf.WriteByte('\n') if err != nil { return n, err } _, err = buf.WriteTo(w.Out) return len(p), err }
[ "func", "(", "w", "ConsoleWriter", ")", "Write", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "if", "w", ".", "PartsOrder", "==", "nil", "{", "w", ".", "PartsOrder", "=", "consoleDefaultPartsOrder", "(", ")", "\n", "}", "\n\n", "var", "buf", "=", "consoleBufPool", ".", "Get", "(", ")", ".", "(", "*", "bytes", ".", "Buffer", ")", "\n", "defer", "func", "(", ")", "{", "buf", ".", "Reset", "(", ")", "\n", "consoleBufPool", ".", "Put", "(", "buf", ")", "\n", "}", "(", ")", "\n\n", "var", "evt", "map", "[", "string", "]", "interface", "{", "}", "\n", "p", "=", "decodeIfBinaryToBytes", "(", "p", ")", "\n", "d", ":=", "json", ".", "NewDecoder", "(", "bytes", ".", "NewReader", "(", "p", ")", ")", "\n", "d", ".", "UseNumber", "(", ")", "\n", "err", "=", "d", ".", "Decode", "(", "&", "evt", ")", "\n", "if", "err", "!=", "nil", "{", "return", "n", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "for", "_", ",", "p", ":=", "range", "w", ".", "PartsOrder", "{", "w", ".", "writePart", "(", "buf", ",", "evt", ",", "p", ")", "\n", "}", "\n\n", "w", ".", "writeFields", "(", "evt", ",", "buf", ")", "\n\n", "err", "=", "buf", ".", "WriteByte", "(", "'\\n'", ")", "\n", "if", "err", "!=", "nil", "{", "return", "n", ",", "err", "\n", "}", "\n", "_", ",", "err", "=", "buf", ".", "WriteTo", "(", "w", ".", "Out", ")", "\n", "return", "len", "(", "p", ")", ",", "err", "\n", "}" ]
// Write transforms the JSON input with formatters and appends to w.Out.
[ "Write", "transforms", "the", "JSON", "input", "with", "formatters", "and", "appends", "to", "w", ".", "Out", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L86-L118
147,286
rs/zerolog
console.go
writeFields
func (w ConsoleWriter) writeFields(evt map[string]interface{}, buf *bytes.Buffer) { var fields = make([]string, 0, len(evt)) for field := range evt { switch field { case LevelFieldName, TimestampFieldName, MessageFieldName, CallerFieldName: continue } fields = append(fields, field) } sort.Strings(fields) if len(fields) > 0 { buf.WriteByte(' ') } // Move the "error" field to the front ei := sort.Search(len(fields), func(i int) bool { return fields[i] >= ErrorFieldName }) if ei < len(fields) && fields[ei] == ErrorFieldName { fields[ei] = "" fields = append([]string{ErrorFieldName}, fields...) var xfields = make([]string, 0, len(fields)) for _, field := range fields { if field == "" { // Skip empty fields continue } xfields = append(xfields, field) } fields = xfields } for i, field := range fields { var fn Formatter var fv Formatter if field == ErrorFieldName { if w.FormatErrFieldName == nil { fn = consoleDefaultFormatErrFieldName(w.NoColor) } else { fn = w.FormatErrFieldName } if w.FormatErrFieldValue == nil { fv = consoleDefaultFormatErrFieldValue(w.NoColor) } else { fv = w.FormatErrFieldValue } } else { if w.FormatFieldName == nil { fn = consoleDefaultFormatFieldName(w.NoColor) } else { fn = w.FormatFieldName } if w.FormatFieldValue == nil { fv = consoleDefaultFormatFieldValue } else { fv = w.FormatFieldValue } } buf.WriteString(fn(field)) switch fValue := evt[field].(type) { case string: if needsQuote(fValue) { buf.WriteString(fv(strconv.Quote(fValue))) } else { buf.WriteString(fv(fValue)) } case json.Number: buf.WriteString(fv(fValue)) default: b, err := json.Marshal(fValue) if err != nil { fmt.Fprintf(buf, colorize("[error: %v]", colorRed, w.NoColor), err) } else { fmt.Fprint(buf, fv(b)) } } if i < len(fields)-1 { // Skip space for last field buf.WriteByte(' ') } } }
go
func (w ConsoleWriter) writeFields(evt map[string]interface{}, buf *bytes.Buffer) { var fields = make([]string, 0, len(evt)) for field := range evt { switch field { case LevelFieldName, TimestampFieldName, MessageFieldName, CallerFieldName: continue } fields = append(fields, field) } sort.Strings(fields) if len(fields) > 0 { buf.WriteByte(' ') } // Move the "error" field to the front ei := sort.Search(len(fields), func(i int) bool { return fields[i] >= ErrorFieldName }) if ei < len(fields) && fields[ei] == ErrorFieldName { fields[ei] = "" fields = append([]string{ErrorFieldName}, fields...) var xfields = make([]string, 0, len(fields)) for _, field := range fields { if field == "" { // Skip empty fields continue } xfields = append(xfields, field) } fields = xfields } for i, field := range fields { var fn Formatter var fv Formatter if field == ErrorFieldName { if w.FormatErrFieldName == nil { fn = consoleDefaultFormatErrFieldName(w.NoColor) } else { fn = w.FormatErrFieldName } if w.FormatErrFieldValue == nil { fv = consoleDefaultFormatErrFieldValue(w.NoColor) } else { fv = w.FormatErrFieldValue } } else { if w.FormatFieldName == nil { fn = consoleDefaultFormatFieldName(w.NoColor) } else { fn = w.FormatFieldName } if w.FormatFieldValue == nil { fv = consoleDefaultFormatFieldValue } else { fv = w.FormatFieldValue } } buf.WriteString(fn(field)) switch fValue := evt[field].(type) { case string: if needsQuote(fValue) { buf.WriteString(fv(strconv.Quote(fValue))) } else { buf.WriteString(fv(fValue)) } case json.Number: buf.WriteString(fv(fValue)) default: b, err := json.Marshal(fValue) if err != nil { fmt.Fprintf(buf, colorize("[error: %v]", colorRed, w.NoColor), err) } else { fmt.Fprint(buf, fv(b)) } } if i < len(fields)-1 { // Skip space for last field buf.WriteByte(' ') } } }
[ "func", "(", "w", "ConsoleWriter", ")", "writeFields", "(", "evt", "map", "[", "string", "]", "interface", "{", "}", ",", "buf", "*", "bytes", ".", "Buffer", ")", "{", "var", "fields", "=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "evt", ")", ")", "\n", "for", "field", ":=", "range", "evt", "{", "switch", "field", "{", "case", "LevelFieldName", ",", "TimestampFieldName", ",", "MessageFieldName", ",", "CallerFieldName", ":", "continue", "\n", "}", "\n", "fields", "=", "append", "(", "fields", ",", "field", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "fields", ")", "\n\n", "if", "len", "(", "fields", ")", ">", "0", "{", "buf", ".", "WriteByte", "(", "' '", ")", "\n", "}", "\n\n", "// Move the \"error\" field to the front", "ei", ":=", "sort", ".", "Search", "(", "len", "(", "fields", ")", ",", "func", "(", "i", "int", ")", "bool", "{", "return", "fields", "[", "i", "]", ">=", "ErrorFieldName", "}", ")", "\n", "if", "ei", "<", "len", "(", "fields", ")", "&&", "fields", "[", "ei", "]", "==", "ErrorFieldName", "{", "fields", "[", "ei", "]", "=", "\"", "\"", "\n", "fields", "=", "append", "(", "[", "]", "string", "{", "ErrorFieldName", "}", ",", "fields", "...", ")", "\n", "var", "xfields", "=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "fields", ")", ")", "\n", "for", "_", ",", "field", ":=", "range", "fields", "{", "if", "field", "==", "\"", "\"", "{", "// Skip empty fields", "continue", "\n", "}", "\n", "xfields", "=", "append", "(", "xfields", ",", "field", ")", "\n", "}", "\n", "fields", "=", "xfields", "\n", "}", "\n\n", "for", "i", ",", "field", ":=", "range", "fields", "{", "var", "fn", "Formatter", "\n", "var", "fv", "Formatter", "\n\n", "if", "field", "==", "ErrorFieldName", "{", "if", "w", ".", "FormatErrFieldName", "==", "nil", "{", "fn", "=", "consoleDefaultFormatErrFieldName", "(", "w", ".", "NoColor", ")", "\n", "}", "else", "{", "fn", "=", "w", ".", "FormatErrFieldName", "\n", "}", "\n\n", "if", "w", ".", "FormatErrFieldValue", "==", "nil", "{", "fv", "=", "consoleDefaultFormatErrFieldValue", "(", "w", ".", "NoColor", ")", "\n", "}", "else", "{", "fv", "=", "w", ".", "FormatErrFieldValue", "\n", "}", "\n", "}", "else", "{", "if", "w", ".", "FormatFieldName", "==", "nil", "{", "fn", "=", "consoleDefaultFormatFieldName", "(", "w", ".", "NoColor", ")", "\n", "}", "else", "{", "fn", "=", "w", ".", "FormatFieldName", "\n", "}", "\n\n", "if", "w", ".", "FormatFieldValue", "==", "nil", "{", "fv", "=", "consoleDefaultFormatFieldValue", "\n", "}", "else", "{", "fv", "=", "w", ".", "FormatFieldValue", "\n", "}", "\n", "}", "\n\n", "buf", ".", "WriteString", "(", "fn", "(", "field", ")", ")", "\n\n", "switch", "fValue", ":=", "evt", "[", "field", "]", ".", "(", "type", ")", "{", "case", "string", ":", "if", "needsQuote", "(", "fValue", ")", "{", "buf", ".", "WriteString", "(", "fv", "(", "strconv", ".", "Quote", "(", "fValue", ")", ")", ")", "\n", "}", "else", "{", "buf", ".", "WriteString", "(", "fv", "(", "fValue", ")", ")", "\n", "}", "\n", "case", "json", ".", "Number", ":", "buf", ".", "WriteString", "(", "fv", "(", "fValue", ")", ")", "\n", "default", ":", "b", ",", "err", ":=", "json", ".", "Marshal", "(", "fValue", ")", "\n", "if", "err", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "buf", ",", "colorize", "(", "\"", "\"", ",", "colorRed", ",", "w", ".", "NoColor", ")", ",", "err", ")", "\n", "}", "else", "{", "fmt", ".", "Fprint", "(", "buf", ",", "fv", "(", "b", ")", ")", "\n", "}", "\n", "}", "\n\n", "if", "i", "<", "len", "(", "fields", ")", "-", "1", "{", "// Skip space for last field", "buf", ".", "WriteByte", "(", "' '", ")", "\n", "}", "\n", "}", "\n", "}" ]
// writeFields appends formatted key-value pairs to buf.
[ "writeFields", "appends", "formatted", "key", "-", "value", "pairs", "to", "buf", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L121-L205
147,287
rs/zerolog
console.go
writePart
func (w ConsoleWriter) writePart(buf *bytes.Buffer, evt map[string]interface{}, p string) { var f Formatter switch p { case LevelFieldName: if w.FormatLevel == nil { f = consoleDefaultFormatLevel(w.NoColor) } else { f = w.FormatLevel } case TimestampFieldName: if w.FormatTimestamp == nil { f = consoleDefaultFormatTimestamp(w.TimeFormat, w.NoColor) } else { f = w.FormatTimestamp } case MessageFieldName: if w.FormatMessage == nil { f = consoleDefaultFormatMessage } else { f = w.FormatMessage } case CallerFieldName: if w.FormatCaller == nil { f = consoleDefaultFormatCaller(w.NoColor) } else { f = w.FormatCaller } default: if w.FormatFieldValue == nil { f = consoleDefaultFormatFieldValue } else { f = w.FormatFieldValue } } var s = f(evt[p]) if len(s) > 0 { buf.WriteString(s) if p != w.PartsOrder[len(w.PartsOrder)-1] { // Skip space for last part buf.WriteByte(' ') } } }
go
func (w ConsoleWriter) writePart(buf *bytes.Buffer, evt map[string]interface{}, p string) { var f Formatter switch p { case LevelFieldName: if w.FormatLevel == nil { f = consoleDefaultFormatLevel(w.NoColor) } else { f = w.FormatLevel } case TimestampFieldName: if w.FormatTimestamp == nil { f = consoleDefaultFormatTimestamp(w.TimeFormat, w.NoColor) } else { f = w.FormatTimestamp } case MessageFieldName: if w.FormatMessage == nil { f = consoleDefaultFormatMessage } else { f = w.FormatMessage } case CallerFieldName: if w.FormatCaller == nil { f = consoleDefaultFormatCaller(w.NoColor) } else { f = w.FormatCaller } default: if w.FormatFieldValue == nil { f = consoleDefaultFormatFieldValue } else { f = w.FormatFieldValue } } var s = f(evt[p]) if len(s) > 0 { buf.WriteString(s) if p != w.PartsOrder[len(w.PartsOrder)-1] { // Skip space for last part buf.WriteByte(' ') } } }
[ "func", "(", "w", "ConsoleWriter", ")", "writePart", "(", "buf", "*", "bytes", ".", "Buffer", ",", "evt", "map", "[", "string", "]", "interface", "{", "}", ",", "p", "string", ")", "{", "var", "f", "Formatter", "\n\n", "switch", "p", "{", "case", "LevelFieldName", ":", "if", "w", ".", "FormatLevel", "==", "nil", "{", "f", "=", "consoleDefaultFormatLevel", "(", "w", ".", "NoColor", ")", "\n", "}", "else", "{", "f", "=", "w", ".", "FormatLevel", "\n", "}", "\n", "case", "TimestampFieldName", ":", "if", "w", ".", "FormatTimestamp", "==", "nil", "{", "f", "=", "consoleDefaultFormatTimestamp", "(", "w", ".", "TimeFormat", ",", "w", ".", "NoColor", ")", "\n", "}", "else", "{", "f", "=", "w", ".", "FormatTimestamp", "\n", "}", "\n", "case", "MessageFieldName", ":", "if", "w", ".", "FormatMessage", "==", "nil", "{", "f", "=", "consoleDefaultFormatMessage", "\n", "}", "else", "{", "f", "=", "w", ".", "FormatMessage", "\n", "}", "\n", "case", "CallerFieldName", ":", "if", "w", ".", "FormatCaller", "==", "nil", "{", "f", "=", "consoleDefaultFormatCaller", "(", "w", ".", "NoColor", ")", "\n", "}", "else", "{", "f", "=", "w", ".", "FormatCaller", "\n", "}", "\n", "default", ":", "if", "w", ".", "FormatFieldValue", "==", "nil", "{", "f", "=", "consoleDefaultFormatFieldValue", "\n", "}", "else", "{", "f", "=", "w", ".", "FormatFieldValue", "\n", "}", "\n", "}", "\n\n", "var", "s", "=", "f", "(", "evt", "[", "p", "]", ")", "\n\n", "if", "len", "(", "s", ")", ">", "0", "{", "buf", ".", "WriteString", "(", "s", ")", "\n", "if", "p", "!=", "w", ".", "PartsOrder", "[", "len", "(", "w", ".", "PartsOrder", ")", "-", "1", "]", "{", "// Skip space for last part", "buf", ".", "WriteByte", "(", "' '", ")", "\n", "}", "\n", "}", "\n", "}" ]
// writePart appends a formatted part to buf.
[ "writePart", "appends", "a", "formatted", "part", "to", "buf", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L208-L252
147,288
rs/zerolog
console.go
needsQuote
func needsQuote(s string) bool { for i := range s { if s[i] < 0x20 || s[i] > 0x7e || s[i] == ' ' || s[i] == '\\' || s[i] == '"' { return true } } return false }
go
func needsQuote(s string) bool { for i := range s { if s[i] < 0x20 || s[i] > 0x7e || s[i] == ' ' || s[i] == '\\' || s[i] == '"' { return true } } return false }
[ "func", "needsQuote", "(", "s", "string", ")", "bool", "{", "for", "i", ":=", "range", "s", "{", "if", "s", "[", "i", "]", "<", "0x20", "||", "s", "[", "i", "]", ">", "0x7e", "||", "s", "[", "i", "]", "==", "' '", "||", "s", "[", "i", "]", "==", "'\\\\'", "||", "s", "[", "i", "]", "==", "'\"'", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// needsQuote returns true when the string s should be quoted in output.
[ "needsQuote", "returns", "true", "when", "the", "string", "s", "should", "be", "quoted", "in", "output", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L255-L262
147,289
rs/zerolog
console.go
colorize
func colorize(s interface{}, c int, disabled bool) string { if disabled { return fmt.Sprintf("%s", s) } return fmt.Sprintf("\x1b[%dm%v\x1b[0m", c, s) }
go
func colorize(s interface{}, c int, disabled bool) string { if disabled { return fmt.Sprintf("%s", s) } return fmt.Sprintf("\x1b[%dm%v\x1b[0m", c, s) }
[ "func", "colorize", "(", "s", "interface", "{", "}", ",", "c", "int", ",", "disabled", "bool", ")", "string", "{", "if", "disabled", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "s", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\\x1b", "\\x1b", "\"", ",", "c", ",", "s", ")", "\n", "}" ]
// colorize returns the string s wrapped in ANSI code c, unless disabled is true.
[ "colorize", "returns", "the", "string", "s", "wrapped", "in", "ANSI", "code", "c", "unless", "disabled", "is", "true", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/console.go#L265-L270
147,290
rs/zerolog
syslog.go
WriteLevel
func (sw syslogWriter) WriteLevel(level Level, p []byte) (n int, err error) { switch level { case DebugLevel: err = sw.w.Debug(string(p)) case InfoLevel: err = sw.w.Info(string(p)) case WarnLevel: err = sw.w.Warning(string(p)) case ErrorLevel: err = sw.w.Err(string(p)) case FatalLevel: err = sw.w.Emerg(string(p)) case PanicLevel: err = sw.w.Crit(string(p)) case NoLevel: err = sw.w.Info(string(p)) default: panic("invalid level") } n = len(p) return }
go
func (sw syslogWriter) WriteLevel(level Level, p []byte) (n int, err error) { switch level { case DebugLevel: err = sw.w.Debug(string(p)) case InfoLevel: err = sw.w.Info(string(p)) case WarnLevel: err = sw.w.Warning(string(p)) case ErrorLevel: err = sw.w.Err(string(p)) case FatalLevel: err = sw.w.Emerg(string(p)) case PanicLevel: err = sw.w.Crit(string(p)) case NoLevel: err = sw.w.Info(string(p)) default: panic("invalid level") } n = len(p) return }
[ "func", "(", "sw", "syslogWriter", ")", "WriteLevel", "(", "level", "Level", ",", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "switch", "level", "{", "case", "DebugLevel", ":", "err", "=", "sw", ".", "w", ".", "Debug", "(", "string", "(", "p", ")", ")", "\n", "case", "InfoLevel", ":", "err", "=", "sw", ".", "w", ".", "Info", "(", "string", "(", "p", ")", ")", "\n", "case", "WarnLevel", ":", "err", "=", "sw", ".", "w", ".", "Warning", "(", "string", "(", "p", ")", ")", "\n", "case", "ErrorLevel", ":", "err", "=", "sw", ".", "w", ".", "Err", "(", "string", "(", "p", ")", ")", "\n", "case", "FatalLevel", ":", "err", "=", "sw", ".", "w", ".", "Emerg", "(", "string", "(", "p", ")", ")", "\n", "case", "PanicLevel", ":", "err", "=", "sw", ".", "w", ".", "Crit", "(", "string", "(", "p", ")", ")", "\n", "case", "NoLevel", ":", "err", "=", "sw", ".", "w", ".", "Info", "(", "string", "(", "p", ")", ")", "\n", "default", ":", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "n", "=", "len", "(", "p", ")", "\n", "return", "\n", "}" ]
// WriteLevel implements LevelWriter interface.
[ "WriteLevel", "implements", "LevelWriter", "interface", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/syslog.go#L36-L57
147,291
rs/zerolog
internal/cbor/time.go
AppendTime
func (e Encoder) AppendTime(dst []byte, t time.Time, unused string) []byte { utc := t.UTC() if utc.Nanosecond() == 0 { return appendIntegerTimestamp(dst, utc) } return e.appendFloatTimestamp(dst, utc) }
go
func (e Encoder) AppendTime(dst []byte, t time.Time, unused string) []byte { utc := t.UTC() if utc.Nanosecond() == 0 { return appendIntegerTimestamp(dst, utc) } return e.appendFloatTimestamp(dst, utc) }
[ "func", "(", "e", "Encoder", ")", "AppendTime", "(", "dst", "[", "]", "byte", ",", "t", "time", ".", "Time", ",", "unused", "string", ")", "[", "]", "byte", "{", "utc", ":=", "t", ".", "UTC", "(", ")", "\n", "if", "utc", ".", "Nanosecond", "(", ")", "==", "0", "{", "return", "appendIntegerTimestamp", "(", "dst", ",", "utc", ")", "\n", "}", "\n", "return", "e", ".", "appendFloatTimestamp", "(", "dst", ",", "utc", ")", "\n", "}" ]
// AppendTime encodes and adds a timestamp to the dst byte array.
[ "AppendTime", "encodes", "and", "adds", "a", "timestamp", "to", "the", "dst", "byte", "array", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/time.go#L36-L42
147,292
rs/zerolog
internal/cbor/time.go
AppendTimes
func (e Encoder) AppendTimes(dst []byte, vals []time.Time, unused string) []byte { major := majorTypeArray l := len(vals) if l == 0 { return e.AppendArrayEnd(e.AppendArrayStart(dst)) } if l <= additionalMax { lb := byte(l) dst = append(dst, byte(major|lb)) } else { dst = appendCborTypePrefix(dst, major, uint64(l)) } for _, t := range vals { dst = e.AppendTime(dst, t, unused) } return dst }
go
func (e Encoder) AppendTimes(dst []byte, vals []time.Time, unused string) []byte { major := majorTypeArray l := len(vals) if l == 0 { return e.AppendArrayEnd(e.AppendArrayStart(dst)) } if l <= additionalMax { lb := byte(l) dst = append(dst, byte(major|lb)) } else { dst = appendCborTypePrefix(dst, major, uint64(l)) } for _, t := range vals { dst = e.AppendTime(dst, t, unused) } return dst }
[ "func", "(", "e", "Encoder", ")", "AppendTimes", "(", "dst", "[", "]", "byte", ",", "vals", "[", "]", "time", ".", "Time", ",", "unused", "string", ")", "[", "]", "byte", "{", "major", ":=", "majorTypeArray", "\n", "l", ":=", "len", "(", "vals", ")", "\n", "if", "l", "==", "0", "{", "return", "e", ".", "AppendArrayEnd", "(", "e", ".", "AppendArrayStart", "(", "dst", ")", ")", "\n", "}", "\n", "if", "l", "<=", "additionalMax", "{", "lb", ":=", "byte", "(", "l", ")", "\n", "dst", "=", "append", "(", "dst", ",", "byte", "(", "major", "|", "lb", ")", ")", "\n", "}", "else", "{", "dst", "=", "appendCborTypePrefix", "(", "dst", ",", "major", ",", "uint64", "(", "l", ")", ")", "\n", "}", "\n\n", "for", "_", ",", "t", ":=", "range", "vals", "{", "dst", "=", "e", ".", "AppendTime", "(", "dst", ",", "t", ",", "unused", ")", "\n", "}", "\n", "return", "dst", "\n", "}" ]
// AppendTimes encodes and adds an array of timestamps to the dst byte array.
[ "AppendTimes", "encodes", "and", "adds", "an", "array", "of", "timestamps", "to", "the", "dst", "byte", "array", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/cbor/time.go#L45-L62
147,293
rs/zerolog
internal/json/types.go
AppendArrayDelim
func (Encoder) AppendArrayDelim(dst []byte) []byte { if len(dst) > 0 { return append(dst, ',') } return dst }
go
func (Encoder) AppendArrayDelim(dst []byte) []byte { if len(dst) > 0 { return append(dst, ',') } return dst }
[ "func", "(", "Encoder", ")", "AppendArrayDelim", "(", "dst", "[", "]", "byte", ")", "[", "]", "byte", "{", "if", "len", "(", "dst", ")", ">", "0", "{", "return", "append", "(", "dst", ",", "','", ")", "\n", "}", "\n", "return", "dst", "\n", "}" ]
// AppendArrayDelim adds markers to indicate end of a particular array element.
[ "AppendArrayDelim", "adds", "markers", "to", "indicate", "end", "of", "a", "particular", "array", "element", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L42-L47
147,294
rs/zerolog
internal/json/types.go
AppendBool
func (Encoder) AppendBool(dst []byte, val bool) []byte { return strconv.AppendBool(dst, val) }
go
func (Encoder) AppendBool(dst []byte, val bool) []byte { return strconv.AppendBool(dst, val) }
[ "func", "(", "Encoder", ")", "AppendBool", "(", "dst", "[", "]", "byte", ",", "val", "bool", ")", "[", "]", "byte", "{", "return", "strconv", ".", "AppendBool", "(", "dst", ",", "val", ")", "\n", "}" ]
// AppendBool converts the input bool to a string and // appends the encoded string to the input byte slice.
[ "AppendBool", "converts", "the", "input", "bool", "to", "a", "string", "and", "appends", "the", "encoded", "string", "to", "the", "input", "byte", "slice", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L51-L53
147,295
rs/zerolog
internal/json/types.go
AppendBools
func (Encoder) AppendBools(dst []byte, vals []bool) []byte { if len(vals) == 0 { return append(dst, '[', ']') } dst = append(dst, '[') dst = strconv.AppendBool(dst, vals[0]) if len(vals) > 1 { for _, val := range vals[1:] { dst = strconv.AppendBool(append(dst, ','), val) } } dst = append(dst, ']') return dst }
go
func (Encoder) AppendBools(dst []byte, vals []bool) []byte { if len(vals) == 0 { return append(dst, '[', ']') } dst = append(dst, '[') dst = strconv.AppendBool(dst, vals[0]) if len(vals) > 1 { for _, val := range vals[1:] { dst = strconv.AppendBool(append(dst, ','), val) } } dst = append(dst, ']') return dst }
[ "func", "(", "Encoder", ")", "AppendBools", "(", "dst", "[", "]", "byte", ",", "vals", "[", "]", "bool", ")", "[", "]", "byte", "{", "if", "len", "(", "vals", ")", "==", "0", "{", "return", "append", "(", "dst", ",", "'['", ",", "']'", ")", "\n", "}", "\n", "dst", "=", "append", "(", "dst", ",", "'['", ")", "\n", "dst", "=", "strconv", ".", "AppendBool", "(", "dst", ",", "vals", "[", "0", "]", ")", "\n", "if", "len", "(", "vals", ")", ">", "1", "{", "for", "_", ",", "val", ":=", "range", "vals", "[", "1", ":", "]", "{", "dst", "=", "strconv", ".", "AppendBool", "(", "append", "(", "dst", ",", "','", ")", ",", "val", ")", "\n", "}", "\n", "}", "\n", "dst", "=", "append", "(", "dst", ",", "']'", ")", "\n", "return", "dst", "\n", "}" ]
// AppendBools encodes the input bools to json and // appends the encoded string list to the input byte slice.
[ "AppendBools", "encodes", "the", "input", "bools", "to", "json", "and", "appends", "the", "encoded", "string", "list", "to", "the", "input", "byte", "slice", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L57-L70
147,296
rs/zerolog
internal/json/types.go
AppendInt
func (Encoder) AppendInt(dst []byte, val int) []byte { return strconv.AppendInt(dst, int64(val), 10) }
go
func (Encoder) AppendInt(dst []byte, val int) []byte { return strconv.AppendInt(dst, int64(val), 10) }
[ "func", "(", "Encoder", ")", "AppendInt", "(", "dst", "[", "]", "byte", ",", "val", "int", ")", "[", "]", "byte", "{", "return", "strconv", ".", "AppendInt", "(", "dst", ",", "int64", "(", "val", ")", ",", "10", ")", "\n", "}" ]
// AppendInt converts the input int to a string and // appends the encoded string to the input byte slice.
[ "AppendInt", "converts", "the", "input", "int", "to", "a", "string", "and", "appends", "the", "encoded", "string", "to", "the", "input", "byte", "slice", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L74-L76
147,297
rs/zerolog
internal/json/types.go
AppendInts
func (Encoder) AppendInts(dst []byte, vals []int) []byte { if len(vals) == 0 { return append(dst, '[', ']') } dst = append(dst, '[') dst = strconv.AppendInt(dst, int64(vals[0]), 10) if len(vals) > 1 { for _, val := range vals[1:] { dst = strconv.AppendInt(append(dst, ','), int64(val), 10) } } dst = append(dst, ']') return dst }
go
func (Encoder) AppendInts(dst []byte, vals []int) []byte { if len(vals) == 0 { return append(dst, '[', ']') } dst = append(dst, '[') dst = strconv.AppendInt(dst, int64(vals[0]), 10) if len(vals) > 1 { for _, val := range vals[1:] { dst = strconv.AppendInt(append(dst, ','), int64(val), 10) } } dst = append(dst, ']') return dst }
[ "func", "(", "Encoder", ")", "AppendInts", "(", "dst", "[", "]", "byte", ",", "vals", "[", "]", "int", ")", "[", "]", "byte", "{", "if", "len", "(", "vals", ")", "==", "0", "{", "return", "append", "(", "dst", ",", "'['", ",", "']'", ")", "\n", "}", "\n", "dst", "=", "append", "(", "dst", ",", "'['", ")", "\n", "dst", "=", "strconv", ".", "AppendInt", "(", "dst", ",", "int64", "(", "vals", "[", "0", "]", ")", ",", "10", ")", "\n", "if", "len", "(", "vals", ")", ">", "1", "{", "for", "_", ",", "val", ":=", "range", "vals", "[", "1", ":", "]", "{", "dst", "=", "strconv", ".", "AppendInt", "(", "append", "(", "dst", ",", "','", ")", ",", "int64", "(", "val", ")", ",", "10", ")", "\n", "}", "\n", "}", "\n", "dst", "=", "append", "(", "dst", ",", "']'", ")", "\n", "return", "dst", "\n", "}" ]
// AppendInts encodes the input ints to json and // appends the encoded string list to the input byte slice.
[ "AppendInts", "encodes", "the", "input", "ints", "to", "json", "and", "appends", "the", "encoded", "string", "list", "to", "the", "input", "byte", "slice", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L80-L93
147,298
rs/zerolog
internal/json/types.go
AppendInts8
func (Encoder) AppendInts8(dst []byte, vals []int8) []byte { if len(vals) == 0 { return append(dst, '[', ']') } dst = append(dst, '[') dst = strconv.AppendInt(dst, int64(vals[0]), 10) if len(vals) > 1 { for _, val := range vals[1:] { dst = strconv.AppendInt(append(dst, ','), int64(val), 10) } } dst = append(dst, ']') return dst }
go
func (Encoder) AppendInts8(dst []byte, vals []int8) []byte { if len(vals) == 0 { return append(dst, '[', ']') } dst = append(dst, '[') dst = strconv.AppendInt(dst, int64(vals[0]), 10) if len(vals) > 1 { for _, val := range vals[1:] { dst = strconv.AppendInt(append(dst, ','), int64(val), 10) } } dst = append(dst, ']') return dst }
[ "func", "(", "Encoder", ")", "AppendInts8", "(", "dst", "[", "]", "byte", ",", "vals", "[", "]", "int8", ")", "[", "]", "byte", "{", "if", "len", "(", "vals", ")", "==", "0", "{", "return", "append", "(", "dst", ",", "'['", ",", "']'", ")", "\n", "}", "\n", "dst", "=", "append", "(", "dst", ",", "'['", ")", "\n", "dst", "=", "strconv", ".", "AppendInt", "(", "dst", ",", "int64", "(", "vals", "[", "0", "]", ")", ",", "10", ")", "\n", "if", "len", "(", "vals", ")", ">", "1", "{", "for", "_", ",", "val", ":=", "range", "vals", "[", "1", ":", "]", "{", "dst", "=", "strconv", ".", "AppendInt", "(", "append", "(", "dst", ",", "','", ")", ",", "int64", "(", "val", ")", ",", "10", ")", "\n", "}", "\n", "}", "\n", "dst", "=", "append", "(", "dst", ",", "']'", ")", "\n", "return", "dst", "\n", "}" ]
// AppendInts8 encodes the input int8s to json and // appends the encoded string list to the input byte slice.
[ "AppendInts8", "encodes", "the", "input", "int8s", "to", "json", "and", "appends", "the", "encoded", "string", "list", "to", "the", "input", "byte", "slice", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L103-L116
147,299
rs/zerolog
internal/json/types.go
AppendInt16
func (Encoder) AppendInt16(dst []byte, val int16) []byte { return strconv.AppendInt(dst, int64(val), 10) }
go
func (Encoder) AppendInt16(dst []byte, val int16) []byte { return strconv.AppendInt(dst, int64(val), 10) }
[ "func", "(", "Encoder", ")", "AppendInt16", "(", "dst", "[", "]", "byte", ",", "val", "int16", ")", "[", "]", "byte", "{", "return", "strconv", ".", "AppendInt", "(", "dst", ",", "int64", "(", "val", ")", ",", "10", ")", "\n", "}" ]
// AppendInt16 converts the input int16 to a string and // appends the encoded string to the input byte slice.
[ "AppendInt16", "converts", "the", "input", "int16", "to", "a", "string", "and", "appends", "the", "encoded", "string", "to", "the", "input", "byte", "slice", "." ]
acf3980132bfcdc48638724e6e3d9e5749b85999
https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/types.go#L120-L122