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
163,200
cilium/cilium
pkg/maps/cidrmap/cidrmap.go
OpenMapElems
func OpenMapElems(path string, prefixlen int, prefixdyn bool, maxelem uint32) (*CIDRMap, bool, error) { var typeMap = bpf.BPF_MAP_TYPE_LPM_TRIE var prefix = 0 if prefixdyn == false { typeMap = bpf.BPF_MAP_TYPE_HASH prefix = prefixlen } if prefixlen <= 0 { return nil, false, fmt.Errorf("prefixlen must be > 0") } bytes := (prefixlen-1)/8 + 1 fd, isNewMap, err := bpf.OpenOrCreateMap( path, typeMap, uint32(unsafe.Sizeof(uint32(0))+uintptr(bytes)), uint32(LPM_MAP_VALUE_SIZE), maxelem, bpf.BPF_F_NO_PREALLOC, 0, ) if err != nil { log.Debug("Kernel does not support CIDR maps, using hash table instead.") typeMap = bpf.BPF_MAP_TYPE_HASH fd, isNewMap, err = bpf.OpenOrCreateMap( path, typeMap, uint32(unsafe.Sizeof(uint32(0))+uintptr(bytes)), uint32(LPM_MAP_VALUE_SIZE), maxelem, bpf.BPF_F_NO_PREALLOC, 0, ) if err != nil { scopedLog := log.WithError(err).WithField(logfields.Path, path) scopedLog.Warning("Failed to create CIDR map") return nil, false, err } } m := &CIDRMap{ path: path, Fd: fd, AddrSize: bytes, Prefixlen: uint32(prefix), PrefixIsDynamic: prefixdyn, } log.WithFields(logrus.Fields{ logfields.Path: path, "fd": fd, "LPM": typeMap == bpf.BPF_MAP_TYPE_LPM_TRIE, }).Debug("Created CIDR map") return m, isNewMap, nil }
go
func OpenMapElems(path string, prefixlen int, prefixdyn bool, maxelem uint32) (*CIDRMap, bool, error) { var typeMap = bpf.BPF_MAP_TYPE_LPM_TRIE var prefix = 0 if prefixdyn == false { typeMap = bpf.BPF_MAP_TYPE_HASH prefix = prefixlen } if prefixlen <= 0 { return nil, false, fmt.Errorf("prefixlen must be > 0") } bytes := (prefixlen-1)/8 + 1 fd, isNewMap, err := bpf.OpenOrCreateMap( path, typeMap, uint32(unsafe.Sizeof(uint32(0))+uintptr(bytes)), uint32(LPM_MAP_VALUE_SIZE), maxelem, bpf.BPF_F_NO_PREALLOC, 0, ) if err != nil { log.Debug("Kernel does not support CIDR maps, using hash table instead.") typeMap = bpf.BPF_MAP_TYPE_HASH fd, isNewMap, err = bpf.OpenOrCreateMap( path, typeMap, uint32(unsafe.Sizeof(uint32(0))+uintptr(bytes)), uint32(LPM_MAP_VALUE_SIZE), maxelem, bpf.BPF_F_NO_PREALLOC, 0, ) if err != nil { scopedLog := log.WithError(err).WithField(logfields.Path, path) scopedLog.Warning("Failed to create CIDR map") return nil, false, err } } m := &CIDRMap{ path: path, Fd: fd, AddrSize: bytes, Prefixlen: uint32(prefix), PrefixIsDynamic: prefixdyn, } log.WithFields(logrus.Fields{ logfields.Path: path, "fd": fd, "LPM": typeMap == bpf.BPF_MAP_TYPE_LPM_TRIE, }).Debug("Created CIDR map") return m, isNewMap, nil }
[ "func", "OpenMapElems", "(", "path", "string", ",", "prefixlen", "int", ",", "prefixdyn", "bool", ",", "maxelem", "uint32", ")", "(", "*", "CIDRMap", ",", "bool", ",", "error", ")", "{", "var", "typeMap", "=", "bpf", ".", "BPF_MAP_TYPE_LPM_TRIE", "\n", "var", "prefix", "=", "0", "\n\n", "if", "prefixdyn", "==", "false", "{", "typeMap", "=", "bpf", ".", "BPF_MAP_TYPE_HASH", "\n", "prefix", "=", "prefixlen", "\n", "}", "\n", "if", "prefixlen", "<=", "0", "{", "return", "nil", ",", "false", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n", "bytes", ":=", "(", "prefixlen", "-", "1", ")", "/", "8", "+", "1", "\n", "fd", ",", "isNewMap", ",", "err", ":=", "bpf", ".", "OpenOrCreateMap", "(", "path", ",", "typeMap", ",", "uint32", "(", "unsafe", ".", "Sizeof", "(", "uint32", "(", "0", ")", ")", "+", "uintptr", "(", "bytes", ")", ")", ",", "uint32", "(", "LPM_MAP_VALUE_SIZE", ")", ",", "maxelem", ",", "bpf", ".", "BPF_F_NO_PREALLOC", ",", "0", ",", ")", "\n\n", "if", "err", "!=", "nil", "{", "log", ".", "Debug", "(", "\"", "\"", ")", "\n", "typeMap", "=", "bpf", ".", "BPF_MAP_TYPE_HASH", "\n", "fd", ",", "isNewMap", ",", "err", "=", "bpf", ".", "OpenOrCreateMap", "(", "path", ",", "typeMap", ",", "uint32", "(", "unsafe", ".", "Sizeof", "(", "uint32", "(", "0", ")", ")", "+", "uintptr", "(", "bytes", ")", ")", ",", "uint32", "(", "LPM_MAP_VALUE_SIZE", ")", ",", "maxelem", ",", "bpf", ".", "BPF_F_NO_PREALLOC", ",", "0", ",", ")", "\n", "if", "err", "!=", "nil", "{", "scopedLog", ":=", "log", ".", "WithError", "(", "err", ")", ".", "WithField", "(", "logfields", ".", "Path", ",", "path", ")", "\n", "scopedLog", ".", "Warning", "(", "\"", "\"", ")", "\n", "return", "nil", ",", "false", ",", "err", "\n", "}", "\n", "}", "\n\n", "m", ":=", "&", "CIDRMap", "{", "path", ":", "path", ",", "Fd", ":", "fd", ",", "AddrSize", ":", "bytes", ",", "Prefixlen", ":", "uint32", "(", "prefix", ")", ",", "PrefixIsDynamic", ":", "prefixdyn", ",", "}", "\n\n", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "Path", ":", "path", ",", "\"", "\"", ":", "fd", ",", "\"", "\"", ":", "typeMap", "==", "bpf", ".", "BPF_MAP_TYPE_LPM_TRIE", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "return", "m", ",", "isNewMap", ",", "nil", "\n", "}" ]
// OpenMapElems is the same as OpenMap only with defined maxelem as argument.
[ "OpenMapElems", "is", "the", "same", "as", "OpenMap", "only", "with", "defined", "maxelem", "as", "argument", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/cidrmap/cidrmap.go#L166-L220
163,201
cilium/cilium
pkg/proxy/socket.go
Close
func (s *proxySocket) Close() { s.locker.Lock() select { case <-s.closing: s.locker.Unlock() return default: } close(s.closing) s.listener.Close() pairs := s.pairs s.pairs = nil s.locker.Unlock() // Immediately close all connection pairs for which cascading close was // requested in Accept. for _, pair := range pairs { pair.Rx.Close() } }
go
func (s *proxySocket) Close() { s.locker.Lock() select { case <-s.closing: s.locker.Unlock() return default: } close(s.closing) s.listener.Close() pairs := s.pairs s.pairs = nil s.locker.Unlock() // Immediately close all connection pairs for which cascading close was // requested in Accept. for _, pair := range pairs { pair.Rx.Close() } }
[ "func", "(", "s", "*", "proxySocket", ")", "Close", "(", ")", "{", "s", ".", "locker", ".", "Lock", "(", ")", "\n\n", "select", "{", "case", "<-", "s", ".", "closing", ":", "s", ".", "locker", ".", "Unlock", "(", ")", "\n", "return", "\n", "default", ":", "}", "\n\n", "close", "(", "s", ".", "closing", ")", "\n", "s", ".", "listener", ".", "Close", "(", ")", "\n\n", "pairs", ":=", "s", ".", "pairs", "\n", "s", ".", "pairs", "=", "nil", "\n\n", "s", ".", "locker", ".", "Unlock", "(", ")", "\n\n", "// Immediately close all connection pairs for which cascading close was", "// requested in Accept.", "for", "_", ",", "pair", ":=", "range", "pairs", "{", "pair", ".", "Rx", ".", "Close", "(", ")", "\n", "}", "\n", "}" ]
// Close closes the proxy socket and stops accepting new connections.
[ "Close", "closes", "the", "proxy", "socket", "and", "stops", "accepting", "new", "connections", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/socket.go#L194-L217
163,202
cilium/cilium
pkg/proxy/socket.go
Enqueue
func (c *proxyConnection) Enqueue(msg []byte) { scopedLog := log.WithFields(logrus.Fields{ fieldConn: c, fieldSize: len(msg), }) flowdebug.Log(scopedLog, fmt.Sprintf("Enqueueing %s message", c.direction())) select { case <-c.close: flowdebug.Log(scopedLog, fmt.Sprintf("%s connection is closed; dropping message", c.direction())) case c.queue <- msg: flowdebug.Log(scopedLog, fmt.Sprintf("Enqueued %s message", c.direction())) } }
go
func (c *proxyConnection) Enqueue(msg []byte) { scopedLog := log.WithFields(logrus.Fields{ fieldConn: c, fieldSize: len(msg), }) flowdebug.Log(scopedLog, fmt.Sprintf("Enqueueing %s message", c.direction())) select { case <-c.close: flowdebug.Log(scopedLog, fmt.Sprintf("%s connection is closed; dropping message", c.direction())) case c.queue <- msg: flowdebug.Log(scopedLog, fmt.Sprintf("Enqueued %s message", c.direction())) } }
[ "func", "(", "c", "*", "proxyConnection", ")", "Enqueue", "(", "msg", "[", "]", "byte", ")", "{", "scopedLog", ":=", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "fieldConn", ":", "c", ",", "fieldSize", ":", "len", "(", "msg", ")", ",", "}", ")", "\n\n", "flowdebug", ".", "Log", "(", "scopedLog", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "direction", "(", ")", ")", ")", "\n\n", "select", "{", "case", "<-", "c", ".", "close", ":", "flowdebug", ".", "Log", "(", "scopedLog", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "direction", "(", ")", ")", ")", "\n", "case", "c", ".", "queue", "<-", "msg", ":", "flowdebug", ".", "Log", "(", "scopedLog", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "direction", "(", ")", ")", ")", "\n", "}", "\n", "}" ]
// Enqueue queues a message to be written into the connection.
[ "Enqueue", "queues", "a", "message", "to", "be", "written", "into", "the", "connection", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/socket.go#L340-L354
163,203
cilium/cilium
pkg/proxy/socket.go
Close
func (c *proxyConnection) Close() { scopedLog := log.WithField(fieldConn, c) c.closeLocker.Lock() select { case <-c.close: // Already closed. Nothing to do. c.closeLocker.Unlock() return default: } // Cause writeQueuedMessages to terminate. close(c.close) c.closeLocker.Unlock() // Actually close the TCP connection. This will unblock any eventually // blocking c.conn.Write call in writeQueuedMessages. if !c.Closed() { scopedLog.Debug("Closing socket") c.conn.Close() } // Call connectionPair.close() concurrently so that this call doesn't block // while waiting for the other connection in the pair to close. go c.afterClose() }
go
func (c *proxyConnection) Close() { scopedLog := log.WithField(fieldConn, c) c.closeLocker.Lock() select { case <-c.close: // Already closed. Nothing to do. c.closeLocker.Unlock() return default: } // Cause writeQueuedMessages to terminate. close(c.close) c.closeLocker.Unlock() // Actually close the TCP connection. This will unblock any eventually // blocking c.conn.Write call in writeQueuedMessages. if !c.Closed() { scopedLog.Debug("Closing socket") c.conn.Close() } // Call connectionPair.close() concurrently so that this call doesn't block // while waiting for the other connection in the pair to close. go c.afterClose() }
[ "func", "(", "c", "*", "proxyConnection", ")", "Close", "(", ")", "{", "scopedLog", ":=", "log", ".", "WithField", "(", "fieldConn", ",", "c", ")", "\n\n", "c", ".", "closeLocker", ".", "Lock", "(", ")", "\n", "select", "{", "case", "<-", "c", ".", "close", ":", "// Already closed. Nothing to do.", "c", ".", "closeLocker", ".", "Unlock", "(", ")", "\n", "return", "\n", "default", ":", "}", "\n", "// Cause writeQueuedMessages to terminate.", "close", "(", "c", ".", "close", ")", "\n", "c", ".", "closeLocker", ".", "Unlock", "(", ")", "\n\n", "// Actually close the TCP connection. This will unblock any eventually", "// blocking c.conn.Write call in writeQueuedMessages.", "if", "!", "c", ".", "Closed", "(", ")", "{", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n", "c", ".", "conn", ".", "Close", "(", ")", "\n", "}", "\n\n", "// Call connectionPair.close() concurrently so that this call doesn't block", "// while waiting for the other connection in the pair to close.", "go", "c", ".", "afterClose", "(", ")", "\n", "}" ]
// Close closes this connection. // The connection on the other side of the proxy is closed after it is queued // for closing or after proxyConnectionCloseTimeout.
[ "Close", "closes", "this", "connection", ".", "The", "connection", "on", "the", "other", "side", "of", "the", "proxy", "is", "closed", "after", "it", "is", "queued", "for", "closing", "or", "after", "proxyConnectionCloseTimeout", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/proxy/socket.go#L359-L384
163,204
cilium/cilium
api/v1/client/policy/get_identity_id_parameters.go
WithTimeout
func (o *GetIdentityIDParams) WithTimeout(timeout time.Duration) *GetIdentityIDParams { o.SetTimeout(timeout) return o }
go
func (o *GetIdentityIDParams) WithTimeout(timeout time.Duration) *GetIdentityIDParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "GetIdentityIDParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "GetIdentityIDParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the get identity ID params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "identity", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_id_parameters.go#L77-L80
163,205
cilium/cilium
api/v1/client/policy/get_identity_id_parameters.go
WithContext
func (o *GetIdentityIDParams) WithContext(ctx context.Context) *GetIdentityIDParams { o.SetContext(ctx) return o }
go
func (o *GetIdentityIDParams) WithContext(ctx context.Context) *GetIdentityIDParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "GetIdentityIDParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "GetIdentityIDParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the get identity ID params
[ "WithContext", "adds", "the", "context", "to", "the", "get", "identity", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_id_parameters.go#L88-L91
163,206
cilium/cilium
api/v1/client/policy/get_identity_id_parameters.go
WithHTTPClient
func (o *GetIdentityIDParams) WithHTTPClient(client *http.Client) *GetIdentityIDParams { o.SetHTTPClient(client) return o }
go
func (o *GetIdentityIDParams) WithHTTPClient(client *http.Client) *GetIdentityIDParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "GetIdentityIDParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetIdentityIDParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the get identity ID params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "identity", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_id_parameters.go#L99-L102
163,207
cilium/cilium
api/v1/client/policy/get_identity_id_parameters.go
WithID
func (o *GetIdentityIDParams) WithID(id string) *GetIdentityIDParams { o.SetID(id) return o }
go
func (o *GetIdentityIDParams) WithID(id string) *GetIdentityIDParams { o.SetID(id) return o }
[ "func", "(", "o", "*", "GetIdentityIDParams", ")", "WithID", "(", "id", "string", ")", "*", "GetIdentityIDParams", "{", "o", ".", "SetID", "(", "id", ")", "\n", "return", "o", "\n", "}" ]
// WithID adds the id to the get identity ID params
[ "WithID", "adds", "the", "id", "to", "the", "get", "identity", "ID", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/policy/get_identity_id_parameters.go#L110-L113
163,208
cilium/cilium
pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/ciliumendpoint.go
newCiliumEndpoints
func newCiliumEndpoints(c *CiliumV2Client, namespace string) *ciliumEndpoints { return &ciliumEndpoints{ client: c.RESTClient(), ns: namespace, } }
go
func newCiliumEndpoints(c *CiliumV2Client, namespace string) *ciliumEndpoints { return &ciliumEndpoints{ client: c.RESTClient(), ns: namespace, } }
[ "func", "newCiliumEndpoints", "(", "c", "*", "CiliumV2Client", ",", "namespace", "string", ")", "*", "ciliumEndpoints", "{", "return", "&", "ciliumEndpoints", "{", "client", ":", "c", ".", "RESTClient", "(", ")", ",", "ns", ":", "namespace", ",", "}", "\n", "}" ]
// newCiliumEndpoints returns a CiliumEndpoints
[ "newCiliumEndpoints", "returns", "a", "CiliumEndpoints" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/ciliumendpoint.go#L57-L62
163,209
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_log_parameters.go
WithTimeout
func (o *GetEndpointIDLogParams) WithTimeout(timeout time.Duration) *GetEndpointIDLogParams { o.SetTimeout(timeout) return o }
go
func (o *GetEndpointIDLogParams) WithTimeout(timeout time.Duration) *GetEndpointIDLogParams { o.SetTimeout(timeout) return o }
[ "func", "(", "o", "*", "GetEndpointIDLogParams", ")", "WithTimeout", "(", "timeout", "time", ".", "Duration", ")", "*", "GetEndpointIDLogParams", "{", "o", ".", "SetTimeout", "(", "timeout", ")", "\n", "return", "o", "\n", "}" ]
// WithTimeout adds the timeout to the get endpoint ID log params
[ "WithTimeout", "adds", "the", "timeout", "to", "the", "get", "endpoint", "ID", "log", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_log_parameters.go#L88-L91
163,210
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_log_parameters.go
WithContext
func (o *GetEndpointIDLogParams) WithContext(ctx context.Context) *GetEndpointIDLogParams { o.SetContext(ctx) return o }
go
func (o *GetEndpointIDLogParams) WithContext(ctx context.Context) *GetEndpointIDLogParams { o.SetContext(ctx) return o }
[ "func", "(", "o", "*", "GetEndpointIDLogParams", ")", "WithContext", "(", "ctx", "context", ".", "Context", ")", "*", "GetEndpointIDLogParams", "{", "o", ".", "SetContext", "(", "ctx", ")", "\n", "return", "o", "\n", "}" ]
// WithContext adds the context to the get endpoint ID log params
[ "WithContext", "adds", "the", "context", "to", "the", "get", "endpoint", "ID", "log", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_log_parameters.go#L99-L102
163,211
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_log_parameters.go
WithHTTPClient
func (o *GetEndpointIDLogParams) WithHTTPClient(client *http.Client) *GetEndpointIDLogParams { o.SetHTTPClient(client) return o }
go
func (o *GetEndpointIDLogParams) WithHTTPClient(client *http.Client) *GetEndpointIDLogParams { o.SetHTTPClient(client) return o }
[ "func", "(", "o", "*", "GetEndpointIDLogParams", ")", "WithHTTPClient", "(", "client", "*", "http", ".", "Client", ")", "*", "GetEndpointIDLogParams", "{", "o", ".", "SetHTTPClient", "(", "client", ")", "\n", "return", "o", "\n", "}" ]
// WithHTTPClient adds the HTTPClient to the get endpoint ID log params
[ "WithHTTPClient", "adds", "the", "HTTPClient", "to", "the", "get", "endpoint", "ID", "log", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_log_parameters.go#L110-L113
163,212
cilium/cilium
api/v1/client/endpoint/get_endpoint_id_log_parameters.go
WithID
func (o *GetEndpointIDLogParams) WithID(id string) *GetEndpointIDLogParams { o.SetID(id) return o }
go
func (o *GetEndpointIDLogParams) WithID(id string) *GetEndpointIDLogParams { o.SetID(id) return o }
[ "func", "(", "o", "*", "GetEndpointIDLogParams", ")", "WithID", "(", "id", "string", ")", "*", "GetEndpointIDLogParams", "{", "o", ".", "SetID", "(", "id", ")", "\n", "return", "o", "\n", "}" ]
// WithID adds the id to the get endpoint ID log params
[ "WithID", "adds", "the", "id", "to", "the", "get", "endpoint", "ID", "log", "params" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/client/endpoint/get_endpoint_id_log_parameters.go#L121-L124
163,213
cilium/cilium
pkg/maps/nat/ipv6.go
Dump
func (n *NatEntry6) Dump(key tuple.TupleKey, start uint64) string { var which string if key.GetFlags()&tuple.TUPLE_F_IN != 0 { which = "DST" } else { which = "SRC" } return fmt.Sprintf("XLATE_%s [%s]:%d Created=%s HostLocal=%d\n", which, n.Addr, n.Port, NatDumpCreated(start, n.Created), n.HostLocal) }
go
func (n *NatEntry6) Dump(key tuple.TupleKey, start uint64) string { var which string if key.GetFlags()&tuple.TUPLE_F_IN != 0 { which = "DST" } else { which = "SRC" } return fmt.Sprintf("XLATE_%s [%s]:%d Created=%s HostLocal=%d\n", which, n.Addr, n.Port, NatDumpCreated(start, n.Created), n.HostLocal) }
[ "func", "(", "n", "*", "NatEntry6", ")", "Dump", "(", "key", "tuple", ".", "TupleKey", ",", "start", "uint64", ")", "string", "{", "var", "which", "string", "\n\n", "if", "key", ".", "GetFlags", "(", ")", "&", "tuple", ".", "TUPLE_F_IN", "!=", "0", "{", "which", "=", "\"", "\"", "\n", "}", "else", "{", "which", "=", "\"", "\"", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "which", ",", "n", ".", "Addr", ",", "n", ".", "Port", ",", "NatDumpCreated", "(", "start", ",", "n", ".", "Created", ")", ",", "n", ".", "HostLocal", ")", "\n", "}" ]
// Dump dumps NAT entry to string.
[ "Dump", "dumps", "NAT", "entry", "to", "string", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/nat/ipv6.go#L49-L63
163,214
cilium/cilium
pkg/maps/nat/ipv6.go
ToHost
func (n *NatEntry6) ToHost() NatEntry { x := *n x.Port = byteorder.NetworkToHost(n.Port).(uint16) return &x }
go
func (n *NatEntry6) ToHost() NatEntry { x := *n x.Port = byteorder.NetworkToHost(n.Port).(uint16) return &x }
[ "func", "(", "n", "*", "NatEntry6", ")", "ToHost", "(", ")", "NatEntry", "{", "x", ":=", "*", "n", "\n", "x", ".", "Port", "=", "byteorder", ".", "NetworkToHost", "(", "n", ".", "Port", ")", ".", "(", "uint16", ")", "\n", "return", "&", "x", "\n", "}" ]
// ToHost converts NatEntry4 ports to host byte order.
[ "ToHost", "converts", "NatEntry4", "ports", "to", "host", "byte", "order", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/nat/ipv6.go#L66-L70
163,215
cilium/cilium
pkg/health/server/node.go
PrimaryIP
func (n *healthNode) PrimaryIP() string { if n.NodeElement.PrimaryAddress.IPV4.Enabled { return n.NodeElement.PrimaryAddress.IPV4.IP } return n.NodeElement.PrimaryAddress.IPV6.IP }
go
func (n *healthNode) PrimaryIP() string { if n.NodeElement.PrimaryAddress.IPV4.Enabled { return n.NodeElement.PrimaryAddress.IPV4.IP } return n.NodeElement.PrimaryAddress.IPV6.IP }
[ "func", "(", "n", "*", "healthNode", ")", "PrimaryIP", "(", ")", "string", "{", "if", "n", ".", "NodeElement", ".", "PrimaryAddress", ".", "IPV4", ".", "Enabled", "{", "return", "n", ".", "NodeElement", ".", "PrimaryAddress", ".", "IPV4", ".", "IP", "\n", "}", "\n", "return", "n", ".", "NodeElement", ".", "PrimaryAddress", ".", "IPV6", ".", "IP", "\n", "}" ]
// PrimaryIP returns the primary IP address of the node.
[ "PrimaryIP", "returns", "the", "primary", "IP", "address", "of", "the", "node", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/node.go#L38-L43
163,216
cilium/cilium
pkg/health/server/node.go
HealthIP
func (n *healthNode) HealthIP() string { if n.NodeElement.HealthEndpointAddress == nil { return "" } if n.NodeElement.HealthEndpointAddress.IPV4.Enabled { return n.NodeElement.HealthEndpointAddress.IPV4.IP } return n.NodeElement.HealthEndpointAddress.IPV6.IP }
go
func (n *healthNode) HealthIP() string { if n.NodeElement.HealthEndpointAddress == nil { return "" } if n.NodeElement.HealthEndpointAddress.IPV4.Enabled { return n.NodeElement.HealthEndpointAddress.IPV4.IP } return n.NodeElement.HealthEndpointAddress.IPV6.IP }
[ "func", "(", "n", "*", "healthNode", ")", "HealthIP", "(", ")", "string", "{", "if", "n", ".", "NodeElement", ".", "HealthEndpointAddress", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "n", ".", "NodeElement", ".", "HealthEndpointAddress", ".", "IPV4", ".", "Enabled", "{", "return", "n", ".", "NodeElement", ".", "HealthEndpointAddress", ".", "IPV4", ".", "IP", "\n", "}", "\n", "return", "n", ".", "NodeElement", ".", "HealthEndpointAddress", ".", "IPV6", ".", "IP", "\n", "}" ]
// HealthIP returns the IP address of the health endpoint for the node.
[ "HealthIP", "returns", "the", "IP", "address", "of", "the", "health", "endpoint", "for", "the", "node", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/node.go#L46-L54
163,217
cilium/cilium
pkg/health/server/node.go
Addresses
func (n *healthNode) Addresses() map[*models.NodeAddressingElement]bool { addresses := map[*models.NodeAddressingElement]bool{} if n.NodeElement.PrimaryAddress != nil { addr := n.NodeElement.PrimaryAddress addresses[addr.IPV4] = addr.IPV4.Enabled addresses[addr.IPV6] = addr.IPV6.Enabled } if n.NodeElement.HealthEndpointAddress != nil { addresses[n.NodeElement.HealthEndpointAddress.IPV4] = false addresses[n.NodeElement.HealthEndpointAddress.IPV6] = false } for _, elem := range n.NodeElement.SecondaryAddresses { addresses[elem] = false } return addresses }
go
func (n *healthNode) Addresses() map[*models.NodeAddressingElement]bool { addresses := map[*models.NodeAddressingElement]bool{} if n.NodeElement.PrimaryAddress != nil { addr := n.NodeElement.PrimaryAddress addresses[addr.IPV4] = addr.IPV4.Enabled addresses[addr.IPV6] = addr.IPV6.Enabled } if n.NodeElement.HealthEndpointAddress != nil { addresses[n.NodeElement.HealthEndpointAddress.IPV4] = false addresses[n.NodeElement.HealthEndpointAddress.IPV6] = false } for _, elem := range n.NodeElement.SecondaryAddresses { addresses[elem] = false } return addresses }
[ "func", "(", "n", "*", "healthNode", ")", "Addresses", "(", ")", "map", "[", "*", "models", ".", "NodeAddressingElement", "]", "bool", "{", "addresses", ":=", "map", "[", "*", "models", ".", "NodeAddressingElement", "]", "bool", "{", "}", "\n", "if", "n", ".", "NodeElement", ".", "PrimaryAddress", "!=", "nil", "{", "addr", ":=", "n", ".", "NodeElement", ".", "PrimaryAddress", "\n", "addresses", "[", "addr", ".", "IPV4", "]", "=", "addr", ".", "IPV4", ".", "Enabled", "\n", "addresses", "[", "addr", ".", "IPV6", "]", "=", "addr", ".", "IPV6", ".", "Enabled", "\n", "}", "\n", "if", "n", ".", "NodeElement", ".", "HealthEndpointAddress", "!=", "nil", "{", "addresses", "[", "n", ".", "NodeElement", ".", "HealthEndpointAddress", ".", "IPV4", "]", "=", "false", "\n", "addresses", "[", "n", ".", "NodeElement", ".", "HealthEndpointAddress", ".", "IPV6", "]", "=", "false", "\n", "}", "\n", "for", "_", ",", "elem", ":=", "range", "n", ".", "NodeElement", ".", "SecondaryAddresses", "{", "addresses", "[", "elem", "]", "=", "false", "\n", "}", "\n", "return", "addresses", "\n", "}" ]
// Addresses returns a map of the node's addresses -> "primary" bool
[ "Addresses", "returns", "a", "map", "of", "the", "node", "s", "addresses", "-", ">", "primary", "bool" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/health/server/node.go#L57-L72
163,218
cilium/cilium
pkg/endpoint/restore.go
transformEndpointForDowngrade
func transformEndpointForDowngrade(ep *Endpoint) { ep.DeprecatedOpts.Opts = convertOptions(ep.Options.Opts) }
go
func transformEndpointForDowngrade(ep *Endpoint) { ep.DeprecatedOpts.Opts = convertOptions(ep.Options.Opts) }
[ "func", "transformEndpointForDowngrade", "(", "ep", "*", "Endpoint", ")", "{", "ep", ".", "DeprecatedOpts", ".", "Opts", "=", "convertOptions", "(", "ep", ".", "Options", ".", "Opts", ")", "\n", "}" ]
// transformEndpointForDowngrade modifies the specified endpoint to populate // deprecated fields so that when the endpoint is serialized, an older version // of Cilium will understand the format. This allows safe downgrade from this // version to an older version.
[ "transformEndpointForDowngrade", "modifies", "the", "specified", "endpoint", "to", "populate", "deprecated", "fields", "so", "that", "when", "the", "endpoint", "is", "serialized", "an", "older", "version", "of", "Cilium", "will", "understand", "the", "format", ".", "This", "allows", "safe", "downgrade", "from", "this", "version", "to", "an", "older", "version", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/restore.go#L58-L60
163,219
cilium/cilium
pkg/endpoint/restore.go
ReadEPsFromDirNames
func ReadEPsFromDirNames(basePath string, eptsDirNames []string) map[uint16]*Endpoint { possibleEPs := map[uint16]*Endpoint{} for _, epDirName := range eptsDirNames { epDir := filepath.Join(basePath, epDirName) readDir := func() string { scopedLog := log.WithFields(logrus.Fields{ logfields.EndpointID: epDirName, logfields.Path: filepath.Join(epDir, common.CHeaderFileName), }) scopedLog.Debug("Reading directory") epFiles, err := ioutil.ReadDir(epDir) if err != nil { scopedLog.WithError(err).Warn("Error while reading directory. Ignoring it...") return "" } cHeaderFile := common.FindEPConfigCHeader(epDir, epFiles) if cHeaderFile == "" { return "" } return cHeaderFile } // There's an odd issue where the first read dir doesn't work. cHeaderFile := readDir() if cHeaderFile == "" { cHeaderFile = readDir() } scopedLog := log.WithFields(logrus.Fields{ logfields.EndpointID: epDirName, logfields.Path: cHeaderFile, }) if cHeaderFile == "" { scopedLog.Warning("C header file not found. Ignoring endpoint") continue } scopedLog.Debug("Found endpoint C header file") strEp, err := common.GetCiliumVersionString(cHeaderFile) if err != nil { scopedLog.WithError(err).Warn("Unable to read the C header file") continue } ep, err := ParseEndpoint(strEp) if err != nil { scopedLog.WithError(err).Warn("Unable to parse the C header file") continue } if _, ok := possibleEPs[ep.ID]; ok { // If the endpoint already exists then give priority to the directory // that contains an endpoint that didn't fail to be build. if strings.HasSuffix(ep.DirectoryPath(), epDirName) { possibleEPs[ep.ID] = ep } } else { possibleEPs[ep.ID] = ep } } return possibleEPs }
go
func ReadEPsFromDirNames(basePath string, eptsDirNames []string) map[uint16]*Endpoint { possibleEPs := map[uint16]*Endpoint{} for _, epDirName := range eptsDirNames { epDir := filepath.Join(basePath, epDirName) readDir := func() string { scopedLog := log.WithFields(logrus.Fields{ logfields.EndpointID: epDirName, logfields.Path: filepath.Join(epDir, common.CHeaderFileName), }) scopedLog.Debug("Reading directory") epFiles, err := ioutil.ReadDir(epDir) if err != nil { scopedLog.WithError(err).Warn("Error while reading directory. Ignoring it...") return "" } cHeaderFile := common.FindEPConfigCHeader(epDir, epFiles) if cHeaderFile == "" { return "" } return cHeaderFile } // There's an odd issue where the first read dir doesn't work. cHeaderFile := readDir() if cHeaderFile == "" { cHeaderFile = readDir() } scopedLog := log.WithFields(logrus.Fields{ logfields.EndpointID: epDirName, logfields.Path: cHeaderFile, }) if cHeaderFile == "" { scopedLog.Warning("C header file not found. Ignoring endpoint") continue } scopedLog.Debug("Found endpoint C header file") strEp, err := common.GetCiliumVersionString(cHeaderFile) if err != nil { scopedLog.WithError(err).Warn("Unable to read the C header file") continue } ep, err := ParseEndpoint(strEp) if err != nil { scopedLog.WithError(err).Warn("Unable to parse the C header file") continue } if _, ok := possibleEPs[ep.ID]; ok { // If the endpoint already exists then give priority to the directory // that contains an endpoint that didn't fail to be build. if strings.HasSuffix(ep.DirectoryPath(), epDirName) { possibleEPs[ep.ID] = ep } } else { possibleEPs[ep.ID] = ep } } return possibleEPs }
[ "func", "ReadEPsFromDirNames", "(", "basePath", "string", ",", "eptsDirNames", "[", "]", "string", ")", "map", "[", "uint16", "]", "*", "Endpoint", "{", "possibleEPs", ":=", "map", "[", "uint16", "]", "*", "Endpoint", "{", "}", "\n", "for", "_", ",", "epDirName", ":=", "range", "eptsDirNames", "{", "epDir", ":=", "filepath", ".", "Join", "(", "basePath", ",", "epDirName", ")", "\n", "readDir", ":=", "func", "(", ")", "string", "{", "scopedLog", ":=", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "EndpointID", ":", "epDirName", ",", "logfields", ".", "Path", ":", "filepath", ".", "Join", "(", "epDir", ",", "common", ".", "CHeaderFileName", ")", ",", "}", ")", "\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n", "epFiles", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "epDir", ")", "\n", "if", "err", "!=", "nil", "{", "scopedLog", ".", "WithError", "(", "err", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "return", "\"", "\"", "\n", "}", "\n", "cHeaderFile", ":=", "common", ".", "FindEPConfigCHeader", "(", "epDir", ",", "epFiles", ")", "\n", "if", "cHeaderFile", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n", "return", "cHeaderFile", "\n", "}", "\n", "// There's an odd issue where the first read dir doesn't work.", "cHeaderFile", ":=", "readDir", "(", ")", "\n", "if", "cHeaderFile", "==", "\"", "\"", "{", "cHeaderFile", "=", "readDir", "(", ")", "\n", "}", "\n\n", "scopedLog", ":=", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "EndpointID", ":", "epDirName", ",", "logfields", ".", "Path", ":", "cHeaderFile", ",", "}", ")", "\n\n", "if", "cHeaderFile", "==", "\"", "\"", "{", "scopedLog", ".", "Warning", "(", "\"", "\"", ")", "\n", "continue", "\n", "}", "\n\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "strEp", ",", "err", ":=", "common", ".", "GetCiliumVersionString", "(", "cHeaderFile", ")", "\n", "if", "err", "!=", "nil", "{", "scopedLog", ".", "WithError", "(", "err", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "continue", "\n", "}", "\n", "ep", ",", "err", ":=", "ParseEndpoint", "(", "strEp", ")", "\n", "if", "err", "!=", "nil", "{", "scopedLog", ".", "WithError", "(", "err", ")", ".", "Warn", "(", "\"", "\"", ")", "\n", "continue", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "possibleEPs", "[", "ep", ".", "ID", "]", ";", "ok", "{", "// If the endpoint already exists then give priority to the directory", "// that contains an endpoint that didn't fail to be build.", "if", "strings", ".", "HasSuffix", "(", "ep", ".", "DirectoryPath", "(", ")", ",", "epDirName", ")", "{", "possibleEPs", "[", "ep", ".", "ID", "]", "=", "ep", "\n", "}", "\n", "}", "else", "{", "possibleEPs", "[", "ep", ".", "ID", "]", "=", "ep", "\n", "}", "\n", "}", "\n", "return", "possibleEPs", "\n", "}" ]
// ReadEPsFromDirNames returns a mapping of endpoint ID to endpoint of endpoints // from a list of directory names that can possible contain an endpoint.
[ "ReadEPsFromDirNames", "returns", "a", "mapping", "of", "endpoint", "ID", "to", "endpoint", "of", "endpoints", "from", "a", "list", "of", "directory", "names", "that", "can", "possible", "contain", "an", "endpoint", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/endpoint/restore.go#L64-L124
163,220
cilium/cilium
pkg/modules/modules.go
Init
func (m *ModulesManager) Init() error { modulesList, err := listModules() if err != nil { return err } m.modulesList = modulesList return nil }
go
func (m *ModulesManager) Init() error { modulesList, err := listModules() if err != nil { return err } m.modulesList = modulesList return nil }
[ "func", "(", "m", "*", "ModulesManager", ")", "Init", "(", ")", "error", "{", "modulesList", ",", "err", ":=", "listModules", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "m", ".", "modulesList", "=", "modulesList", "\n", "return", "nil", "\n", "}" ]
// Init initializes the internal modules information store of modules manager.
[ "Init", "initializes", "the", "internal", "modules", "information", "store", "of", "modules", "manager", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/modules/modules.go#L32-L39
163,221
cilium/cilium
pkg/modules/modules.go
findModules
func (m *ModulesManager) findModules(expectedNames ...string) (bool, []string) { return set.SliceSubsetOf(expectedNames, m.modulesList) }
go
func (m *ModulesManager) findModules(expectedNames ...string) (bool, []string) { return set.SliceSubsetOf(expectedNames, m.modulesList) }
[ "func", "(", "m", "*", "ModulesManager", ")", "findModules", "(", "expectedNames", "...", "string", ")", "(", "bool", ",", "[", "]", "string", ")", "{", "return", "set", ".", "SliceSubsetOf", "(", "expectedNames", ",", "m", ".", "modulesList", ")", "\n", "}" ]
// findModules checks whether the given kernel modules are loaded and also // returns a slice with names of modules which are not loaded.
[ "findModules", "checks", "whether", "the", "given", "kernel", "modules", "are", "loaded", "and", "also", "returns", "a", "slice", "with", "names", "of", "modules", "which", "are", "not", "loaded", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/modules/modules.go#L43-L45
163,222
cilium/cilium
pkg/modules/modules.go
FindOrLoadModules
func (m *ModulesManager) FindOrLoadModules(expectedNames ...string) error { found, diff := m.findModules(expectedNames...) if found { return nil } for _, unloadedModule := range diff { if _, err := exec.WithTimeout( defaults.ExecTimeout, moduleLoader(), unloadedModule).CombinedOutput( nil, false); err != nil { return fmt.Errorf("could not load module %s: %s", unloadedModule, err) } } return nil }
go
func (m *ModulesManager) FindOrLoadModules(expectedNames ...string) error { found, diff := m.findModules(expectedNames...) if found { return nil } for _, unloadedModule := range diff { if _, err := exec.WithTimeout( defaults.ExecTimeout, moduleLoader(), unloadedModule).CombinedOutput( nil, false); err != nil { return fmt.Errorf("could not load module %s: %s", unloadedModule, err) } } return nil }
[ "func", "(", "m", "*", "ModulesManager", ")", "FindOrLoadModules", "(", "expectedNames", "...", "string", ")", "error", "{", "found", ",", "diff", ":=", "m", ".", "findModules", "(", "expectedNames", "...", ")", "\n", "if", "found", "{", "return", "nil", "\n", "}", "\n", "for", "_", ",", "unloadedModule", ":=", "range", "diff", "{", "if", "_", ",", "err", ":=", "exec", ".", "WithTimeout", "(", "defaults", ".", "ExecTimeout", ",", "moduleLoader", "(", ")", ",", "unloadedModule", ")", ".", "CombinedOutput", "(", "nil", ",", "false", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "unloadedModule", ",", "err", ")", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// FindOrLoadModules checks whether the given kernel modules are loaded and // tries to load those which are not.
[ "FindOrLoadModules", "checks", "whether", "the", "given", "kernel", "modules", "are", "loaded", "and", "tries", "to", "load", "those", "which", "are", "not", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/modules/modules.go#L49-L63
163,223
cilium/cilium
pkg/cleanup/cleanup.go
DeferTerminationCleanupFunction
func DeferTerminationCleanupFunction(wg *sync.WaitGroup, ch <-chan struct{}, f func()) { wg.Add(1) go func() { defer wg.Done() <-ch f() }() }
go
func DeferTerminationCleanupFunction(wg *sync.WaitGroup, ch <-chan struct{}, f func()) { wg.Add(1) go func() { defer wg.Done() <-ch f() }() }
[ "func", "DeferTerminationCleanupFunction", "(", "wg", "*", "sync", ".", "WaitGroup", ",", "ch", "<-", "chan", "struct", "{", "}", ",", "f", "func", "(", ")", ")", "{", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{", "defer", "wg", ".", "Done", "(", ")", "\n", "<-", "ch", "\n", "f", "(", ")", "\n", "}", "(", ")", "\n", "}" ]
// DeferTerminationCleanupFunction will execute the given function `f` when the // channel `ch` is closed. // The given waitGroup will be added with a delta +1 and once the function // `f` returns from its execution that same waitGroup will signalize function // `f` is completed.
[ "DeferTerminationCleanupFunction", "will", "execute", "the", "given", "function", "f", "when", "the", "channel", "ch", "is", "closed", ".", "The", "given", "waitGroup", "will", "be", "added", "with", "a", "delta", "+", "1", "and", "once", "the", "function", "f", "returns", "from", "its", "execution", "that", "same", "waitGroup", "will", "signalize", "function", "f", "is", "completed", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/cleanup/cleanup.go#L26-L33
163,224
cilium/cilium
daemon/policy.go
UpdateIdentities
func (d *Daemon) UpdateIdentities(added, deleted cache.IdentityCache) { policy.UpdateIdentities(added, deleted) d.TriggerPolicyUpdates(true, "one or more identities created or deleted") }
go
func (d *Daemon) UpdateIdentities(added, deleted cache.IdentityCache) { policy.UpdateIdentities(added, deleted) d.TriggerPolicyUpdates(true, "one or more identities created or deleted") }
[ "func", "(", "d", "*", "Daemon", ")", "UpdateIdentities", "(", "added", ",", "deleted", "cache", ".", "IdentityCache", ")", "{", "policy", ".", "UpdateIdentities", "(", "added", ",", "deleted", ")", "\n", "d", ".", "TriggerPolicyUpdates", "(", "true", ",", "\"", "\"", ")", "\n", "}" ]
// UpdateIdentities informs the policy package of all identity changes // and also triggers policy updates.
[ "UpdateIdentities", "informs", "the", "policy", "package", "of", "all", "identity", "changes", "and", "also", "triggers", "policy", "updates", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/policy.go#L74-L77
163,225
cilium/cilium
daemon/policy.go
PolicyAdd
func (d *Daemon) PolicyAdd(rules policyAPI.Rules, opts *AddOptions) (newRev uint64, err error) { p := &PolicyAddEvent{ rules: rules, opts: opts, d: d, } polAddEvent := eventqueue.NewEvent(p) resChan := d.policy.RepositoryChangeQueue.Enqueue(polAddEvent) res, ok := <-resChan if ok { pRes := res.(*PolicyAddResult) return pRes.newRev, pRes.err } return 0, fmt.Errorf("policy addition event was cancelled") }
go
func (d *Daemon) PolicyAdd(rules policyAPI.Rules, opts *AddOptions) (newRev uint64, err error) { p := &PolicyAddEvent{ rules: rules, opts: opts, d: d, } polAddEvent := eventqueue.NewEvent(p) resChan := d.policy.RepositoryChangeQueue.Enqueue(polAddEvent) res, ok := <-resChan if ok { pRes := res.(*PolicyAddResult) return pRes.newRev, pRes.err } return 0, fmt.Errorf("policy addition event was cancelled") }
[ "func", "(", "d", "*", "Daemon", ")", "PolicyAdd", "(", "rules", "policyAPI", ".", "Rules", ",", "opts", "*", "AddOptions", ")", "(", "newRev", "uint64", ",", "err", "error", ")", "{", "p", ":=", "&", "PolicyAddEvent", "{", "rules", ":", "rules", ",", "opts", ":", "opts", ",", "d", ":", "d", ",", "}", "\n", "polAddEvent", ":=", "eventqueue", ".", "NewEvent", "(", "p", ")", "\n", "resChan", ":=", "d", ".", "policy", ".", "RepositoryChangeQueue", ".", "Enqueue", "(", "polAddEvent", ")", "\n\n", "res", ",", "ok", ":=", "<-", "resChan", "\n", "if", "ok", "{", "pRes", ":=", "res", ".", "(", "*", "PolicyAddResult", ")", "\n", "return", "pRes", ".", "newRev", ",", "pRes", ".", "err", "\n", "}", "\n", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
// PolicyAdd adds a slice of rules to the policy repository owned by the // daemon. Eventual changes in policy rules are propagated to all locally // managed endpoints. Returns the policy revision number of the repository after // adding the rules into the repository, or an error if the updated policy // was not able to be imported.
[ "PolicyAdd", "adds", "a", "slice", "of", "rules", "to", "the", "policy", "repository", "owned", "by", "the", "daemon", ".", "Eventual", "changes", "in", "policy", "rules", "are", "propagated", "to", "all", "locally", "managed", "endpoints", ".", "Returns", "the", "policy", "revision", "number", "of", "the", "repository", "after", "adding", "the", "rules", "into", "the", "repository", "or", "an", "error", "if", "the", "updated", "policy", "was", "not", "able", "to", "be", "imported", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/policy.go#L217-L232
163,226
cilium/cilium
daemon/policy.go
PolicyDelete
func (d *Daemon) PolicyDelete(labels labels.LabelArray) (newRev uint64, err error) { p := &PolicyDeleteEvent{ labels: labels, d: d, } policyDeleteEvent := eventqueue.NewEvent(p) resChan := d.policy.RepositoryChangeQueue.Enqueue(policyDeleteEvent) res, ok := <-resChan if ok { ress := res.(*PolicyDeleteResult) return ress.newRev, ress.err } return 0, fmt.Errorf("policy deletion event cancelled") }
go
func (d *Daemon) PolicyDelete(labels labels.LabelArray) (newRev uint64, err error) { p := &PolicyDeleteEvent{ labels: labels, d: d, } policyDeleteEvent := eventqueue.NewEvent(p) resChan := d.policy.RepositoryChangeQueue.Enqueue(policyDeleteEvent) res, ok := <-resChan if ok { ress := res.(*PolicyDeleteResult) return ress.newRev, ress.err } return 0, fmt.Errorf("policy deletion event cancelled") }
[ "func", "(", "d", "*", "Daemon", ")", "PolicyDelete", "(", "labels", "labels", ".", "LabelArray", ")", "(", "newRev", "uint64", ",", "err", "error", ")", "{", "p", ":=", "&", "PolicyDeleteEvent", "{", "labels", ":", "labels", ",", "d", ":", "d", ",", "}", "\n", "policyDeleteEvent", ":=", "eventqueue", ".", "NewEvent", "(", "p", ")", "\n", "resChan", ":=", "d", ".", "policy", ".", "RepositoryChangeQueue", ".", "Enqueue", "(", "policyDeleteEvent", ")", "\n\n", "res", ",", "ok", ":=", "<-", "resChan", "\n", "if", "ok", "{", "ress", ":=", "res", ".", "(", "*", "PolicyDeleteResult", ")", "\n", "return", "ress", ".", "newRev", ",", "ress", ".", "err", "\n", "}", "\n", "return", "0", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}" ]
// PolicyDelete deletes the policy rules with the provided set of labels from // the policy repository of the daemon. // Returns the revision number and an error in case it was not possible to // delete the policy.
[ "PolicyDelete", "deletes", "the", "policy", "rules", "with", "the", "provided", "set", "of", "labels", "from", "the", "policy", "repository", "of", "the", "daemon", ".", "Returns", "the", "revision", "number", "and", "an", "error", "in", "case", "it", "was", "not", "possible", "to", "delete", "the", "policy", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/daemon/policy.go#L514-L529
163,227
cilium/cilium
pkg/monitor/dissect.go
initParser
func initParser() { if cache == nil { log.Info("Initializing dissection cache...") cache = &parserCache{ decoded: []gopacket.LayerType{}, } parser = gopacket.NewDecodingLayerParser( layers.LayerTypeEthernet, &cache.eth, &cache.ip4, &cache.ip6, &cache.icmp4, &cache.icmp6, &cache.tcp, &cache.udp) } }
go
func initParser() { if cache == nil { log.Info("Initializing dissection cache...") cache = &parserCache{ decoded: []gopacket.LayerType{}, } parser = gopacket.NewDecodingLayerParser( layers.LayerTypeEthernet, &cache.eth, &cache.ip4, &cache.ip6, &cache.icmp4, &cache.icmp6, &cache.tcp, &cache.udp) } }
[ "func", "initParser", "(", ")", "{", "if", "cache", "==", "nil", "{", "log", ".", "Info", "(", "\"", "\"", ")", "\n\n", "cache", "=", "&", "parserCache", "{", "decoded", ":", "[", "]", "gopacket", ".", "LayerType", "{", "}", ",", "}", "\n\n", "parser", "=", "gopacket", ".", "NewDecodingLayerParser", "(", "layers", ".", "LayerTypeEthernet", ",", "&", "cache", ".", "eth", ",", "&", "cache", ".", "ip4", ",", "&", "cache", ".", "ip6", ",", "&", "cache", ".", "icmp4", ",", "&", "cache", ".", "icmp6", ",", "&", "cache", ".", "tcp", ",", "&", "cache", ".", "udp", ")", "\n", "}", "\n", "}" ]
// getParser must be called with dissectLock held
[ "getParser", "must", "be", "called", "with", "dissectLock", "held" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/dissect.go#L51-L64
163,228
cilium/cilium
pkg/monitor/dissect.go
Dissect
func Dissect(dissect bool, data []byte) { if dissect { dissectLock.Lock() defer dissectLock.Unlock() initParser() parser.DecodeLayers(data, &cache.decoded) for _, typ := range cache.decoded { switch typ { case layers.LayerTypeEthernet: fmt.Println(gopacket.LayerString(&cache.eth)) case layers.LayerTypeIPv4: fmt.Println(gopacket.LayerString(&cache.ip4)) case layers.LayerTypeIPv6: fmt.Println(gopacket.LayerString(&cache.ip6)) case layers.LayerTypeTCP: fmt.Println(gopacket.LayerString(&cache.tcp)) case layers.LayerTypeUDP: fmt.Println(gopacket.LayerString(&cache.udp)) case layers.LayerTypeICMPv4: fmt.Println(gopacket.LayerString(&cache.icmp4)) case layers.LayerTypeICMPv6: fmt.Println(gopacket.LayerString(&cache.icmp6)) default: fmt.Println("Unknown layer") } } if parser.Truncated { fmt.Println(" Packet has been truncated") } } else { fmt.Print(hex.Dump(data)) } }
go
func Dissect(dissect bool, data []byte) { if dissect { dissectLock.Lock() defer dissectLock.Unlock() initParser() parser.DecodeLayers(data, &cache.decoded) for _, typ := range cache.decoded { switch typ { case layers.LayerTypeEthernet: fmt.Println(gopacket.LayerString(&cache.eth)) case layers.LayerTypeIPv4: fmt.Println(gopacket.LayerString(&cache.ip4)) case layers.LayerTypeIPv6: fmt.Println(gopacket.LayerString(&cache.ip6)) case layers.LayerTypeTCP: fmt.Println(gopacket.LayerString(&cache.tcp)) case layers.LayerTypeUDP: fmt.Println(gopacket.LayerString(&cache.udp)) case layers.LayerTypeICMPv4: fmt.Println(gopacket.LayerString(&cache.icmp4)) case layers.LayerTypeICMPv6: fmt.Println(gopacket.LayerString(&cache.icmp6)) default: fmt.Println("Unknown layer") } } if parser.Truncated { fmt.Println(" Packet has been truncated") } } else { fmt.Print(hex.Dump(data)) } }
[ "func", "Dissect", "(", "dissect", "bool", ",", "data", "[", "]", "byte", ")", "{", "if", "dissect", "{", "dissectLock", ".", "Lock", "(", ")", "\n", "defer", "dissectLock", ".", "Unlock", "(", ")", "\n\n", "initParser", "(", ")", "\n", "parser", ".", "DecodeLayers", "(", "data", ",", "&", "cache", ".", "decoded", ")", "\n\n", "for", "_", ",", "typ", ":=", "range", "cache", ".", "decoded", "{", "switch", "typ", "{", "case", "layers", ".", "LayerTypeEthernet", ":", "fmt", ".", "Println", "(", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "eth", ")", ")", "\n", "case", "layers", ".", "LayerTypeIPv4", ":", "fmt", ".", "Println", "(", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "ip4", ")", ")", "\n", "case", "layers", ".", "LayerTypeIPv6", ":", "fmt", ".", "Println", "(", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "ip6", ")", ")", "\n", "case", "layers", ".", "LayerTypeTCP", ":", "fmt", ".", "Println", "(", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "tcp", ")", ")", "\n", "case", "layers", ".", "LayerTypeUDP", ":", "fmt", ".", "Println", "(", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "udp", ")", ")", "\n", "case", "layers", ".", "LayerTypeICMPv4", ":", "fmt", ".", "Println", "(", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "icmp4", ")", ")", "\n", "case", "layers", ".", "LayerTypeICMPv6", ":", "fmt", ".", "Println", "(", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "icmp6", ")", ")", "\n", "default", ":", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "if", "parser", ".", "Truncated", "{", "fmt", ".", "Println", "(", "\"", "\"", ")", "\n", "}", "\n\n", "}", "else", "{", "fmt", ".", "Print", "(", "hex", ".", "Dump", "(", "data", ")", ")", "\n", "}", "\n", "}" ]
// Dissect parses and prints the provided data if dissect is set to true, // otherwise the data is printed as HEX output
[ "Dissect", "parses", "and", "prints", "the", "provided", "data", "if", "dissect", "is", "set", "to", "true", "otherwise", "the", "data", "is", "printed", "as", "HEX", "output" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/dissect.go#L159-L194
163,229
cilium/cilium
pkg/monitor/dissect.go
GetDissectSummary
func GetDissectSummary(data []byte) *DissectSummary { dissectLock.Lock() defer dissectLock.Unlock() initParser() parser.DecodeLayers(data, &cache.decoded) ret := &DissectSummary{} for _, typ := range cache.decoded { switch typ { case layers.LayerTypeEthernet: ret.Ethernet = gopacket.LayerString(&cache.eth) src, dst := cache.eth.LinkFlow().Endpoints() ret.L2 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeIPv4: ret.IPv4 = gopacket.LayerString(&cache.ip4) src, dst := cache.ip4.NetworkFlow().Endpoints() ret.L3 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeIPv6: ret.IPv6 = gopacket.LayerString(&cache.ip6) src, dst := cache.ip6.NetworkFlow().Endpoints() ret.L3 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeTCP: ret.TCP = gopacket.LayerString(&cache.tcp) src, dst := cache.tcp.TransportFlow().Endpoints() ret.L4 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeUDP: ret.UDP = gopacket.LayerString(&cache.udp) src, dst := cache.udp.TransportFlow().Endpoints() ret.L4 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeICMPv4: ret.ICMPv4 = gopacket.LayerString(&cache.icmp4) case layers.LayerTypeICMPv6: ret.ICMPv6 = gopacket.LayerString(&cache.icmp6) } } return ret }
go
func GetDissectSummary(data []byte) *DissectSummary { dissectLock.Lock() defer dissectLock.Unlock() initParser() parser.DecodeLayers(data, &cache.decoded) ret := &DissectSummary{} for _, typ := range cache.decoded { switch typ { case layers.LayerTypeEthernet: ret.Ethernet = gopacket.LayerString(&cache.eth) src, dst := cache.eth.LinkFlow().Endpoints() ret.L2 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeIPv4: ret.IPv4 = gopacket.LayerString(&cache.ip4) src, dst := cache.ip4.NetworkFlow().Endpoints() ret.L3 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeIPv6: ret.IPv6 = gopacket.LayerString(&cache.ip6) src, dst := cache.ip6.NetworkFlow().Endpoints() ret.L3 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeTCP: ret.TCP = gopacket.LayerString(&cache.tcp) src, dst := cache.tcp.TransportFlow().Endpoints() ret.L4 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeUDP: ret.UDP = gopacket.LayerString(&cache.udp) src, dst := cache.udp.TransportFlow().Endpoints() ret.L4 = &Flow{Src: src.String(), Dst: dst.String()} case layers.LayerTypeICMPv4: ret.ICMPv4 = gopacket.LayerString(&cache.icmp4) case layers.LayerTypeICMPv6: ret.ICMPv6 = gopacket.LayerString(&cache.icmp6) } } return ret }
[ "func", "GetDissectSummary", "(", "data", "[", "]", "byte", ")", "*", "DissectSummary", "{", "dissectLock", ".", "Lock", "(", ")", "\n", "defer", "dissectLock", ".", "Unlock", "(", ")", "\n\n", "initParser", "(", ")", "\n", "parser", ".", "DecodeLayers", "(", "data", ",", "&", "cache", ".", "decoded", ")", "\n\n", "ret", ":=", "&", "DissectSummary", "{", "}", "\n\n", "for", "_", ",", "typ", ":=", "range", "cache", ".", "decoded", "{", "switch", "typ", "{", "case", "layers", ".", "LayerTypeEthernet", ":", "ret", ".", "Ethernet", "=", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "eth", ")", "\n", "src", ",", "dst", ":=", "cache", ".", "eth", ".", "LinkFlow", "(", ")", ".", "Endpoints", "(", ")", "\n", "ret", ".", "L2", "=", "&", "Flow", "{", "Src", ":", "src", ".", "String", "(", ")", ",", "Dst", ":", "dst", ".", "String", "(", ")", "}", "\n", "case", "layers", ".", "LayerTypeIPv4", ":", "ret", ".", "IPv4", "=", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "ip4", ")", "\n", "src", ",", "dst", ":=", "cache", ".", "ip4", ".", "NetworkFlow", "(", ")", ".", "Endpoints", "(", ")", "\n", "ret", ".", "L3", "=", "&", "Flow", "{", "Src", ":", "src", ".", "String", "(", ")", ",", "Dst", ":", "dst", ".", "String", "(", ")", "}", "\n", "case", "layers", ".", "LayerTypeIPv6", ":", "ret", ".", "IPv6", "=", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "ip6", ")", "\n", "src", ",", "dst", ":=", "cache", ".", "ip6", ".", "NetworkFlow", "(", ")", ".", "Endpoints", "(", ")", "\n", "ret", ".", "L3", "=", "&", "Flow", "{", "Src", ":", "src", ".", "String", "(", ")", ",", "Dst", ":", "dst", ".", "String", "(", ")", "}", "\n", "case", "layers", ".", "LayerTypeTCP", ":", "ret", ".", "TCP", "=", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "tcp", ")", "\n", "src", ",", "dst", ":=", "cache", ".", "tcp", ".", "TransportFlow", "(", ")", ".", "Endpoints", "(", ")", "\n", "ret", ".", "L4", "=", "&", "Flow", "{", "Src", ":", "src", ".", "String", "(", ")", ",", "Dst", ":", "dst", ".", "String", "(", ")", "}", "\n", "case", "layers", ".", "LayerTypeUDP", ":", "ret", ".", "UDP", "=", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "udp", ")", "\n", "src", ",", "dst", ":=", "cache", ".", "udp", ".", "TransportFlow", "(", ")", ".", "Endpoints", "(", ")", "\n", "ret", ".", "L4", "=", "&", "Flow", "{", "Src", ":", "src", ".", "String", "(", ")", ",", "Dst", ":", "dst", ".", "String", "(", ")", "}", "\n", "case", "layers", ".", "LayerTypeICMPv4", ":", "ret", ".", "ICMPv4", "=", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "icmp4", ")", "\n", "case", "layers", ".", "LayerTypeICMPv6", ":", "ret", ".", "ICMPv6", "=", "gopacket", ".", "LayerString", "(", "&", "cache", ".", "icmp6", ")", "\n", "}", "\n", "}", "\n", "return", "ret", "\n", "}" ]
// GetDissectSummary returns DissectSummary created from data
[ "GetDissectSummary", "returns", "DissectSummary", "created", "from", "data" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/monitor/dissect.go#L217-L255
163,230
cilium/cilium
pkg/labels/cidr/cidr.go
ipNetToLabel
func ipNetToLabel(cidr *net.IPNet) labels.Label { ones, _ := cidr.Mask.Size() lblStr := maskedIPToLabelString(&cidr.IP, ones) return labels.ParseLabel(lblStr) }
go
func ipNetToLabel(cidr *net.IPNet) labels.Label { ones, _ := cidr.Mask.Size() lblStr := maskedIPToLabelString(&cidr.IP, ones) return labels.ParseLabel(lblStr) }
[ "func", "ipNetToLabel", "(", "cidr", "*", "net", ".", "IPNet", ")", "labels", ".", "Label", "{", "ones", ",", "_", ":=", "cidr", ".", "Mask", ".", "Size", "(", ")", "\n", "lblStr", ":=", "maskedIPToLabelString", "(", "&", "cidr", ".", "IP", ",", "ones", ")", "\n", "return", "labels", ".", "ParseLabel", "(", "lblStr", ")", "\n", "}" ]
// ipNetToLabel turns a CIDR into a Label object which can be used to create // EndpointSelector objects.
[ "ipNetToLabel", "turns", "a", "CIDR", "into", "a", "Label", "object", "which", "can", "be", "used", "to", "create", "EndpointSelector", "objects", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/cidr/cidr.go#L51-L55
163,231
cilium/cilium
pkg/labels/cidr/cidr.go
IPStringToLabel
func IPStringToLabel(IP string) (labels.Label, error) { _, parsedPrefix, err := net.ParseCIDR(IP) if err != nil { parsedIP := net.ParseIP(IP) if parsedIP == nil { return labels.Label{}, fmt.Errorf("Not an IP address or CIDR: %s", IP) } bits := net.IPv6len * 8 if parsedIP.To4() != nil { bits = net.IPv4len * 8 } parsedPrefix = &net.IPNet{IP: parsedIP, Mask: net.CIDRMask(bits, bits)} } return ipNetToLabel(parsedPrefix), nil }
go
func IPStringToLabel(IP string) (labels.Label, error) { _, parsedPrefix, err := net.ParseCIDR(IP) if err != nil { parsedIP := net.ParseIP(IP) if parsedIP == nil { return labels.Label{}, fmt.Errorf("Not an IP address or CIDR: %s", IP) } bits := net.IPv6len * 8 if parsedIP.To4() != nil { bits = net.IPv4len * 8 } parsedPrefix = &net.IPNet{IP: parsedIP, Mask: net.CIDRMask(bits, bits)} } return ipNetToLabel(parsedPrefix), nil }
[ "func", "IPStringToLabel", "(", "IP", "string", ")", "(", "labels", ".", "Label", ",", "error", ")", "{", "_", ",", "parsedPrefix", ",", "err", ":=", "net", ".", "ParseCIDR", "(", "IP", ")", "\n", "if", "err", "!=", "nil", "{", "parsedIP", ":=", "net", ".", "ParseIP", "(", "IP", ")", "\n", "if", "parsedIP", "==", "nil", "{", "return", "labels", ".", "Label", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "IP", ")", "\n", "}", "\n", "bits", ":=", "net", ".", "IPv6len", "*", "8", "\n", "if", "parsedIP", ".", "To4", "(", ")", "!=", "nil", "{", "bits", "=", "net", ".", "IPv4len", "*", "8", "\n", "}", "\n", "parsedPrefix", "=", "&", "net", ".", "IPNet", "{", "IP", ":", "parsedIP", ",", "Mask", ":", "net", ".", "CIDRMask", "(", "bits", ",", "bits", ")", "}", "\n", "}", "\n\n", "return", "ipNetToLabel", "(", "parsedPrefix", ")", ",", "nil", "\n", "}" ]
// IPStringToLabel parses a string and returns it as a CIDR label. // // If "IP" is not a valid IP address or CIDR Prefix, returns an error.
[ "IPStringToLabel", "parses", "a", "string", "and", "returns", "it", "as", "a", "CIDR", "label", ".", "If", "IP", "is", "not", "a", "valid", "IP", "address", "or", "CIDR", "Prefix", "returns", "an", "error", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/cidr/cidr.go#L60-L75
163,232
cilium/cilium
pkg/k8s/labels.go
isInjectedWithIstioSidecarProxy
func isInjectedWithIstioSidecarProxy(scopedLog *logrus.Entry, pod *corev1.Pod) bool { istioStatusString, ok := pod.GetAnnotations()[AnnotationIstioSidecarStatus] if !ok { // Istio's injection annotation was not found. scopedLog.Debugf("No %s annotation", AnnotationIstioSidecarStatus) return false } scopedLog.Debugf("Found %s annotation with value: %s", AnnotationIstioSidecarStatus, istioStatusString) // Check that there's an "istio-proxy" container that uses an image // compatible with Cilium. for _, container := range pod.Spec.Containers { if container.Name != "istio-proxy" { continue } scopedLog.Debug("Found istio-proxy container in pod") if !SidecarIstioProxyImageRegexp.MatchString(container.Image) { continue } scopedLog.Debugf("istio-proxy container runs Cilium-compatible image: %s", container.Image) for _, mount := range container.VolumeMounts { if mount.MountPath != "/var/run/cilium" { continue } scopedLog.Debug("istio-proxy container has volume mounted into /var/run/cilium") return true } } scopedLog.Debug("No Cilium-compatible istio-proxy container found") return false }
go
func isInjectedWithIstioSidecarProxy(scopedLog *logrus.Entry, pod *corev1.Pod) bool { istioStatusString, ok := pod.GetAnnotations()[AnnotationIstioSidecarStatus] if !ok { // Istio's injection annotation was not found. scopedLog.Debugf("No %s annotation", AnnotationIstioSidecarStatus) return false } scopedLog.Debugf("Found %s annotation with value: %s", AnnotationIstioSidecarStatus, istioStatusString) // Check that there's an "istio-proxy" container that uses an image // compatible with Cilium. for _, container := range pod.Spec.Containers { if container.Name != "istio-proxy" { continue } scopedLog.Debug("Found istio-proxy container in pod") if !SidecarIstioProxyImageRegexp.MatchString(container.Image) { continue } scopedLog.Debugf("istio-proxy container runs Cilium-compatible image: %s", container.Image) for _, mount := range container.VolumeMounts { if mount.MountPath != "/var/run/cilium" { continue } scopedLog.Debug("istio-proxy container has volume mounted into /var/run/cilium") return true } } scopedLog.Debug("No Cilium-compatible istio-proxy container found") return false }
[ "func", "isInjectedWithIstioSidecarProxy", "(", "scopedLog", "*", "logrus", ".", "Entry", ",", "pod", "*", "corev1", ".", "Pod", ")", "bool", "{", "istioStatusString", ",", "ok", ":=", "pod", ".", "GetAnnotations", "(", ")", "[", "AnnotationIstioSidecarStatus", "]", "\n", "if", "!", "ok", "{", "// Istio's injection annotation was not found.", "scopedLog", ".", "Debugf", "(", "\"", "\"", ",", "AnnotationIstioSidecarStatus", ")", "\n", "return", "false", "\n", "}", "\n\n", "scopedLog", ".", "Debugf", "(", "\"", "\"", ",", "AnnotationIstioSidecarStatus", ",", "istioStatusString", ")", "\n\n", "// Check that there's an \"istio-proxy\" container that uses an image", "// compatible with Cilium.", "for", "_", ",", "container", ":=", "range", "pod", ".", "Spec", ".", "Containers", "{", "if", "container", ".", "Name", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "if", "!", "SidecarIstioProxyImageRegexp", ".", "MatchString", "(", "container", ".", "Image", ")", "{", "continue", "\n", "}", "\n", "scopedLog", ".", "Debugf", "(", "\"", "\"", ",", "container", ".", "Image", ")", "\n\n", "for", "_", ",", "mount", ":=", "range", "container", ".", "VolumeMounts", "{", "if", "mount", ".", "MountPath", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "return", "true", "\n", "}", "\n", "}", "\n\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "false", "\n", "}" ]
// isInjectedWithIstioSidecarProxy returns whether the given pod has been // injected by Istio with a sidecar proxy that is compatible with Cilium.
[ "isInjectedWithIstioSidecarProxy", "returns", "whether", "the", "given", "pod", "has", "been", "injected", "by", "Istio", "with", "a", "sidecar", "proxy", "that", "is", "compatible", "with", "Cilium", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/labels.go#L59-L95
163,233
cilium/cilium
pkg/k8s/labels.go
GetPodLabels
func GetPodLabels(namespace, podName string) (map[string]string, error) { scopedLog := log.WithFields(logrus.Fields{ logfields.K8sNamespace: namespace, logfields.K8sPodName: podName, }) scopedLog.Debug("Connecting to k8s apiserver to retrieve labels for pod") result, err := Client().CoreV1().Pods(namespace).Get(podName, metav1.GetOptions{}) if err != nil { return nil, err } // Also get all labels from the namespace where the pod is running k8sNs, err := Client().CoreV1().Namespaces().Get(namespace, metav1.GetOptions{}) if err != nil { return nil, err } k8sLabels := result.GetLabels() if k8sLabels == nil { k8sLabels = map[string]string{} } for k, v := range k8sNs.GetLabels() { k8sLabels[policy.JoinPath(k8sConst.PodNamespaceMetaLabels, k)] = v } k8sLabels[k8sConst.PodNamespaceLabel] = namespace if result.Spec.ServiceAccountName != "" { k8sLabels[k8sConst.PolicyLabelServiceAccount] = result.Spec.ServiceAccountName } else { delete(k8sLabels, k8sConst.PolicyLabelServiceAccount) } // If the pod has been injected with an Istio sidecar proxy compatible with // Cilium, add a label to notify that. // If the pod already contains that label to explicitly enable or disable // the sidecar proxy mode, keep it as is. if _, ok := k8sLabels[k8sConst.PolicyLabelIstioSidecarProxy]; !ok && isInjectedWithIstioSidecarProxy(scopedLog, result) { k8sLabels[k8sConst.PolicyLabelIstioSidecarProxy] = "true" } k8sLabels[k8sConst.PolicyLabelCluster] = option.Config.ClusterName return k8sLabels, nil }
go
func GetPodLabels(namespace, podName string) (map[string]string, error) { scopedLog := log.WithFields(logrus.Fields{ logfields.K8sNamespace: namespace, logfields.K8sPodName: podName, }) scopedLog.Debug("Connecting to k8s apiserver to retrieve labels for pod") result, err := Client().CoreV1().Pods(namespace).Get(podName, metav1.GetOptions{}) if err != nil { return nil, err } // Also get all labels from the namespace where the pod is running k8sNs, err := Client().CoreV1().Namespaces().Get(namespace, metav1.GetOptions{}) if err != nil { return nil, err } k8sLabels := result.GetLabels() if k8sLabels == nil { k8sLabels = map[string]string{} } for k, v := range k8sNs.GetLabels() { k8sLabels[policy.JoinPath(k8sConst.PodNamespaceMetaLabels, k)] = v } k8sLabels[k8sConst.PodNamespaceLabel] = namespace if result.Spec.ServiceAccountName != "" { k8sLabels[k8sConst.PolicyLabelServiceAccount] = result.Spec.ServiceAccountName } else { delete(k8sLabels, k8sConst.PolicyLabelServiceAccount) } // If the pod has been injected with an Istio sidecar proxy compatible with // Cilium, add a label to notify that. // If the pod already contains that label to explicitly enable or disable // the sidecar proxy mode, keep it as is. if _, ok := k8sLabels[k8sConst.PolicyLabelIstioSidecarProxy]; !ok && isInjectedWithIstioSidecarProxy(scopedLog, result) { k8sLabels[k8sConst.PolicyLabelIstioSidecarProxy] = "true" } k8sLabels[k8sConst.PolicyLabelCluster] = option.Config.ClusterName return k8sLabels, nil }
[ "func", "GetPodLabels", "(", "namespace", ",", "podName", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "scopedLog", ":=", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "K8sNamespace", ":", "namespace", ",", "logfields", ".", "K8sPodName", ":", "podName", ",", "}", ")", "\n", "scopedLog", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "result", ",", "err", ":=", "Client", "(", ")", ".", "CoreV1", "(", ")", ".", "Pods", "(", "namespace", ")", ".", "Get", "(", "podName", ",", "metav1", ".", "GetOptions", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "// Also get all labels from the namespace where the pod is running", "k8sNs", ",", "err", ":=", "Client", "(", ")", ".", "CoreV1", "(", ")", ".", "Namespaces", "(", ")", ".", "Get", "(", "namespace", ",", "metav1", ".", "GetOptions", "{", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "k8sLabels", ":=", "result", ".", "GetLabels", "(", ")", "\n", "if", "k8sLabels", "==", "nil", "{", "k8sLabels", "=", "map", "[", "string", "]", "string", "{", "}", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "k8sNs", ".", "GetLabels", "(", ")", "{", "k8sLabels", "[", "policy", ".", "JoinPath", "(", "k8sConst", ".", "PodNamespaceMetaLabels", ",", "k", ")", "]", "=", "v", "\n", "}", "\n", "k8sLabels", "[", "k8sConst", ".", "PodNamespaceLabel", "]", "=", "namespace", "\n\n", "if", "result", ".", "Spec", ".", "ServiceAccountName", "!=", "\"", "\"", "{", "k8sLabels", "[", "k8sConst", ".", "PolicyLabelServiceAccount", "]", "=", "result", ".", "Spec", ".", "ServiceAccountName", "\n", "}", "else", "{", "delete", "(", "k8sLabels", ",", "k8sConst", ".", "PolicyLabelServiceAccount", ")", "\n", "}", "\n\n", "// If the pod has been injected with an Istio sidecar proxy compatible with", "// Cilium, add a label to notify that.", "// If the pod already contains that label to explicitly enable or disable", "// the sidecar proxy mode, keep it as is.", "if", "_", ",", "ok", ":=", "k8sLabels", "[", "k8sConst", ".", "PolicyLabelIstioSidecarProxy", "]", ";", "!", "ok", "&&", "isInjectedWithIstioSidecarProxy", "(", "scopedLog", ",", "result", ")", "{", "k8sLabels", "[", "k8sConst", ".", "PolicyLabelIstioSidecarProxy", "]", "=", "\"", "\"", "\n", "}", "\n\n", "k8sLabels", "[", "k8sConst", ".", "PolicyLabelCluster", "]", "=", "option", ".", "Config", ".", "ClusterName", "\n\n", "return", "k8sLabels", ",", "nil", "\n", "}" ]
// GetPodLabels returns the labels of a pod
[ "GetPodLabels", "returns", "the", "labels", "of", "a", "pod" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/labels.go#L98-L143
163,234
cilium/cilium
api/v1/models/identity_endpoints.go
Validate
func (m *IdentityEndpoints) Validate(formats strfmt.Registry) error { var res []error if err := m.validateIdentity(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *IdentityEndpoints) Validate(formats strfmt.Registry) error { var res []error if err := m.validateIdentity(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "IdentityEndpoints", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateIdentity", "(", "formats", ")", ";", "err", "!=", "nil", "{", "res", "=", "append", "(", "res", ",", "err", ")", "\n", "}", "\n\n", "if", "len", "(", "res", ")", ">", "0", "{", "return", "errors", ".", "CompositeValidationError", "(", "res", "...", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate validates this identity endpoints
[ "Validate", "validates", "this", "identity", "endpoints" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/identity_endpoints.go#L27-L38
163,235
cilium/cilium
pkg/datapath/loader/hash.go
sumEndpoint
func (d *datapathHash) sumEndpoint(dp datapath.Datapath, epCfg datapath.EndpointConfiguration, staticData bool) (string, error) { result, err := d.Copy() if err != nil { return "", err } if staticData { dp.WriteEndpointConfig(result, epCfg) } else { dp.WriteTemplateConfig(result, epCfg) } return result.String(), nil }
go
func (d *datapathHash) sumEndpoint(dp datapath.Datapath, epCfg datapath.EndpointConfiguration, staticData bool) (string, error) { result, err := d.Copy() if err != nil { return "", err } if staticData { dp.WriteEndpointConfig(result, epCfg) } else { dp.WriteTemplateConfig(result, epCfg) } return result.String(), nil }
[ "func", "(", "d", "*", "datapathHash", ")", "sumEndpoint", "(", "dp", "datapath", ".", "Datapath", ",", "epCfg", "datapath", ".", "EndpointConfiguration", ",", "staticData", "bool", ")", "(", "string", ",", "error", ")", "{", "result", ",", "err", ":=", "d", ".", "Copy", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "if", "staticData", "{", "dp", ".", "WriteEndpointConfig", "(", "result", ",", "epCfg", ")", "\n", "}", "else", "{", "dp", ".", "WriteTemplateConfig", "(", "result", ",", "epCfg", ")", "\n", "}", "\n", "return", "result", ".", "String", "(", ")", ",", "nil", "\n", "}" ]
// sumEndpoint returns the hash of the complete datapath for an endpoint. // It does not change the underlying hash state.
[ "sumEndpoint", "returns", "the", "hash", "of", "the", "complete", "datapath", "for", "an", "endpoint", ".", "It", "does", "not", "change", "the", "underlying", "hash", "state", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/datapath/loader/hash.go#L70-L81
163,236
cilium/cilium
pkg/option/option.go
RequiresOption
func (o Option) RequiresOption(name string) bool { for _, o := range o.Requires { if o == name { return true } } return false }
go
func (o Option) RequiresOption(name string) bool { for _, o := range o.Requires { if o == name { return true } } return false }
[ "func", "(", "o", "Option", ")", "RequiresOption", "(", "name", "string", ")", "bool", "{", "for", "_", ",", "o", ":=", "range", "o", ".", "Requires", "{", "if", "o", "==", "name", "{", "return", "true", "\n", "}", "\n", "}", "\n\n", "return", "false", "\n", "}" ]
// RequiresOption returns true if the option requires the specified option `name`.
[ "RequiresOption", "returns", "true", "if", "the", "option", "requires", "the", "specified", "option", "name", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L71-L79
163,237
cilium/cilium
pkg/option/option.go
ValidateConfigurationMap
func (l *OptionLibrary) ValidateConfigurationMap(n models.ConfigurationMap) (OptionMap, error) { o := make(OptionMap) for k, v := range n { _, newVal, err := ParseKeyValue(l, k, v) if err != nil { return nil, err } if err := l.Validate(k, v); err != nil { return nil, err } o[k] = newVal } return o, nil }
go
func (l *OptionLibrary) ValidateConfigurationMap(n models.ConfigurationMap) (OptionMap, error) { o := make(OptionMap) for k, v := range n { _, newVal, err := ParseKeyValue(l, k, v) if err != nil { return nil, err } if err := l.Validate(k, v); err != nil { return nil, err } o[k] = newVal } return o, nil }
[ "func", "(", "l", "*", "OptionLibrary", ")", "ValidateConfigurationMap", "(", "n", "models", ".", "ConfigurationMap", ")", "(", "OptionMap", ",", "error", ")", "{", "o", ":=", "make", "(", "OptionMap", ")", "\n", "for", "k", ",", "v", ":=", "range", "n", "{", "_", ",", "newVal", ",", "err", ":=", "ParseKeyValue", "(", "l", ",", "k", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", ":=", "l", ".", "Validate", "(", "k", ",", "v", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "o", "[", "k", "]", "=", "newVal", "\n", "}", "\n\n", "return", "o", ",", "nil", "\n", "}" ]
// ValidateConfigurationMap validates a given configuration map based on the // option library
[ "ValidateConfigurationMap", "validates", "a", "given", "configuration", "map", "based", "on", "the", "option", "library" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L116-L131
163,238
cilium/cilium
pkg/option/option.go
GetImmutableModel
func (o *IntOptions) GetImmutableModel() *models.ConfigurationMap { immutableCfg := make(models.ConfigurationMap) return &immutableCfg }
go
func (o *IntOptions) GetImmutableModel() *models.ConfigurationMap { immutableCfg := make(models.ConfigurationMap) return &immutableCfg }
[ "func", "(", "o", "*", "IntOptions", ")", "GetImmutableModel", "(", ")", "*", "models", ".", "ConfigurationMap", "{", "immutableCfg", ":=", "make", "(", "models", ".", "ConfigurationMap", ")", "\n", "return", "&", "immutableCfg", "\n", "}" ]
// GetImmutableModel returns the set of immutable options as a ConfigurationMap API model.
[ "GetImmutableModel", "returns", "the", "set", "of", "immutable", "options", "as", "a", "ConfigurationMap", "API", "model", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L170-L173
163,239
cilium/cilium
pkg/option/option.go
GetMutableModel
func (o *IntOptions) GetMutableModel() *models.ConfigurationMap { mutableCfg := make(models.ConfigurationMap) o.optsMU.RLock() for k, v := range o.Opts { _, config := o.Library.Lookup(k) // It's possible that an option has since been removed and thus has // no corresponding configuration; need to check if configuration is // nil accordingly. if config != nil { if config.Format == nil { if v == OptionDisabled { mutableCfg[k] = fmt.Sprintf("Disabled") } else { mutableCfg[k] = fmt.Sprintf("Enabled") } } else { mutableCfg[k] = config.Format(v) } } } o.optsMU.RUnlock() return &mutableCfg }
go
func (o *IntOptions) GetMutableModel() *models.ConfigurationMap { mutableCfg := make(models.ConfigurationMap) o.optsMU.RLock() for k, v := range o.Opts { _, config := o.Library.Lookup(k) // It's possible that an option has since been removed and thus has // no corresponding configuration; need to check if configuration is // nil accordingly. if config != nil { if config.Format == nil { if v == OptionDisabled { mutableCfg[k] = fmt.Sprintf("Disabled") } else { mutableCfg[k] = fmt.Sprintf("Enabled") } } else { mutableCfg[k] = config.Format(v) } } } o.optsMU.RUnlock() return &mutableCfg }
[ "func", "(", "o", "*", "IntOptions", ")", "GetMutableModel", "(", ")", "*", "models", ".", "ConfigurationMap", "{", "mutableCfg", ":=", "make", "(", "models", ".", "ConfigurationMap", ")", "\n", "o", ".", "optsMU", ".", "RLock", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "o", ".", "Opts", "{", "_", ",", "config", ":=", "o", ".", "Library", ".", "Lookup", "(", "k", ")", "\n\n", "// It's possible that an option has since been removed and thus has", "// no corresponding configuration; need to check if configuration is", "// nil accordingly.", "if", "config", "!=", "nil", "{", "if", "config", ".", "Format", "==", "nil", "{", "if", "v", "==", "OptionDisabled", "{", "mutableCfg", "[", "k", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", "\n", "}", "else", "{", "mutableCfg", "[", "k", "]", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "else", "{", "mutableCfg", "[", "k", "]", "=", "config", ".", "Format", "(", "v", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "o", ".", "optsMU", ".", "RUnlock", "(", ")", "\n\n", "return", "&", "mutableCfg", "\n", "}" ]
// GetMutableModel returns the set of mutable options as a ConfigurationMap API model.
[ "GetMutableModel", "returns", "the", "set", "of", "mutable", "options", "as", "a", "ConfigurationMap", "API", "model", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L176-L200
163,240
cilium/cilium
pkg/option/option.go
SetValidated
func (o *IntOptions) SetValidated(key string, value OptionSetting) { o.optsMU.Lock() o.Opts[key] = value o.optsMU.Unlock() }
go
func (o *IntOptions) SetValidated(key string, value OptionSetting) { o.optsMU.Lock() o.Opts[key] = value o.optsMU.Unlock() }
[ "func", "(", "o", "*", "IntOptions", ")", "SetValidated", "(", "key", "string", ",", "value", "OptionSetting", ")", "{", "o", ".", "optsMU", ".", "Lock", "(", ")", "\n", "o", ".", "Opts", "[", "key", "]", "=", "value", "\n", "o", ".", "optsMU", ".", "Unlock", "(", ")", "\n", "}" ]
// SetValidated sets the option `key` to the specified value. The caller is // expected to have validated the input to this function.
[ "SetValidated", "sets", "the", "option", "key", "to", "the", "specified", "value", ".", "The", "caller", "is", "expected", "to", "have", "validated", "the", "input", "to", "this", "function", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L240-L244
163,241
cilium/cilium
pkg/option/option.go
SetBool
func (o *IntOptions) SetBool(key string, value bool) { intValue := OptionDisabled if value { intValue = OptionEnabled } o.optsMU.Lock() o.Opts[key] = intValue o.optsMU.Unlock() }
go
func (o *IntOptions) SetBool(key string, value bool) { intValue := OptionDisabled if value { intValue = OptionEnabled } o.optsMU.Lock() o.Opts[key] = intValue o.optsMU.Unlock() }
[ "func", "(", "o", "*", "IntOptions", ")", "SetBool", "(", "key", "string", ",", "value", "bool", ")", "{", "intValue", ":=", "OptionDisabled", "\n", "if", "value", "{", "intValue", "=", "OptionEnabled", "\n", "}", "\n", "o", ".", "optsMU", ".", "Lock", "(", ")", "\n", "o", ".", "Opts", "[", "key", "]", "=", "intValue", "\n", "o", ".", "optsMU", ".", "Unlock", "(", ")", "\n", "}" ]
// SetBool sets the specified option to Enabled.
[ "SetBool", "sets", "the", "specified", "option", "to", "Enabled", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L247-L255
163,242
cilium/cilium
pkg/option/option.go
Validate
func (o *IntOptions) Validate(n models.ConfigurationMap) error { o.optsMU.RLock() defer o.optsMU.RUnlock() for k, v := range n { _, newVal, err := ParseKeyValue(o.Library, k, v) if err != nil { return err } // Ignore validation if value is identical if oldVal, ok := o.Opts[k]; ok && oldVal == newVal { continue } if err := o.Library.Validate(k, v); err != nil { return err } } return nil }
go
func (o *IntOptions) Validate(n models.ConfigurationMap) error { o.optsMU.RLock() defer o.optsMU.RUnlock() for k, v := range n { _, newVal, err := ParseKeyValue(o.Library, k, v) if err != nil { return err } // Ignore validation if value is identical if oldVal, ok := o.Opts[k]; ok && oldVal == newVal { continue } if err := o.Library.Validate(k, v); err != nil { return err } } return nil }
[ "func", "(", "o", "*", "IntOptions", ")", "Validate", "(", "n", "models", ".", "ConfigurationMap", ")", "error", "{", "o", ".", "optsMU", ".", "RLock", "(", ")", "\n", "defer", "o", ".", "optsMU", ".", "RUnlock", "(", ")", "\n", "for", "k", ",", "v", ":=", "range", "n", "{", "_", ",", "newVal", ",", "err", ":=", "ParseKeyValue", "(", "o", ".", "Library", ",", "k", ",", "v", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Ignore validation if value is identical", "if", "oldVal", ",", "ok", ":=", "o", ".", "Opts", "[", "k", "]", ";", "ok", "&&", "oldVal", "==", "newVal", "{", "continue", "\n", "}", "\n\n", "if", "err", ":=", "o", ".", "Library", ".", "Validate", "(", "k", ",", "v", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// Validate validates a given configuration map based on the option library
[ "Validate", "validates", "a", "given", "configuration", "map", "based", "on", "the", "option", "library" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L390-L410
163,243
cilium/cilium
pkg/option/option.go
enable
func (o *IntOptions) enable(name string) { if o.Library != nil { if _, opt := o.Library.Lookup(name); opt != nil { for _, dependency := range opt.Requires { o.enable(dependency) } } } o.Opts[name] = OptionEnabled }
go
func (o *IntOptions) enable(name string) { if o.Library != nil { if _, opt := o.Library.Lookup(name); opt != nil { for _, dependency := range opt.Requires { o.enable(dependency) } } } o.Opts[name] = OptionEnabled }
[ "func", "(", "o", "*", "IntOptions", ")", "enable", "(", "name", "string", ")", "{", "if", "o", ".", "Library", "!=", "nil", "{", "if", "_", ",", "opt", ":=", "o", ".", "Library", ".", "Lookup", "(", "name", ")", ";", "opt", "!=", "nil", "{", "for", "_", ",", "dependency", ":=", "range", "opt", ".", "Requires", "{", "o", ".", "enable", "(", "dependency", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "o", ".", "Opts", "[", "name", "]", "=", "OptionEnabled", "\n", "}" ]
// enable enables the option `name` with all its dependencies
[ "enable", "enables", "the", "option", "name", "with", "all", "its", "dependencies" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L416-L426
163,244
cilium/cilium
pkg/option/option.go
set
func (o *IntOptions) set(name string, value OptionSetting) { o.enable(name) o.Opts[name] = value }
go
func (o *IntOptions) set(name string, value OptionSetting) { o.enable(name) o.Opts[name] = value }
[ "func", "(", "o", "*", "IntOptions", ")", "set", "(", "name", "string", ",", "value", "OptionSetting", ")", "{", "o", ".", "enable", "(", "name", ")", "\n", "o", ".", "Opts", "[", "name", "]", "=", "value", "\n", "}" ]
// set enables the option `name` with all its dependencies, and sets the // integer level of the option to `value`.
[ "set", "enables", "the", "option", "name", "with", "all", "its", "dependencies", "and", "sets", "the", "integer", "level", "of", "the", "option", "to", "value", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L430-L433
163,245
cilium/cilium
pkg/option/option.go
disable
func (o *IntOptions) disable(name string) { o.Opts[name] = OptionDisabled if o.Library != nil { // Disable all options which have a dependency on the option // that was just disabled for key, opt := range *o.Library { if opt.RequiresOption(name) && o.Opts[key] != OptionDisabled { o.disable(key) } } } }
go
func (o *IntOptions) disable(name string) { o.Opts[name] = OptionDisabled if o.Library != nil { // Disable all options which have a dependency on the option // that was just disabled for key, opt := range *o.Library { if opt.RequiresOption(name) && o.Opts[key] != OptionDisabled { o.disable(key) } } } }
[ "func", "(", "o", "*", "IntOptions", ")", "disable", "(", "name", "string", ")", "{", "o", ".", "Opts", "[", "name", "]", "=", "OptionDisabled", "\n\n", "if", "o", ".", "Library", "!=", "nil", "{", "// Disable all options which have a dependency on the option", "// that was just disabled", "for", "key", ",", "opt", ":=", "range", "*", "o", ".", "Library", "{", "if", "opt", ".", "RequiresOption", "(", "name", ")", "&&", "o", ".", "Opts", "[", "key", "]", "!=", "OptionDisabled", "{", "o", ".", "disable", "(", "key", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// disable disables the option `name`. All options which depend on the option // to be disabled will be disabled. Options which have previously been enabled // as a dependency will not be automatically disabled.
[ "disable", "disables", "the", "option", "name", ".", "All", "options", "which", "depend", "on", "the", "option", "to", "be", "disabled", "will", "be", "disabled", ".", "Options", "which", "have", "previously", "been", "enabled", "as", "a", "dependency", "will", "not", "be", "automatically", "disabled", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L438-L450
163,246
cilium/cilium
pkg/option/option.go
ApplyValidated
func (o *IntOptions) ApplyValidated(n OptionMap, changed ChangedFunc, data interface{}) int { changes := make([]changedOptions, 0, len(n)) o.optsMU.Lock() for k, optVal := range n { val, ok := o.Opts[k] if optVal == OptionDisabled { /* Only disable if enabled already */ if ok && val != OptionDisabled { o.disable(k) changes = append(changes, changedOptions{key: k, value: optVal}) } } else { /* Only enable if not enabled already */ if !ok || val == OptionDisabled { o.set(k, optVal) changes = append(changes, changedOptions{key: k, value: optVal}) } } } o.optsMU.Unlock() for _, change := range changes { changed(change.key, change.value, data) } return len(changes) }
go
func (o *IntOptions) ApplyValidated(n OptionMap, changed ChangedFunc, data interface{}) int { changes := make([]changedOptions, 0, len(n)) o.optsMU.Lock() for k, optVal := range n { val, ok := o.Opts[k] if optVal == OptionDisabled { /* Only disable if enabled already */ if ok && val != OptionDisabled { o.disable(k) changes = append(changes, changedOptions{key: k, value: optVal}) } } else { /* Only enable if not enabled already */ if !ok || val == OptionDisabled { o.set(k, optVal) changes = append(changes, changedOptions{key: k, value: optVal}) } } } o.optsMU.Unlock() for _, change := range changes { changed(change.key, change.value, data) } return len(changes) }
[ "func", "(", "o", "*", "IntOptions", ")", "ApplyValidated", "(", "n", "OptionMap", ",", "changed", "ChangedFunc", ",", "data", "interface", "{", "}", ")", "int", "{", "changes", ":=", "make", "(", "[", "]", "changedOptions", ",", "0", ",", "len", "(", "n", ")", ")", "\n\n", "o", ".", "optsMU", ".", "Lock", "(", ")", "\n", "for", "k", ",", "optVal", ":=", "range", "n", "{", "val", ",", "ok", ":=", "o", ".", "Opts", "[", "k", "]", "\n\n", "if", "optVal", "==", "OptionDisabled", "{", "/* Only disable if enabled already */", "if", "ok", "&&", "val", "!=", "OptionDisabled", "{", "o", ".", "disable", "(", "k", ")", "\n", "changes", "=", "append", "(", "changes", ",", "changedOptions", "{", "key", ":", "k", ",", "value", ":", "optVal", "}", ")", "\n", "}", "\n", "}", "else", "{", "/* Only enable if not enabled already */", "if", "!", "ok", "||", "val", "==", "OptionDisabled", "{", "o", ".", "set", "(", "k", ",", "optVal", ")", "\n", "changes", "=", "append", "(", "changes", ",", "changedOptions", "{", "key", ":", "k", ",", "value", ":", "optVal", "}", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "o", ".", "optsMU", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", "change", ":=", "range", "changes", "{", "changed", "(", "change", ".", "key", ",", "change", ".", "value", ",", "data", ")", "\n", "}", "\n\n", "return", "len", "(", "changes", ")", "\n", "}" ]
// ApplyValidated takes a configuration map and applies the changes. For an // option which is changed, the `ChangedFunc` function is called with the // `data` argument passed in as well. Returns the number of options changed if // any. // // The caller is expected to have validated the configuration options prior to // calling this function.
[ "ApplyValidated", "takes", "a", "configuration", "map", "and", "applies", "the", "changes", ".", "For", "an", "option", "which", "is", "changed", "the", "ChangedFunc", "function", "is", "called", "with", "the", "data", "argument", "passed", "in", "as", "well", ".", "Returns", "the", "number", "of", "options", "changed", "if", "any", ".", "The", "caller", "is", "expected", "to", "have", "validated", "the", "configuration", "options", "prior", "to", "calling", "this", "function", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/option/option.go#L464-L492
163,247
cilium/cilium
pkg/labels/labels.go
AppendPrefixInKey
func (l Labels) AppendPrefixInKey(prefix string) Labels { newLabels := Labels{} for k, v := range l { newLabels[prefix+k] = Label{ Key: prefix + v.Key, Value: v.Value, Source: v.Source, } } return newLabels }
go
func (l Labels) AppendPrefixInKey(prefix string) Labels { newLabels := Labels{} for k, v := range l { newLabels[prefix+k] = Label{ Key: prefix + v.Key, Value: v.Value, Source: v.Source, } } return newLabels }
[ "func", "(", "l", "Labels", ")", "AppendPrefixInKey", "(", "prefix", "string", ")", "Labels", "{", "newLabels", ":=", "Labels", "{", "}", "\n", "for", "k", ",", "v", ":=", "range", "l", "{", "newLabels", "[", "prefix", "+", "k", "]", "=", "Label", "{", "Key", ":", "prefix", "+", "v", ".", "Key", ",", "Value", ":", "v", ".", "Value", ",", "Source", ":", "v", ".", "Source", ",", "}", "\n", "}", "\n", "return", "newLabels", "\n", "}" ]
// AppendPrefixInKey appends the given prefix to all the Key's of the map and the // respective Labels' Key.
[ "AppendPrefixInKey", "appends", "the", "given", "prefix", "to", "all", "the", "Key", "s", "of", "the", "map", "and", "the", "respective", "Labels", "Key", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L155-L165
163,248
cilium/cilium
pkg/labels/labels.go
Equals
func (l Labels) Equals(other Labels) bool { if len(l) != len(other) { return false } for k, lbl1 := range l { if lbl2, ok := other[k]; ok { if lbl1.Source == lbl2.Source && lbl1.Key == lbl2.Key && lbl1.Value == lbl2.Value { continue } } return false } return true }
go
func (l Labels) Equals(other Labels) bool { if len(l) != len(other) { return false } for k, lbl1 := range l { if lbl2, ok := other[k]; ok { if lbl1.Source == lbl2.Source && lbl1.Key == lbl2.Key && lbl1.Value == lbl2.Value { continue } } return false } return true }
[ "func", "(", "l", "Labels", ")", "Equals", "(", "other", "Labels", ")", "bool", "{", "if", "len", "(", "l", ")", "!=", "len", "(", "other", ")", "{", "return", "false", "\n", "}", "\n\n", "for", "k", ",", "lbl1", ":=", "range", "l", "{", "if", "lbl2", ",", "ok", ":=", "other", "[", "k", "]", ";", "ok", "{", "if", "lbl1", ".", "Source", "==", "lbl2", ".", "Source", "&&", "lbl1", ".", "Key", "==", "lbl2", ".", "Key", "&&", "lbl1", ".", "Value", "==", "lbl2", ".", "Value", "{", "continue", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}", "\n", "return", "true", "\n", "}" ]
// Equals returns true if the two Labels contain the same set of labels.
[ "Equals", "returns", "true", "if", "the", "two", "Labels", "contain", "the", "same", "set", "of", "labels", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L168-L182
163,249
cilium/cilium
pkg/labels/labels.go
GetFromSource
func (l Labels) GetFromSource(source string) Labels { lbls := Labels{} for k, v := range l { if v.Source == source { lbls[k] = v } } return lbls }
go
func (l Labels) GetFromSource(source string) Labels { lbls := Labels{} for k, v := range l { if v.Source == source { lbls[k] = v } } return lbls }
[ "func", "(", "l", "Labels", ")", "GetFromSource", "(", "source", "string", ")", "Labels", "{", "lbls", ":=", "Labels", "{", "}", "\n", "for", "k", ",", "v", ":=", "range", "l", "{", "if", "v", ".", "Source", "==", "source", "{", "lbls", "[", "k", "]", "=", "v", "\n", "}", "\n", "}", "\n", "return", "lbls", "\n", "}" ]
// GetFromSource returns all labels that are from the given source.
[ "GetFromSource", "returns", "all", "labels", "that", "are", "from", "the", "given", "source", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L185-L193
163,250
cilium/cilium
pkg/labels/labels.go
Matches
func (l *Label) Matches(target *Label) bool { return l.IsAllLabel() || l.Equals(target) }
go
func (l *Label) Matches(target *Label) bool { return l.IsAllLabel() || l.Equals(target) }
[ "func", "(", "l", "*", "Label", ")", "Matches", "(", "target", "*", "Label", ")", "bool", "{", "return", "l", ".", "IsAllLabel", "(", ")", "||", "l", ".", "Equals", "(", "target", ")", "\n", "}" ]
// Matches returns true if l matches the target
[ "Matches", "returns", "true", "if", "l", "matches", "the", "target" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L246-L248
163,251
cilium/cilium
pkg/labels/labels.go
NewLabelsFromModel
func NewLabelsFromModel(base []string) Labels { lbls := make(Labels, len(base)) for _, v := range base { if lbl := ParseLabel(v); lbl.Key != "" { lbls[lbl.Key] = lbl } } return lbls }
go
func NewLabelsFromModel(base []string) Labels { lbls := make(Labels, len(base)) for _, v := range base { if lbl := ParseLabel(v); lbl.Key != "" { lbls[lbl.Key] = lbl } } return lbls }
[ "func", "NewLabelsFromModel", "(", "base", "[", "]", "string", ")", "Labels", "{", "lbls", ":=", "make", "(", "Labels", ",", "len", "(", "base", ")", ")", "\n", "for", "_", ",", "v", ":=", "range", "base", "{", "if", "lbl", ":=", "ParseLabel", "(", "v", ")", ";", "lbl", ".", "Key", "!=", "\"", "\"", "{", "lbls", "[", "lbl", ".", "Key", "]", "=", "lbl", "\n", "}", "\n", "}", "\n\n", "return", "lbls", "\n", "}" ]
// NewLabelsFromModel creates labels from string array.
[ "NewLabelsFromModel", "creates", "labels", "from", "string", "array", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L371-L380
163,252
cilium/cilium
pkg/labels/labels.go
NewSelectLabelArrayFromModel
func NewSelectLabelArrayFromModel(base []string) LabelArray { lbls := make(LabelArray, 0, len(base)) for i := range base { lbls = append(lbls, ParseSelectLabel(base[i])) } return lbls.Sort() }
go
func NewSelectLabelArrayFromModel(base []string) LabelArray { lbls := make(LabelArray, 0, len(base)) for i := range base { lbls = append(lbls, ParseSelectLabel(base[i])) } return lbls.Sort() }
[ "func", "NewSelectLabelArrayFromModel", "(", "base", "[", "]", "string", ")", "LabelArray", "{", "lbls", ":=", "make", "(", "LabelArray", ",", "0", ",", "len", "(", "base", ")", ")", "\n", "for", "i", ":=", "range", "base", "{", "lbls", "=", "append", "(", "lbls", ",", "ParseSelectLabel", "(", "base", "[", "i", "]", ")", ")", "\n", "}", "\n\n", "return", "lbls", ".", "Sort", "(", ")", "\n", "}" ]
// NewSelectLabelArrayFromModel parses a slice of strings and converts them // into an array of selecting labels, sorted by the key.
[ "NewSelectLabelArrayFromModel", "parses", "a", "slice", "of", "strings", "and", "converts", "them", "into", "an", "array", "of", "selecting", "labels", "sorted", "by", "the", "key", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L389-L396
163,253
cilium/cilium
pkg/labels/labels.go
GetModel
func (l Labels) GetModel() []string { res := make([]string, 0, len(l)) for _, v := range l { res = append(res, v.String()) } return res }
go
func (l Labels) GetModel() []string { res := make([]string, 0, len(l)) for _, v := range l { res = append(res, v.String()) } return res }
[ "func", "(", "l", "Labels", ")", "GetModel", "(", ")", "[", "]", "string", "{", "res", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "l", ")", ")", "\n", "for", "_", ",", "v", ":=", "range", "l", "{", "res", "=", "append", "(", "res", ",", "v", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "res", "\n", "}" ]
// GetModel returns model with all the values of the labels.
[ "GetModel", "returns", "model", "with", "all", "the", "values", "of", "the", "labels", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L399-L405
163,254
cilium/cilium
pkg/labels/labels.go
SHA256Sum
func (l Labels) SHA256Sum() string { return fmt.Sprintf("%x", sha512.Sum512_256(l.SortedList())) }
go
func (l Labels) SHA256Sum() string { return fmt.Sprintf("%x", sha512.Sum512_256(l.SortedList())) }
[ "func", "(", "l", "Labels", ")", "SHA256Sum", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sha512", ".", "Sum512_256", "(", "l", ".", "SortedList", "(", ")", ")", ")", "\n", "}" ]
// SHA256Sum calculates l' internal SHA256Sum. For a particular set of labels is // guarantee that it will always have the same SHA256Sum.
[ "SHA256Sum", "calculates", "l", "internal", "SHA256Sum", ".", "For", "a", "particular", "set", "of", "labels", "is", "guarantee", "that", "it", "will", "always", "have", "the", "same", "SHA256Sum", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L423-L425
163,255
cilium/cilium
pkg/labels/labels.go
FormatForKVStore
func (l Label) FormatForKVStore() string { // We don't care if the values already have a '=' since this method is // only used to calculate a SHA256Sum // // We absolutely care that the final character is a semi-colon. // Identity allocation in the kvstore depends on this (see // kvstore.prefixMatchesKey()) return fmt.Sprintf(`%s:%s=%s;`, l.Source, l.Key, l.Value) }
go
func (l Label) FormatForKVStore() string { // We don't care if the values already have a '=' since this method is // only used to calculate a SHA256Sum // // We absolutely care that the final character is a semi-colon. // Identity allocation in the kvstore depends on this (see // kvstore.prefixMatchesKey()) return fmt.Sprintf(`%s:%s=%s;`, l.Source, l.Key, l.Value) }
[ "func", "(", "l", "Label", ")", "FormatForKVStore", "(", ")", "string", "{", "// We don't care if the values already have a '=' since this method is", "// only used to calculate a SHA256Sum", "//", "// We absolutely care that the final character is a semi-colon.", "// Identity allocation in the kvstore depends on this (see", "// kvstore.prefixMatchesKey())", "return", "fmt", ".", "Sprintf", "(", "`%s:%s=%s;`", ",", "l", ".", "Source", ",", "l", ".", "Key", ",", "l", ".", "Value", ")", "\n", "}" ]
// FormatForKVStore returns the label as a formatted string, ending in // a semicolon // // DO NOT BREAK THE FORMAT OF THIS. THE RETURNED STRING IS USED AS // PART OF THE KEY IN THE KEY-VALUE STORE. // // Non-pointer receiver allows this to be called on a value in a map.
[ "FormatForKVStore", "returns", "the", "label", "as", "a", "formatted", "string", "ending", "in", "a", "semicolon", "DO", "NOT", "BREAK", "THE", "FORMAT", "OF", "THIS", ".", "THE", "RETURNED", "STRING", "IS", "USED", "AS", "PART", "OF", "THE", "KEY", "IN", "THE", "KEY", "-", "VALUE", "STORE", ".", "Non", "-", "pointer", "receiver", "allows", "this", "to", "be", "called", "on", "a", "value", "in", "a", "map", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L434-L442
163,256
cilium/cilium
pkg/labels/labels.go
SortedList
func (l Labels) SortedList() []byte { var keys []string for k := range l { keys = append(keys, k) } sort.Strings(keys) result := "" for _, k := range keys { result += l[k].FormatForKVStore() } return []byte(result) }
go
func (l Labels) SortedList() []byte { var keys []string for k := range l { keys = append(keys, k) } sort.Strings(keys) result := "" for _, k := range keys { result += l[k].FormatForKVStore() } return []byte(result) }
[ "func", "(", "l", "Labels", ")", "SortedList", "(", ")", "[", "]", "byte", "{", "var", "keys", "[", "]", "string", "\n", "for", "k", ":=", "range", "l", "{", "keys", "=", "append", "(", "keys", ",", "k", ")", "\n", "}", "\n", "sort", ".", "Strings", "(", "keys", ")", "\n\n", "result", ":=", "\"", "\"", "\n", "for", "_", ",", "k", ":=", "range", "keys", "{", "result", "+=", "l", "[", "k", "]", ".", "FormatForKVStore", "(", ")", "\n", "}", "\n\n", "return", "[", "]", "byte", "(", "result", ")", "\n", "}" ]
// SortedList returns the labels as a sorted list, separated by semicolon // // DO NOT BREAK THE FORMAT OF THIS. THE RETURNED STRING IS USED AS KEY IN // THE KEY-VALUE STORE.
[ "SortedList", "returns", "the", "labels", "as", "a", "sorted", "list", "separated", "by", "semicolon", "DO", "NOT", "BREAK", "THE", "FORMAT", "OF", "THIS", ".", "THE", "RETURNED", "STRING", "IS", "USED", "AS", "KEY", "IN", "THE", "KEY", "-", "VALUE", "STORE", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L448-L461
163,257
cilium/cilium
pkg/labels/labels.go
LabelArray
func (l Labels) LabelArray() LabelArray { labels := make(LabelArray, 0, len(l)) for _, v := range l { labels = append(labels, v) } return labels.Sort() }
go
func (l Labels) LabelArray() LabelArray { labels := make(LabelArray, 0, len(l)) for _, v := range l { labels = append(labels, v) } return labels.Sort() }
[ "func", "(", "l", "Labels", ")", "LabelArray", "(", ")", "LabelArray", "{", "labels", ":=", "make", "(", "LabelArray", ",", "0", ",", "len", "(", "l", ")", ")", "\n", "for", "_", ",", "v", ":=", "range", "l", "{", "labels", "=", "append", "(", "labels", ",", "v", ")", "\n", "}", "\n", "return", "labels", ".", "Sort", "(", ")", "\n", "}" ]
// LabelArray returns the labels as label array, sorted by the key.
[ "LabelArray", "returns", "the", "labels", "as", "label", "array", "sorted", "by", "the", "key", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L470-L476
163,258
cilium/cilium
pkg/labels/labels.go
IsReserved
func (l Labels) IsReserved() bool { for _, lbl := range l { if lbl.Source == LabelSourceReserved { return true } } return false }
go
func (l Labels) IsReserved() bool { for _, lbl := range l { if lbl.Source == LabelSourceReserved { return true } } return false }
[ "func", "(", "l", "Labels", ")", "IsReserved", "(", ")", "bool", "{", "for", "_", ",", "lbl", ":=", "range", "l", "{", "if", "lbl", ".", "Source", "==", "LabelSourceReserved", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "false", "\n", "}" ]
// IsReserved returns true if any of the labels has a reserved source.
[ "IsReserved", "returns", "true", "if", "any", "of", "the", "labels", "has", "a", "reserved", "source", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/labels.go#L497-L504
163,259
cilium/cilium
pkg/serializer/func_queue.go
NewFunctionQueue
func NewFunctionQueue(queueSize uint) *FunctionQueue { fq := &FunctionQueue{ queue: make(chan queuedFunction, queueSize), stopCh: make(chan struct{}), } go fq.run() return fq }
go
func NewFunctionQueue(queueSize uint) *FunctionQueue { fq := &FunctionQueue{ queue: make(chan queuedFunction, queueSize), stopCh: make(chan struct{}), } go fq.run() return fq }
[ "func", "NewFunctionQueue", "(", "queueSize", "uint", ")", "*", "FunctionQueue", "{", "fq", ":=", "&", "FunctionQueue", "{", "queue", ":", "make", "(", "chan", "queuedFunction", ",", "queueSize", ")", ",", "stopCh", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n", "go", "fq", ".", "run", "(", ")", "\n", "return", "fq", "\n", "}" ]
// NewFunctionQueue returns a FunctionQueue that will be used to execute // functions in the same order they are enqueued.
[ "NewFunctionQueue", "returns", "a", "FunctionQueue", "that", "will", "be", "used", "to", "execute", "functions", "in", "the", "same", "order", "they", "are", "enqueued", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/serializer/func_queue.go#L45-L52
163,260
cilium/cilium
pkg/serializer/func_queue.go
run
func (fq *FunctionQueue) run() { for { select { case <-fq.stopCh: return case f := <-fq.queue: retries := 0 for { select { case <-fq.stopCh: return default: } retries++ if err := f.f(); err != nil { if !f.waitFunc(retries) { break } } else { break } } } } }
go
func (fq *FunctionQueue) run() { for { select { case <-fq.stopCh: return case f := <-fq.queue: retries := 0 for { select { case <-fq.stopCh: return default: } retries++ if err := f.f(); err != nil { if !f.waitFunc(retries) { break } } else { break } } } } }
[ "func", "(", "fq", "*", "FunctionQueue", ")", "run", "(", ")", "{", "for", "{", "select", "{", "case", "<-", "fq", ".", "stopCh", ":", "return", "\n", "case", "f", ":=", "<-", "fq", ".", "queue", ":", "retries", ":=", "0", "\n", "for", "{", "select", "{", "case", "<-", "fq", ".", "stopCh", ":", "return", "\n", "default", ":", "}", "\n", "retries", "++", "\n", "if", "err", ":=", "f", ".", "f", "(", ")", ";", "err", "!=", "nil", "{", "if", "!", "f", ".", "waitFunc", "(", "retries", ")", "{", "break", "\n", "}", "\n", "}", "else", "{", "break", "\n", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "}" ]
// run starts the FunctionQueue internal worker. It will be stopped once // `stopCh` is closed or receives a value.
[ "run", "starts", "the", "FunctionQueue", "internal", "worker", ".", "It", "will", "be", "stopped", "once", "stopCh", "is", "closed", "or", "receives", "a", "value", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/serializer/func_queue.go#L56-L80
163,261
cilium/cilium
pkg/serializer/func_queue.go
Wait
func (fq *FunctionQueue) Wait(ctx context.Context) error { select { case <-fq.stopCh: case <-ctx.Done(): } if err := ctx.Err(); err != nil { return fmt.Errorf("serializer %s", err) } return nil }
go
func (fq *FunctionQueue) Wait(ctx context.Context) error { select { case <-fq.stopCh: case <-ctx.Done(): } if err := ctx.Err(); err != nil { return fmt.Errorf("serializer %s", err) } return nil }
[ "func", "(", "fq", "*", "FunctionQueue", ")", "Wait", "(", "ctx", "context", ".", "Context", ")", "error", "{", "select", "{", "case", "<-", "fq", ".", "stopCh", ":", "case", "<-", "ctx", ".", "Done", "(", ")", ":", "}", "\n", "if", "err", ":=", "ctx", ".", "Err", "(", ")", ";", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Wait until the FunctionQueue is stopped, or the specified context deadline // expires. Returns the error from the context, or nil if the FunctionQueue // was completed before the context deadline.
[ "Wait", "until", "the", "FunctionQueue", "is", "stopped", "or", "the", "specified", "context", "deadline", "expires", ".", "Returns", "the", "error", "from", "the", "context", "or", "nil", "if", "the", "FunctionQueue", "was", "completed", "before", "the", "context", "deadline", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/serializer/func_queue.go#L92-L101
163,262
cilium/cilium
pkg/serializer/func_queue.go
Enqueue
func (fq *FunctionQueue) Enqueue(f func() error, waitFunc WaitFunc) { fq.queue <- queuedFunction{f: f, waitFunc: waitFunc} }
go
func (fq *FunctionQueue) Enqueue(f func() error, waitFunc WaitFunc) { fq.queue <- queuedFunction{f: f, waitFunc: waitFunc} }
[ "func", "(", "fq", "*", "FunctionQueue", ")", "Enqueue", "(", "f", "func", "(", ")", "error", ",", "waitFunc", "WaitFunc", ")", "{", "fq", ".", "queue", "<-", "queuedFunction", "{", "f", ":", "f", ",", "waitFunc", ":", "waitFunc", "}", "\n", "}" ]
// Enqueue enqueues the receiving function `f` to be executed by the function // queue. Depending on the size of the function queue and the amount // of functions queued, this function can block until the function queue // is ready to receive more requests. // If `f` returns an error, `waitFunc` will be executed and, depending on the // return value of `waitFunc`, `f` will be executed again or not. // The return value of `f` will not be logged and it's up to the caller to log // it properly.
[ "Enqueue", "enqueues", "the", "receiving", "function", "f", "to", "be", "executed", "by", "the", "function", "queue", ".", "Depending", "on", "the", "size", "of", "the", "function", "queue", "and", "the", "amount", "of", "functions", "queued", "this", "function", "can", "block", "until", "the", "function", "queue", "is", "ready", "to", "receive", "more", "requests", ".", "If", "f", "returns", "an", "error", "waitFunc", "will", "be", "executed", "and", "depending", "on", "the", "return", "value", "of", "waitFunc", "f", "will", "be", "executed", "again", "or", "not", ".", "The", "return", "value", "of", "f", "will", "not", "be", "logged", "and", "it", "s", "up", "to", "the", "caller", "to", "log", "it", "properly", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/serializer/func_queue.go#L111-L113
163,263
cilium/cilium
pkg/trigger/trigger.go
NewTrigger
func NewTrigger(p Parameters) (*Trigger, error) { if p.sleepInterval == 0 { p.sleepInterval = time.Second } if p.TriggerFunc == nil { return nil, fmt.Errorf("trigger function is nil") } if p.PrometheusMetrics && p.Name == "" { return nil, fmt.Errorf("trigger name must be provided when enabling metrics") } t := &Trigger{ params: p, wakeupChan: make(chan bool, 1), closeChan: make(chan struct{}, 1), foldedReasons: newReasonStack(), } // Guarantee that initial trigger has no delay if p.MinInterval > time.Duration(0) { t.lastTrigger = time.Now().Add(-1 * p.MinInterval) } if p.PrometheusMetrics { t.triggerReasons = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: "triggers", Name: p.Name + "_total", Help: "Total number of trigger invocations labelled by reason", }, []string{metricLabelReason}) if err := metrics.Register(t.triggerReasons); err != nil { return nil, fmt.Errorf("unable to register prometheus collector: %s", err) } t.triggerFolds = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: metrics.Namespace, Subsystem: "triggers", Name: p.Name + "_folds", Help: "Current level of trigger folds", }) if err := metrics.Register(t.triggerFolds); err != nil { metrics.Unregister(t.triggerReasons) return nil, fmt.Errorf("unable to register prometheus collector: %s", err) } t.callDurations = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: metrics.Namespace, Subsystem: "triggers", Name: p.Name + "_call_duration_seconds", Help: "Length of duration trigger used to execute", }, []string{"type"}) if err := metrics.Register(t.callDurations); err != nil { metrics.Unregister(t.triggerReasons) metrics.Unregister(t.triggerFolds) return nil, err } } go t.waiter() return t, nil }
go
func NewTrigger(p Parameters) (*Trigger, error) { if p.sleepInterval == 0 { p.sleepInterval = time.Second } if p.TriggerFunc == nil { return nil, fmt.Errorf("trigger function is nil") } if p.PrometheusMetrics && p.Name == "" { return nil, fmt.Errorf("trigger name must be provided when enabling metrics") } t := &Trigger{ params: p, wakeupChan: make(chan bool, 1), closeChan: make(chan struct{}, 1), foldedReasons: newReasonStack(), } // Guarantee that initial trigger has no delay if p.MinInterval > time.Duration(0) { t.lastTrigger = time.Now().Add(-1 * p.MinInterval) } if p.PrometheusMetrics { t.triggerReasons = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: metrics.Namespace, Subsystem: "triggers", Name: p.Name + "_total", Help: "Total number of trigger invocations labelled by reason", }, []string{metricLabelReason}) if err := metrics.Register(t.triggerReasons); err != nil { return nil, fmt.Errorf("unable to register prometheus collector: %s", err) } t.triggerFolds = prometheus.NewGauge(prometheus.GaugeOpts{ Namespace: metrics.Namespace, Subsystem: "triggers", Name: p.Name + "_folds", Help: "Current level of trigger folds", }) if err := metrics.Register(t.triggerFolds); err != nil { metrics.Unregister(t.triggerReasons) return nil, fmt.Errorf("unable to register prometheus collector: %s", err) } t.callDurations = prometheus.NewHistogramVec(prometheus.HistogramOpts{ Namespace: metrics.Namespace, Subsystem: "triggers", Name: p.Name + "_call_duration_seconds", Help: "Length of duration trigger used to execute", }, []string{"type"}) if err := metrics.Register(t.callDurations); err != nil { metrics.Unregister(t.triggerReasons) metrics.Unregister(t.triggerFolds) return nil, err } } go t.waiter() return t, nil }
[ "func", "NewTrigger", "(", "p", "Parameters", ")", "(", "*", "Trigger", ",", "error", ")", "{", "if", "p", ".", "sleepInterval", "==", "0", "{", "p", ".", "sleepInterval", "=", "time", ".", "Second", "\n", "}", "\n\n", "if", "p", ".", "TriggerFunc", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "if", "p", ".", "PrometheusMetrics", "&&", "p", ".", "Name", "==", "\"", "\"", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "t", ":=", "&", "Trigger", "{", "params", ":", "p", ",", "wakeupChan", ":", "make", "(", "chan", "bool", ",", "1", ")", ",", "closeChan", ":", "make", "(", "chan", "struct", "{", "}", ",", "1", ")", ",", "foldedReasons", ":", "newReasonStack", "(", ")", ",", "}", "\n\n", "// Guarantee that initial trigger has no delay", "if", "p", ".", "MinInterval", ">", "time", ".", "Duration", "(", "0", ")", "{", "t", ".", "lastTrigger", "=", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "1", "*", "p", ".", "MinInterval", ")", "\n", "}", "\n\n", "if", "p", ".", "PrometheusMetrics", "{", "t", ".", "triggerReasons", "=", "prometheus", ".", "NewCounterVec", "(", "prometheus", ".", "CounterOpts", "{", "Namespace", ":", "metrics", ".", "Namespace", ",", "Subsystem", ":", "\"", "\"", ",", "Name", ":", "p", ".", "Name", "+", "\"", "\"", ",", "Help", ":", "\"", "\"", ",", "}", ",", "[", "]", "string", "{", "metricLabelReason", "}", ")", "\n\n", "if", "err", ":=", "metrics", ".", "Register", "(", "t", ".", "triggerReasons", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "t", ".", "triggerFolds", "=", "prometheus", ".", "NewGauge", "(", "prometheus", ".", "GaugeOpts", "{", "Namespace", ":", "metrics", ".", "Namespace", ",", "Subsystem", ":", "\"", "\"", ",", "Name", ":", "p", ".", "Name", "+", "\"", "\"", ",", "Help", ":", "\"", "\"", ",", "}", ")", "\n\n", "if", "err", ":=", "metrics", ".", "Register", "(", "t", ".", "triggerFolds", ")", ";", "err", "!=", "nil", "{", "metrics", ".", "Unregister", "(", "t", ".", "triggerReasons", ")", "\n", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "err", ")", "\n", "}", "\n\n", "t", ".", "callDurations", "=", "prometheus", ".", "NewHistogramVec", "(", "prometheus", ".", "HistogramOpts", "{", "Namespace", ":", "metrics", ".", "Namespace", ",", "Subsystem", ":", "\"", "\"", ",", "Name", ":", "p", ".", "Name", "+", "\"", "\"", ",", "Help", ":", "\"", "\"", ",", "}", ",", "[", "]", "string", "{", "\"", "\"", "}", ")", "\n\n", "if", "err", ":=", "metrics", ".", "Register", "(", "t", ".", "callDurations", ")", ";", "err", "!=", "nil", "{", "metrics", ".", "Unregister", "(", "t", ".", "triggerReasons", ")", "\n", "metrics", ".", "Unregister", "(", "t", ".", "triggerFolds", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "go", "t", ".", "waiter", "(", ")", "\n\n", "return", "t", ",", "nil", "\n", "}" ]
// NewTrigger returns a new trigger based on the provided parameters
[ "NewTrigger", "returns", "a", "new", "trigger", "based", "on", "the", "provided", "parameters" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/trigger/trigger.go#L107-L173
163,264
cilium/cilium
pkg/trigger/trigger.go
needsDelay
func (t *Trigger) needsDelay() (bool, time.Duration) { if t.params.MinInterval == time.Duration(0) { return false, 0 } sleepTime := time.Since(t.lastTrigger.Add(t.params.MinInterval)) return sleepTime < 0, sleepTime * -1 }
go
func (t *Trigger) needsDelay() (bool, time.Duration) { if t.params.MinInterval == time.Duration(0) { return false, 0 } sleepTime := time.Since(t.lastTrigger.Add(t.params.MinInterval)) return sleepTime < 0, sleepTime * -1 }
[ "func", "(", "t", "*", "Trigger", ")", "needsDelay", "(", ")", "(", "bool", ",", "time", ".", "Duration", ")", "{", "if", "t", ".", "params", ".", "MinInterval", "==", "time", ".", "Duration", "(", "0", ")", "{", "return", "false", ",", "0", "\n", "}", "\n\n", "sleepTime", ":=", "time", ".", "Since", "(", "t", ".", "lastTrigger", ".", "Add", "(", "t", ".", "params", ".", "MinInterval", ")", ")", "\n", "return", "sleepTime", "<", "0", ",", "sleepTime", "*", "-", "1", "\n", "}" ]
// needsDelay returns whether and how long of a delay is required to fullfil // MinInterval
[ "needsDelay", "returns", "whether", "and", "how", "long", "of", "a", "delay", "is", "required", "to", "fullfil", "MinInterval" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/trigger/trigger.go#L177-L184
163,265
cilium/cilium
pkg/trigger/trigger.go
Shutdown
func (t *Trigger) Shutdown() { close(t.closeChan) if t.params.PrometheusMetrics { metrics.Unregister(t.triggerReasons) metrics.Unregister(t.triggerFolds) metrics.Unregister(t.callDurations) } }
go
func (t *Trigger) Shutdown() { close(t.closeChan) if t.params.PrometheusMetrics { metrics.Unregister(t.triggerReasons) metrics.Unregister(t.triggerFolds) metrics.Unregister(t.callDurations) } }
[ "func", "(", "t", "*", "Trigger", ")", "Shutdown", "(", ")", "{", "close", "(", "t", ".", "closeChan", ")", "\n", "if", "t", ".", "params", ".", "PrometheusMetrics", "{", "metrics", ".", "Unregister", "(", "t", ".", "triggerReasons", ")", "\n", "metrics", ".", "Unregister", "(", "t", ".", "triggerFolds", ")", "\n", "metrics", ".", "Unregister", "(", "t", ".", "callDurations", ")", "\n", "}", "\n", "}" ]
// Shutdown stops the trigger mechanism
[ "Shutdown", "stops", "the", "trigger", "mechanism" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/trigger/trigger.go#L219-L226
163,266
cilium/cilium
pkg/k8s/client/informers/externalversions/cilium.io/interface.go
V2
func (g *group) V2() v2.Interface { return v2.New(g.factory, g.namespace, g.tweakListOptions) }
go
func (g *group) V2() v2.Interface { return v2.New(g.factory, g.namespace, g.tweakListOptions) }
[ "func", "(", "g", "*", "group", ")", "V2", "(", ")", "v2", ".", "Interface", "{", "return", "v2", ".", "New", "(", "g", ".", "factory", ",", "g", ".", "namespace", ",", "g", ".", "tweakListOptions", ")", "\n", "}" ]
// V2 returns a new v2.Interface.
[ "V2", "returns", "a", "new", "v2", ".", "Interface", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/k8s/client/informers/externalversions/cilium.io/interface.go#L42-L44
163,267
cilium/cilium
api/v1/server/restapi/service/put_service_id.go
NewPutServiceID
func NewPutServiceID(ctx *middleware.Context, handler PutServiceIDHandler) *PutServiceID { return &PutServiceID{Context: ctx, Handler: handler} }
go
func NewPutServiceID(ctx *middleware.Context, handler PutServiceIDHandler) *PutServiceID { return &PutServiceID{Context: ctx, Handler: handler} }
[ "func", "NewPutServiceID", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "PutServiceIDHandler", ")", "*", "PutServiceID", "{", "return", "&", "PutServiceID", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewPutServiceID creates a new http.Handler for the put service ID operation
[ "NewPutServiceID", "creates", "a", "new", "http", ".", "Handler", "for", "the", "put", "service", "ID", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/service/put_service_id.go#L28-L30
163,268
cilium/cilium
pkg/envoy/xds/server.go
NewServer
func NewServer(resourceTypes map[string]*ResourceTypeConfiguration, resourceAccessTimeout time.Duration) *Server { watchers := make(map[string]*ResourceWatcher, len(resourceTypes)) ackObservers := make(map[string]ResourceVersionAckObserver, len(resourceTypes)) for typeURL, resType := range resourceTypes { w := NewResourceWatcher(typeURL, resType.Source, resourceAccessTimeout) resType.Source.AddResourceVersionObserver(w) watchers[typeURL] = w if resType.AckObserver != nil { ackObservers[typeURL] = resType.AckObserver } } // TODO: Unregister the watchers when stopping the server. return &Server{watchers: watchers, ackObservers: ackObservers} }
go
func NewServer(resourceTypes map[string]*ResourceTypeConfiguration, resourceAccessTimeout time.Duration) *Server { watchers := make(map[string]*ResourceWatcher, len(resourceTypes)) ackObservers := make(map[string]ResourceVersionAckObserver, len(resourceTypes)) for typeURL, resType := range resourceTypes { w := NewResourceWatcher(typeURL, resType.Source, resourceAccessTimeout) resType.Source.AddResourceVersionObserver(w) watchers[typeURL] = w if resType.AckObserver != nil { ackObservers[typeURL] = resType.AckObserver } } // TODO: Unregister the watchers when stopping the server. return &Server{watchers: watchers, ackObservers: ackObservers} }
[ "func", "NewServer", "(", "resourceTypes", "map", "[", "string", "]", "*", "ResourceTypeConfiguration", ",", "resourceAccessTimeout", "time", ".", "Duration", ")", "*", "Server", "{", "watchers", ":=", "make", "(", "map", "[", "string", "]", "*", "ResourceWatcher", ",", "len", "(", "resourceTypes", ")", ")", "\n", "ackObservers", ":=", "make", "(", "map", "[", "string", "]", "ResourceVersionAckObserver", ",", "len", "(", "resourceTypes", ")", ")", "\n", "for", "typeURL", ",", "resType", ":=", "range", "resourceTypes", "{", "w", ":=", "NewResourceWatcher", "(", "typeURL", ",", "resType", ".", "Source", ",", "resourceAccessTimeout", ")", "\n", "resType", ".", "Source", ".", "AddResourceVersionObserver", "(", "w", ")", "\n", "watchers", "[", "typeURL", "]", "=", "w", "\n\n", "if", "resType", ".", "AckObserver", "!=", "nil", "{", "ackObservers", "[", "typeURL", "]", "=", "resType", ".", "AckObserver", "\n", "}", "\n", "}", "\n\n", "// TODO: Unregister the watchers when stopping the server.", "return", "&", "Server", "{", "watchers", ":", "watchers", ",", "ackObservers", ":", "ackObservers", "}", "\n", "}" ]
// NewServer creates an xDS gRPC stream handler using the given resource // sources. // types maps each supported resource type URL to its corresponding resource // source and ACK observer.
[ "NewServer", "creates", "an", "xDS", "gRPC", "stream", "handler", "using", "the", "given", "resource", "sources", ".", "types", "maps", "each", "supported", "resource", "type", "URL", "to", "its", "corresponding", "resource", "source", "and", "ACK", "observer", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/server.go#L91-L108
163,269
cilium/cilium
pkg/envoy/xds/server.go
HandleRequestStream
func (s *Server) HandleRequestStream(ctx context.Context, stream Stream, defaultTypeURL string) error { // increment stream count streamID := atomic.AddUint64(&s.lastStreamID, 1) streamLog := log.WithField(logfields.XDSStreamID, streamID) reqCh := make(chan *envoy_api_v2.DiscoveryRequest) stopRecv := make(chan struct{}) defer close(stopRecv) go func() { defer close(reqCh) for { req, err := stream.Recv() if err != nil { if err == io.EOF { streamLog.Debug("xDS stream closed") } else { streamLog.WithError(err).Error("error while receiving request from xDS stream") } return } if req == nil { streamLog.Error("received nil request from xDS stream; stopping xDS stream handling") return } if req.GetTypeUrl() == "" { req.TypeUrl = defaultTypeURL } streamLog.WithFields(getXDSRequestFields(req)).Debug("received request from xDS stream") select { case <-stopRecv: streamLog.Debug("stopping xDS stream handling") return case reqCh <- req: } } }() return s.processRequestStream(ctx, streamLog, stream, reqCh, defaultTypeURL) }
go
func (s *Server) HandleRequestStream(ctx context.Context, stream Stream, defaultTypeURL string) error { // increment stream count streamID := atomic.AddUint64(&s.lastStreamID, 1) streamLog := log.WithField(logfields.XDSStreamID, streamID) reqCh := make(chan *envoy_api_v2.DiscoveryRequest) stopRecv := make(chan struct{}) defer close(stopRecv) go func() { defer close(reqCh) for { req, err := stream.Recv() if err != nil { if err == io.EOF { streamLog.Debug("xDS stream closed") } else { streamLog.WithError(err).Error("error while receiving request from xDS stream") } return } if req == nil { streamLog.Error("received nil request from xDS stream; stopping xDS stream handling") return } if req.GetTypeUrl() == "" { req.TypeUrl = defaultTypeURL } streamLog.WithFields(getXDSRequestFields(req)).Debug("received request from xDS stream") select { case <-stopRecv: streamLog.Debug("stopping xDS stream handling") return case reqCh <- req: } } }() return s.processRequestStream(ctx, streamLog, stream, reqCh, defaultTypeURL) }
[ "func", "(", "s", "*", "Server", ")", "HandleRequestStream", "(", "ctx", "context", ".", "Context", ",", "stream", "Stream", ",", "defaultTypeURL", "string", ")", "error", "{", "// increment stream count", "streamID", ":=", "atomic", ".", "AddUint64", "(", "&", "s", ".", "lastStreamID", ",", "1", ")", "\n\n", "streamLog", ":=", "log", ".", "WithField", "(", "logfields", ".", "XDSStreamID", ",", "streamID", ")", "\n\n", "reqCh", ":=", "make", "(", "chan", "*", "envoy_api_v2", ".", "DiscoveryRequest", ")", "\n\n", "stopRecv", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "defer", "close", "(", "stopRecv", ")", "\n\n", "go", "func", "(", ")", "{", "defer", "close", "(", "reqCh", ")", "\n", "for", "{", "req", ",", "err", ":=", "stream", ".", "Recv", "(", ")", "\n", "if", "err", "!=", "nil", "{", "if", "err", "==", "io", ".", "EOF", "{", "streamLog", ".", "Debug", "(", "\"", "\"", ")", "\n", "}", "else", "{", "streamLog", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "}", "\n", "return", "\n", "}", "\n", "if", "req", "==", "nil", "{", "streamLog", ".", "Error", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "if", "req", ".", "GetTypeUrl", "(", ")", "==", "\"", "\"", "{", "req", ".", "TypeUrl", "=", "defaultTypeURL", "\n", "}", "\n", "streamLog", ".", "WithFields", "(", "getXDSRequestFields", "(", "req", ")", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "select", "{", "case", "<-", "stopRecv", ":", "streamLog", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "\n", "case", "reqCh", "<-", "req", ":", "}", "\n", "}", "\n", "}", "(", ")", "\n\n", "return", "s", ".", "processRequestStream", "(", "ctx", ",", "streamLog", ",", "stream", ",", "reqCh", ",", "defaultTypeURL", ")", "\n", "}" ]
// HandleRequestStream receives and processes the requests from an xDS stream.
[ "HandleRequestStream", "receives", "and", "processes", "the", "requests", "from", "an", "xDS", "stream", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/envoy/xds/server.go#L120-L161
163,270
cilium/cilium
pkg/eventqueue/eventqueue.go
NewEventQueueBuffered
func NewEventQueueBuffered(name string, numBufferedEvents int) *EventQueue { log.WithFields(logrus.Fields{ "name": name, "numBufferedEvents": numBufferedEvents, }).Debug("creating new EventQueue") return &EventQueue{ name: name, // Up to numBufferedEvents can be Enqueued until Enqueueing blocks. events: make(chan *Event, numBufferedEvents), close: make(chan struct{}), drain: make(chan struct{}), } }
go
func NewEventQueueBuffered(name string, numBufferedEvents int) *EventQueue { log.WithFields(logrus.Fields{ "name": name, "numBufferedEvents": numBufferedEvents, }).Debug("creating new EventQueue") return &EventQueue{ name: name, // Up to numBufferedEvents can be Enqueued until Enqueueing blocks. events: make(chan *Event, numBufferedEvents), close: make(chan struct{}), drain: make(chan struct{}), } }
[ "func", "NewEventQueueBuffered", "(", "name", "string", ",", "numBufferedEvents", "int", ")", "*", "EventQueue", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "\"", "\"", ":", "name", ",", "\"", "\"", ":", "numBufferedEvents", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "&", "EventQueue", "{", "name", ":", "name", ",", "// Up to numBufferedEvents can be Enqueued until Enqueueing blocks.", "events", ":", "make", "(", "chan", "*", "Event", ",", "numBufferedEvents", ")", ",", "close", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "drain", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "}", "\n\n", "}" ]
// NewEventQueueBuffered returns an EventQueue with a capacity of, // numBufferedEvents at a time, and all other needed fields initialized.
[ "NewEventQueueBuffered", "returns", "an", "EventQueue", "with", "a", "capacity", "of", "numBufferedEvents", "at", "a", "time", "and", "all", "other", "needed", "fields", "initialized", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/eventqueue/eventqueue.go#L87-L100
163,271
cilium/cilium
pkg/eventqueue/eventqueue.go
NewEvent
func NewEvent(meta EventHandler) *Event { return &Event{ Metadata: meta, eventResults: make(chan interface{}, 1), cancelled: make(chan struct{}), stats: eventStatistics{}, } }
go
func NewEvent(meta EventHandler) *Event { return &Event{ Metadata: meta, eventResults: make(chan interface{}, 1), cancelled: make(chan struct{}), stats: eventStatistics{}, } }
[ "func", "NewEvent", "(", "meta", "EventHandler", ")", "*", "Event", "{", "return", "&", "Event", "{", "Metadata", ":", "meta", ",", "eventResults", ":", "make", "(", "chan", "interface", "{", "}", ",", "1", ")", ",", "cancelled", ":", "make", "(", "chan", "struct", "{", "}", ")", ",", "stats", ":", "eventStatistics", "{", "}", ",", "}", "\n", "}" ]
// NewEvent returns an Event with all fields initialized.
[ "NewEvent", "returns", "an", "Event", "with", "all", "fields", "initialized", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/eventqueue/eventqueue.go#L142-L149
163,272
cilium/cilium
pkg/eventqueue/eventqueue.go
Enqueue
func (q *EventQueue) Enqueue(ev *Event) <-chan interface{} { if q.notSafeToAccess() || ev == nil { return nil } // Track that event has been Enqueued. q.closeWaitGroup.Add(1) defer q.closeWaitGroup.Done() select { // The event should be drained from the queue (e.g., it should not be // processed). case <-q.drain: // Closed eventResults channel signifies cancellation. close(ev.cancelled) close(ev.eventResults) return ev.eventResults default: // The events channel may be closed even if an event has been pushed // onto the events channel, as events are consumed off of the events // channel asynchronously! If the EventQueue is closed before this // event is processed, then it will be cancelled. ev.stats.waitEnqueue.Start() q.events <- ev ev.stats.waitEnqueue.End(true) ev.stats.waitConsumeOffQueue.Start() return ev.eventResults } }
go
func (q *EventQueue) Enqueue(ev *Event) <-chan interface{} { if q.notSafeToAccess() || ev == nil { return nil } // Track that event has been Enqueued. q.closeWaitGroup.Add(1) defer q.closeWaitGroup.Done() select { // The event should be drained from the queue (e.g., it should not be // processed). case <-q.drain: // Closed eventResults channel signifies cancellation. close(ev.cancelled) close(ev.eventResults) return ev.eventResults default: // The events channel may be closed even if an event has been pushed // onto the events channel, as events are consumed off of the events // channel asynchronously! If the EventQueue is closed before this // event is processed, then it will be cancelled. ev.stats.waitEnqueue.Start() q.events <- ev ev.stats.waitEnqueue.End(true) ev.stats.waitConsumeOffQueue.Start() return ev.eventResults } }
[ "func", "(", "q", "*", "EventQueue", ")", "Enqueue", "(", "ev", "*", "Event", ")", "<-", "chan", "interface", "{", "}", "{", "if", "q", ".", "notSafeToAccess", "(", ")", "||", "ev", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "// Track that event has been Enqueued.", "q", ".", "closeWaitGroup", ".", "Add", "(", "1", ")", "\n", "defer", "q", ".", "closeWaitGroup", ".", "Done", "(", ")", "\n\n", "select", "{", "// The event should be drained from the queue (e.g., it should not be", "// processed).", "case", "<-", "q", ".", "drain", ":", "// Closed eventResults channel signifies cancellation.", "close", "(", "ev", ".", "cancelled", ")", "\n", "close", "(", "ev", ".", "eventResults", ")", "\n\n", "return", "ev", ".", "eventResults", "\n", "default", ":", "// The events channel may be closed even if an event has been pushed", "// onto the events channel, as events are consumed off of the events", "// channel asynchronously! If the EventQueue is closed before this", "// event is processed, then it will be cancelled.", "ev", ".", "stats", ".", "waitEnqueue", ".", "Start", "(", ")", "\n", "q", ".", "events", "<-", "ev", "\n", "ev", ".", "stats", ".", "waitEnqueue", ".", "End", "(", "true", ")", "\n", "ev", ".", "stats", ".", "waitConsumeOffQueue", ".", "Start", "(", ")", "\n", "return", "ev", ".", "eventResults", "\n", "}", "\n", "}" ]
// Enqueue pushes the given event onto the EventQueue. If the queue has been // stopped, the Event will not be enqueued, and its cancel channel will be // closed, indicating that the Event was not ran. This function may block if // the queue is at its capacity for events.
[ "Enqueue", "pushes", "the", "given", "event", "onto", "the", "EventQueue", ".", "If", "the", "queue", "has", "been", "stopped", "the", "Event", "will", "not", "be", "enqueued", "and", "its", "cancel", "channel", "will", "be", "closed", "indicating", "that", "the", "Event", "was", "not", "ran", ".", "This", "function", "may", "block", "if", "the", "queue", "is", "at", "its", "capacity", "for", "events", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/eventqueue/eventqueue.go#L169-L200
163,273
cilium/cilium
pkg/eventqueue/eventqueue.go
Stop
func (q *EventQueue) Stop() { if q.notSafeToAccess() { return } q.closeOnce.Do(func() { q.getLogger().Debug("stopping EventQueue") // Any event that is sent to the queue at this point will be cancelled // immediately in Enqueue(). close(q.drain) // Wait for all events which have been queued to be processed. If // a large amount of events are continuously enqueued at this point, // then this may block. But, in most scenarios, this should exit // fairly quickly. q.closeWaitGroup.Wait() // Signal that the queue has been drained. close(q.close) // This will cause Run() to receive a nil event. close(q.events) }) }
go
func (q *EventQueue) Stop() { if q.notSafeToAccess() { return } q.closeOnce.Do(func() { q.getLogger().Debug("stopping EventQueue") // Any event that is sent to the queue at this point will be cancelled // immediately in Enqueue(). close(q.drain) // Wait for all events which have been queued to be processed. If // a large amount of events are continuously enqueued at this point, // then this may block. But, in most scenarios, this should exit // fairly quickly. q.closeWaitGroup.Wait() // Signal that the queue has been drained. close(q.close) // This will cause Run() to receive a nil event. close(q.events) }) }
[ "func", "(", "q", "*", "EventQueue", ")", "Stop", "(", ")", "{", "if", "q", ".", "notSafeToAccess", "(", ")", "{", "return", "\n", "}", "\n\n", "q", ".", "closeOnce", ".", "Do", "(", "func", "(", ")", "{", "q", ".", "getLogger", "(", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "// Any event that is sent to the queue at this point will be cancelled", "// immediately in Enqueue().", "close", "(", "q", ".", "drain", ")", "\n\n", "// Wait for all events which have been queued to be processed. If", "// a large amount of events are continuously enqueued at this point,", "// then this may block. But, in most scenarios, this should exit", "// fairly quickly.", "q", ".", "closeWaitGroup", ".", "Wait", "(", ")", "\n\n", "// Signal that the queue has been drained.", "close", "(", "q", ".", "close", ")", "\n\n", "// This will cause Run() to receive a nil event.", "close", "(", "q", ".", "events", ")", "\n\n", "}", ")", "\n", "}" ]
// Stop stops any further events from being processed by the EventQueue. Any // event which is currently being processed by the EventQueue will continue to // run. All other events waiting to be processed, and all events that may be // enqueued will not be processed by the event queue; they will be cancelled. // If the queue has already been stopped, this is a no-op.
[ "Stop", "stops", "any", "further", "events", "from", "being", "processed", "by", "the", "EventQueue", ".", "Any", "event", "which", "is", "currently", "being", "processed", "by", "the", "EventQueue", "will", "continue", "to", "run", ".", "All", "other", "events", "waiting", "to", "be", "processed", "and", "all", "events", "that", "may", "be", "enqueued", "will", "not", "be", "processed", "by", "the", "event", "queue", ";", "they", "will", "be", "cancelled", ".", "If", "the", "queue", "has", "already", "been", "stopped", "this", "is", "a", "no", "-", "op", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/eventqueue/eventqueue.go#L257-L281
163,274
cilium/cilium
pkg/policy/selectorcache.go
newSelectorCache
func newSelectorCache() *SelectorCache { return &SelectorCache{ idCache: cache.GetIdentityCache(), selectors: make(map[string]identitySelector), } }
go
func newSelectorCache() *SelectorCache { return &SelectorCache{ idCache: cache.GetIdentityCache(), selectors: make(map[string]identitySelector), } }
[ "func", "newSelectorCache", "(", ")", "*", "SelectorCache", "{", "return", "&", "SelectorCache", "{", "idCache", ":", "cache", ".", "GetIdentityCache", "(", ")", ",", "selectors", ":", "make", "(", "map", "[", "string", "]", "identitySelector", ")", ",", "}", "\n", "}" ]
// newSelectorCache creates a new SelectorCache.
[ "newSelectorCache", "creates", "a", "new", "SelectorCache", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/selectorcache.go#L105-L110
163,275
cilium/cilium
pkg/policy/selectorcache.go
updateSelections
func (l *labelIdentitySelector) updateSelections() { selections := make([]identity.NumericIdentity, len(l.cachedSelections)) i := 0 for nid := range l.cachedSelections { selections[i] = nid i++ } // Sort the numeric identities so that the map iteration order // does not matter. This makes testing easier, but may help // identifying changes easier also otherwise. sort.Slice(selections, func(i, j int) bool { return selections[i] < selections[j] }) l.setSelections(&selections) }
go
func (l *labelIdentitySelector) updateSelections() { selections := make([]identity.NumericIdentity, len(l.cachedSelections)) i := 0 for nid := range l.cachedSelections { selections[i] = nid i++ } // Sort the numeric identities so that the map iteration order // does not matter. This makes testing easier, but may help // identifying changes easier also otherwise. sort.Slice(selections, func(i, j int) bool { return selections[i] < selections[j] }) l.setSelections(&selections) }
[ "func", "(", "l", "*", "labelIdentitySelector", ")", "updateSelections", "(", ")", "{", "selections", ":=", "make", "(", "[", "]", "identity", ".", "NumericIdentity", ",", "len", "(", "l", ".", "cachedSelections", ")", ")", "\n", "i", ":=", "0", "\n", "for", "nid", ":=", "range", "l", ".", "cachedSelections", "{", "selections", "[", "i", "]", "=", "nid", "\n", "i", "++", "\n", "}", "\n", "// Sort the numeric identities so that the map iteration order", "// does not matter. This makes testing easier, but may help", "// identifying changes easier also otherwise.", "sort", ".", "Slice", "(", "selections", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "selections", "[", "i", "]", "<", "selections", "[", "j", "]", "\n", "}", ")", "\n", "l", ".", "setSelections", "(", "&", "selections", ")", "\n", "}" ]
// updateSelections updates the immutable slice representation of the // cached selections after the cached selections have been changed. // // lock must be held
[ "updateSelections", "updates", "the", "immutable", "slice", "representation", "of", "the", "cached", "selections", "after", "the", "cached", "selections", "have", "been", "changed", ".", "lock", "must", "be", "held" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/selectorcache.go#L186-L200
163,276
cilium/cilium
pkg/policy/selectorcache.go
AddIdentitySelector
func (sc *SelectorCache) AddIdentitySelector(user CachedSelectionUser, selector api.EndpointSelector) (cachedSelector CachedSelector, added bool) { // The key returned here may be different for equivalent // labelselectors, if the selector's requirements are stored // in different orders. When this happens we'll be tracking // essentially two copies of the same selector. key := selector.LabelSelector.String() sc.mutex.Lock() defer sc.mutex.Unlock() idSel, exists := sc.selectors[key] if exists { return idSel, idSel.addUser(user) } // Selectors are never modified once a rule is placed in the policy repository, // so no need to copy. // TODO: FQDNSelector newIDSel := &labelIdentitySelector{ key: key, users: make(map[CachedSelectionUser]struct{}), selector: selector, cachedSelections: make(map[identity.NumericIdentity]struct{}), } // Add the initial user newIDSel.users[user] = struct{}{} // Find all matching identities from the identity cache. for numericID, lbls := range sc.idCache { if selector.Matches(lbls) { newIDSel.cachedSelections[numericID] = struct{}{} } } // Create the immutable slice representation of the selected // numeric identities newIDSel.updateSelections() // Note: No notifications are sent for the existing // identities. Caller must use GetSelections() to get the // current selections after adding a selector. This way the // behavior is the same between the two cases here (selector // is already cached, or is a new one). sc.selectors[key] = newIDSel return newIDSel, true }
go
func (sc *SelectorCache) AddIdentitySelector(user CachedSelectionUser, selector api.EndpointSelector) (cachedSelector CachedSelector, added bool) { // The key returned here may be different for equivalent // labelselectors, if the selector's requirements are stored // in different orders. When this happens we'll be tracking // essentially two copies of the same selector. key := selector.LabelSelector.String() sc.mutex.Lock() defer sc.mutex.Unlock() idSel, exists := sc.selectors[key] if exists { return idSel, idSel.addUser(user) } // Selectors are never modified once a rule is placed in the policy repository, // so no need to copy. // TODO: FQDNSelector newIDSel := &labelIdentitySelector{ key: key, users: make(map[CachedSelectionUser]struct{}), selector: selector, cachedSelections: make(map[identity.NumericIdentity]struct{}), } // Add the initial user newIDSel.users[user] = struct{}{} // Find all matching identities from the identity cache. for numericID, lbls := range sc.idCache { if selector.Matches(lbls) { newIDSel.cachedSelections[numericID] = struct{}{} } } // Create the immutable slice representation of the selected // numeric identities newIDSel.updateSelections() // Note: No notifications are sent for the existing // identities. Caller must use GetSelections() to get the // current selections after adding a selector. This way the // behavior is the same between the two cases here (selector // is already cached, or is a new one). sc.selectors[key] = newIDSel return newIDSel, true }
[ "func", "(", "sc", "*", "SelectorCache", ")", "AddIdentitySelector", "(", "user", "CachedSelectionUser", ",", "selector", "api", ".", "EndpointSelector", ")", "(", "cachedSelector", "CachedSelector", ",", "added", "bool", ")", "{", "// The key returned here may be different for equivalent", "// labelselectors, if the selector's requirements are stored", "// in different orders. When this happens we'll be tracking", "// essentially two copies of the same selector.", "key", ":=", "selector", ".", "LabelSelector", ".", "String", "(", ")", "\n", "sc", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "sc", ".", "mutex", ".", "Unlock", "(", ")", "\n", "idSel", ",", "exists", ":=", "sc", ".", "selectors", "[", "key", "]", "\n", "if", "exists", "{", "return", "idSel", ",", "idSel", ".", "addUser", "(", "user", ")", "\n", "}", "\n\n", "// Selectors are never modified once a rule is placed in the policy repository,", "// so no need to copy.", "// TODO: FQDNSelector", "newIDSel", ":=", "&", "labelIdentitySelector", "{", "key", ":", "key", ",", "users", ":", "make", "(", "map", "[", "CachedSelectionUser", "]", "struct", "{", "}", ")", ",", "selector", ":", "selector", ",", "cachedSelections", ":", "make", "(", "map", "[", "identity", ".", "NumericIdentity", "]", "struct", "{", "}", ")", ",", "}", "\n\n", "// Add the initial user", "newIDSel", ".", "users", "[", "user", "]", "=", "struct", "{", "}", "{", "}", "\n\n", "// Find all matching identities from the identity cache.", "for", "numericID", ",", "lbls", ":=", "range", "sc", ".", "idCache", "{", "if", "selector", ".", "Matches", "(", "lbls", ")", "{", "newIDSel", ".", "cachedSelections", "[", "numericID", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n", "// Create the immutable slice representation of the selected", "// numeric identities", "newIDSel", ".", "updateSelections", "(", ")", "\n\n", "// Note: No notifications are sent for the existing", "// identities. Caller must use GetSelections() to get the", "// current selections after adding a selector. This way the", "// behavior is the same between the two cases here (selector", "// is already cached, or is a new one).", "sc", ".", "selectors", "[", "key", "]", "=", "newIDSel", "\n", "return", "newIDSel", ",", "true", "\n", "}" ]
// AddIdentitySelector adds the given api.EndpointSelector in to the // selector cache. If an identical EndpointSelector has already been // cached, the corresponding CachedSelector is returned, otherwise one // is created and added to the cache.
[ "AddIdentitySelector", "adds", "the", "given", "api", ".", "EndpointSelector", "in", "to", "the", "selector", "cache", ".", "If", "an", "identical", "EndpointSelector", "has", "already", "been", "cached", "the", "corresponding", "CachedSelector", "is", "returned", "otherwise", "one", "is", "created", "and", "added", "to", "the", "cache", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/selectorcache.go#L211-L257
163,277
cilium/cilium
pkg/policy/selectorcache.go
RemoveIdentitySelector
func (sc *SelectorCache) RemoveIdentitySelector(user CachedSelectionUser, selector CachedSelector) { key := selector.String() sc.mutex.Lock() defer sc.mutex.Unlock() idSel, exists := sc.selectors[key] if exists { if idSel.removeUser(user) { delete(sc.selectors, key) } } }
go
func (sc *SelectorCache) RemoveIdentitySelector(user CachedSelectionUser, selector CachedSelector) { key := selector.String() sc.mutex.Lock() defer sc.mutex.Unlock() idSel, exists := sc.selectors[key] if exists { if idSel.removeUser(user) { delete(sc.selectors, key) } } }
[ "func", "(", "sc", "*", "SelectorCache", ")", "RemoveIdentitySelector", "(", "user", "CachedSelectionUser", ",", "selector", "CachedSelector", ")", "{", "key", ":=", "selector", ".", "String", "(", ")", "\n", "sc", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "sc", ".", "mutex", ".", "Unlock", "(", ")", "\n", "idSel", ",", "exists", ":=", "sc", ".", "selectors", "[", "key", "]", "\n", "if", "exists", "{", "if", "idSel", ".", "removeUser", "(", "user", ")", "{", "delete", "(", "sc", ".", "selectors", ",", "key", ")", "\n", "}", "\n", "}", "\n", "}" ]
// RemoveIdentitySelector removes CachedSelector for the user.
[ "RemoveIdentitySelector", "removes", "CachedSelector", "for", "the", "user", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/selectorcache.go#L260-L270
163,278
cilium/cilium
pkg/policy/selectorcache.go
UpdateIdentities
func (sc *SelectorCache) UpdateIdentities(added, deleted cache.IdentityCache) { sc.mutex.Lock() defer sc.mutex.Unlock() // Update idCache so that newly added selectors get // prepopulated with all matching numeric identities. for numericID := range deleted { if _, exists := sc.idCache[numericID]; exists { delete(sc.idCache, numericID) } else { log.WithFields(logrus.Fields{logfields.Identity: numericID}).Warning("UpdateIdentities: Deleting a non-existing identity") } } for numericID, lbls := range added { if _, exists := sc.idCache[numericID]; exists { log.WithFields(logrus.Fields{logfields.Identity: numericID}).Warning("UpdateIdentities: Adding an existing identity") } sc.idCache[numericID] = lbls } // Iterate through all locally used identity selectors and // update the cached numeric identities as required. for _, sel := range sc.selectors { var adds, dels []identity.NumericIdentity switch idSel := sel.(type) { case *labelIdentitySelector: for numericID := range deleted { if _, exists := idSel.cachedSelections[numericID]; exists { dels = append(dels, numericID) delete(idSel.cachedSelections, numericID) } } for numericID, lbls := range added { if _, exists := idSel.cachedSelections[numericID]; !exists { if idSel.selector.Matches(lbls) { adds = append(adds, numericID) idSel.cachedSelections[numericID] = struct{}{} } } } if len(dels)+len(adds) > 0 { idSel.updateSelections() idSel.notifyUsers(adds, dels) } case *fqdnSelector: // TODO } } }
go
func (sc *SelectorCache) UpdateIdentities(added, deleted cache.IdentityCache) { sc.mutex.Lock() defer sc.mutex.Unlock() // Update idCache so that newly added selectors get // prepopulated with all matching numeric identities. for numericID := range deleted { if _, exists := sc.idCache[numericID]; exists { delete(sc.idCache, numericID) } else { log.WithFields(logrus.Fields{logfields.Identity: numericID}).Warning("UpdateIdentities: Deleting a non-existing identity") } } for numericID, lbls := range added { if _, exists := sc.idCache[numericID]; exists { log.WithFields(logrus.Fields{logfields.Identity: numericID}).Warning("UpdateIdentities: Adding an existing identity") } sc.idCache[numericID] = lbls } // Iterate through all locally used identity selectors and // update the cached numeric identities as required. for _, sel := range sc.selectors { var adds, dels []identity.NumericIdentity switch idSel := sel.(type) { case *labelIdentitySelector: for numericID := range deleted { if _, exists := idSel.cachedSelections[numericID]; exists { dels = append(dels, numericID) delete(idSel.cachedSelections, numericID) } } for numericID, lbls := range added { if _, exists := idSel.cachedSelections[numericID]; !exists { if idSel.selector.Matches(lbls) { adds = append(adds, numericID) idSel.cachedSelections[numericID] = struct{}{} } } } if len(dels)+len(adds) > 0 { idSel.updateSelections() idSel.notifyUsers(adds, dels) } case *fqdnSelector: // TODO } } }
[ "func", "(", "sc", "*", "SelectorCache", ")", "UpdateIdentities", "(", "added", ",", "deleted", "cache", ".", "IdentityCache", ")", "{", "sc", ".", "mutex", ".", "Lock", "(", ")", "\n", "defer", "sc", ".", "mutex", ".", "Unlock", "(", ")", "\n\n", "// Update idCache so that newly added selectors get", "// prepopulated with all matching numeric identities.", "for", "numericID", ":=", "range", "deleted", "{", "if", "_", ",", "exists", ":=", "sc", ".", "idCache", "[", "numericID", "]", ";", "exists", "{", "delete", "(", "sc", ".", "idCache", ",", "numericID", ")", "\n", "}", "else", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "Identity", ":", "numericID", "}", ")", ".", "Warning", "(", "\"", "\"", ")", "\n", "}", "\n", "}", "\n", "for", "numericID", ",", "lbls", ":=", "range", "added", "{", "if", "_", ",", "exists", ":=", "sc", ".", "idCache", "[", "numericID", "]", ";", "exists", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "Identity", ":", "numericID", "}", ")", ".", "Warning", "(", "\"", "\"", ")", "\n", "}", "\n", "sc", ".", "idCache", "[", "numericID", "]", "=", "lbls", "\n", "}", "\n\n", "// Iterate through all locally used identity selectors and", "// update the cached numeric identities as required.", "for", "_", ",", "sel", ":=", "range", "sc", ".", "selectors", "{", "var", "adds", ",", "dels", "[", "]", "identity", ".", "NumericIdentity", "\n", "switch", "idSel", ":=", "sel", ".", "(", "type", ")", "{", "case", "*", "labelIdentitySelector", ":", "for", "numericID", ":=", "range", "deleted", "{", "if", "_", ",", "exists", ":=", "idSel", ".", "cachedSelections", "[", "numericID", "]", ";", "exists", "{", "dels", "=", "append", "(", "dels", ",", "numericID", ")", "\n", "delete", "(", "idSel", ".", "cachedSelections", ",", "numericID", ")", "\n", "}", "\n", "}", "\n", "for", "numericID", ",", "lbls", ":=", "range", "added", "{", "if", "_", ",", "exists", ":=", "idSel", ".", "cachedSelections", "[", "numericID", "]", ";", "!", "exists", "{", "if", "idSel", ".", "selector", ".", "Matches", "(", "lbls", ")", "{", "adds", "=", "append", "(", "adds", ",", "numericID", ")", "\n", "idSel", ".", "cachedSelections", "[", "numericID", "]", "=", "struct", "{", "}", "{", "}", "\n", "}", "\n", "}", "\n", "}", "\n", "if", "len", "(", "dels", ")", "+", "len", "(", "adds", ")", ">", "0", "{", "idSel", ".", "updateSelections", "(", ")", "\n", "idSel", ".", "notifyUsers", "(", "adds", ",", "dels", ")", "\n", "}", "\n", "case", "*", "fqdnSelector", ":", "// TODO", "}", "\n", "}", "\n", "}" ]
// UpdateIdentities propagates identity updates to selectors
[ "UpdateIdentities", "propagates", "identity", "updates", "to", "selectors" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/selectorcache.go#L273-L321
163,279
cilium/cilium
pkg/policy/selectorcache.go
AddIdentitySelector
func AddIdentitySelector(user CachedSelectionUser, selector api.EndpointSelector) (cachedSelector CachedSelector, added bool) { return selectorCache.AddIdentitySelector(user, selector) }
go
func AddIdentitySelector(user CachedSelectionUser, selector api.EndpointSelector) (cachedSelector CachedSelector, added bool) { return selectorCache.AddIdentitySelector(user, selector) }
[ "func", "AddIdentitySelector", "(", "user", "CachedSelectionUser", ",", "selector", "api", ".", "EndpointSelector", ")", "(", "cachedSelector", "CachedSelector", ",", "added", "bool", ")", "{", "return", "selectorCache", ".", "AddIdentitySelector", "(", "user", ",", "selector", ")", "\n", "}" ]
// Export global functions to interface with the global selector cache // AddIdentitySelector adds the given api.EndpointSelector in to the // selector cache. If an identical EndpointSelector has already been // cached, the corresponding CachedSelector is returned, otherwise one // is created and added to the cache.
[ "Export", "global", "functions", "to", "interface", "with", "the", "global", "selector", "cache", "AddIdentitySelector", "adds", "the", "given", "api", ".", "EndpointSelector", "in", "to", "the", "selector", "cache", ".", "If", "an", "identical", "EndpointSelector", "has", "already", "been", "cached", "the", "corresponding", "CachedSelector", "is", "returned", "otherwise", "one", "is", "created", "and", "added", "to", "the", "cache", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/policy/selectorcache.go#L329-L331
163,280
cilium/cilium
api/v1/server/restapi/ipam/delete_ip_a_m_ip.go
NewDeleteIPAMIP
func NewDeleteIPAMIP(ctx *middleware.Context, handler DeleteIPAMIPHandler) *DeleteIPAMIP { return &DeleteIPAMIP{Context: ctx, Handler: handler} }
go
func NewDeleteIPAMIP(ctx *middleware.Context, handler DeleteIPAMIPHandler) *DeleteIPAMIP { return &DeleteIPAMIP{Context: ctx, Handler: handler} }
[ "func", "NewDeleteIPAMIP", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "DeleteIPAMIPHandler", ")", "*", "DeleteIPAMIP", "{", "return", "&", "DeleteIPAMIP", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewDeleteIPAMIP creates a new http.Handler for the delete IP a m IP operation
[ "NewDeleteIPAMIP", "creates", "a", "new", "http", ".", "Handler", "for", "the", "delete", "IP", "a", "m", "IP", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/ipam/delete_ip_a_m_ip.go#L28-L30
163,281
cilium/cilium
pkg/maps/nat/ipv4.go
String
func (n *NatEntry4) String() string { return fmt.Sprintf("Addr=%s Port=%d Created=%d HostLocal=%d\n", n.Addr, n.Port, n.Created, n.HostLocal) }
go
func (n *NatEntry4) String() string { return fmt.Sprintf("Addr=%s Port=%d Created=%d HostLocal=%d\n", n.Addr, n.Port, n.Created, n.HostLocal) }
[ "func", "(", "n", "*", "NatEntry4", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\\n", "\"", ",", "n", ".", "Addr", ",", "n", ".", "Port", ",", "n", ".", "Created", ",", "n", ".", "HostLocal", ")", "\n", "}" ]
// String returns the readable format.
[ "String", "returns", "the", "readable", "format", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/maps/nat/ipv4.go#L40-L46
163,282
cilium/cilium
api/v1/server/restapi/policy/put_policy.go
NewPutPolicy
func NewPutPolicy(ctx *middleware.Context, handler PutPolicyHandler) *PutPolicy { return &PutPolicy{Context: ctx, Handler: handler} }
go
func NewPutPolicy(ctx *middleware.Context, handler PutPolicyHandler) *PutPolicy { return &PutPolicy{Context: ctx, Handler: handler} }
[ "func", "NewPutPolicy", "(", "ctx", "*", "middleware", ".", "Context", ",", "handler", "PutPolicyHandler", ")", "*", "PutPolicy", "{", "return", "&", "PutPolicy", "{", "Context", ":", "ctx", ",", "Handler", ":", "handler", "}", "\n", "}" ]
// NewPutPolicy creates a new http.Handler for the put policy operation
[ "NewPutPolicy", "creates", "a", "new", "http", ".", "Handler", "for", "the", "put", "policy", "operation" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/server/restapi/policy/put_policy.go#L28-L30
163,283
cilium/cilium
api/v1/models/b_p_f_map_list.go
Validate
func (m *BPFMapList) Validate(formats strfmt.Registry) error { var res []error if err := m.validateMaps(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m *BPFMapList) Validate(formats strfmt.Registry) error { var res []error if err := m.validateMaps(formats); err != nil { res = append(res, err) } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "*", "BPFMapList", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "if", "err", ":=", "m", ".", "validateMaps", "(", "formats", ")", ";", "err", "!=", "nil", "{", "res", "=", "append", "(", "res", ",", "err", ")", "\n", "}", "\n\n", "if", "len", "(", "res", ")", ">", "0", "{", "return", "errors", ".", "CompositeValidationError", "(", "res", "...", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate validates this b p f map list
[ "Validate", "validates", "this", "b", "p", "f", "map", "list" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/b_p_f_map_list.go#L26-L37
163,284
cilium/cilium
pkg/labels/arraylist.go
DeepCopy
func (ls LabelArrayList) DeepCopy() LabelArrayList { if ls == nil { return nil } o := make(LabelArrayList, 0, len(ls)) for _, v := range ls { o = append(o, v.DeepCopy()) } return o }
go
func (ls LabelArrayList) DeepCopy() LabelArrayList { if ls == nil { return nil } o := make(LabelArrayList, 0, len(ls)) for _, v := range ls { o = append(o, v.DeepCopy()) } return o }
[ "func", "(", "ls", "LabelArrayList", ")", "DeepCopy", "(", ")", "LabelArrayList", "{", "if", "ls", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "o", ":=", "make", "(", "LabelArrayList", ",", "0", ",", "len", "(", "ls", ")", ")", "\n", "for", "_", ",", "v", ":=", "range", "ls", "{", "o", "=", "append", "(", "o", ",", "v", ".", "DeepCopy", "(", ")", ")", "\n", "}", "\n", "return", "o", "\n", "}" ]
// DeepCopy returns a deep copy of the LabelArray, with each element also copied.
[ "DeepCopy", "returns", "a", "deep", "copy", "of", "the", "LabelArray", "with", "each", "element", "also", "copied", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/labels/arraylist.go#L22-L32
163,285
cilium/cilium
api/v1/models/endpoint_state.go
Validate
func (m EndpointState) Validate(formats strfmt.Registry) error { var res []error // value enum if err := m.validateEndpointStateEnum("", "body", m); err != nil { return err } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
go
func (m EndpointState) Validate(formats strfmt.Registry) error { var res []error // value enum if err := m.validateEndpointStateEnum("", "body", m); err != nil { return err } if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil }
[ "func", "(", "m", "EndpointState", ")", "Validate", "(", "formats", "strfmt", ".", "Registry", ")", "error", "{", "var", "res", "[", "]", "error", "\n\n", "// value enum", "if", "err", ":=", "m", ".", "validateEndpointStateEnum", "(", "\"", "\"", ",", "\"", "\"", ",", "m", ")", ";", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "len", "(", "res", ")", ">", "0", "{", "return", "errors", ".", "CompositeValidationError", "(", "res", "...", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate validates this endpoint state
[ "Validate", "validates", "this", "endpoint", "state" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/api/v1/models/endpoint_state.go#L72-L84
163,286
cilium/cilium
pkg/workloads/watcher_state.go
handlingContainerID
func (ws *watcherState) handlingContainerID(id string) bool { ws.Lock() defer ws.Unlock() _, handled := ws.events[id] return handled }
go
func (ws *watcherState) handlingContainerID(id string) bool { ws.Lock() defer ws.Unlock() _, handled := ws.events[id] return handled }
[ "func", "(", "ws", "*", "watcherState", ")", "handlingContainerID", "(", "id", "string", ")", "bool", "{", "ws", ".", "Lock", "(", ")", "\n", "defer", "ws", ".", "Unlock", "(", ")", "\n\n", "_", ",", "handled", ":=", "ws", ".", "events", "[", "id", "]", "\n", "return", "handled", "\n", "}" ]
// handlingContainerID returns whether there is a goroutine already consuming // events for this id
[ "handlingContainerID", "returns", "whether", "there", "is", "a", "goroutine", "already", "consuming", "events", "for", "this", "id" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/watcher_state.go#L111-L117
163,287
cilium/cilium
pkg/workloads/watcher_state.go
reapEmpty
func (ws *watcherState) reapEmpty() { ws.Lock() defer ws.Unlock() for id, q := range ws.events { if len(q) == 0 { close(q) delete(ws.events, id) } } }
go
func (ws *watcherState) reapEmpty() { ws.Lock() defer ws.Unlock() for id, q := range ws.events { if len(q) == 0 { close(q) delete(ws.events, id) } } }
[ "func", "(", "ws", "*", "watcherState", ")", "reapEmpty", "(", ")", "{", "ws", ".", "Lock", "(", ")", "\n", "defer", "ws", ".", "Unlock", "(", ")", "\n\n", "for", "id", ",", "q", ":=", "range", "ws", ".", "events", "{", "if", "len", "(", "q", ")", "==", "0", "{", "close", "(", "q", ")", "\n", "delete", "(", "ws", ".", "events", ",", "id", ")", "\n", "}", "\n", "}", "\n", "}" ]
// reapEmpty deletes empty queues from the map. This also causes the handler // goroutines to exit. It is expected to be called periodically to avoid the // map growing over time.
[ "reapEmpty", "deletes", "empty", "queues", "from", "the", "map", ".", "This", "also", "causes", "the", "handler", "goroutines", "to", "exit", ".", "It", "is", "expected", "to", "be", "called", "periodically", "to", "avoid", "the", "map", "growing", "over", "time", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/watcher_state.go#L122-L132
163,288
cilium/cilium
pkg/workloads/watcher_state.go
syncWithRuntime
func (ws *watcherState) syncWithRuntime() { var wg sync.WaitGroup timeoutCtx, cancel := ctx.WithTimeout(ctx.Background(), 10*time.Second) defer cancel() cList, err := Client().workloadIDsList(timeoutCtx) if err != nil { log.WithError(err).Error("Failed to retrieve the container list") return } for _, contID := range cList { if ignoredContainer(contID) { continue } if alreadyHandled := ws.handlingContainerID(contID); !alreadyHandled { log.WithFields(logrus.Fields{ logfields.ContainerID: shortContainerID(contID), }).Debug("Found unwatched container") wg.Add(1) go func(wg *sync.WaitGroup, id string) { defer wg.Done() Client().handleCreateWorkload(id, false) }(&wg, contID) } } // Wait for all spawned go routines handling container creations to exit wg.Wait() }
go
func (ws *watcherState) syncWithRuntime() { var wg sync.WaitGroup timeoutCtx, cancel := ctx.WithTimeout(ctx.Background(), 10*time.Second) defer cancel() cList, err := Client().workloadIDsList(timeoutCtx) if err != nil { log.WithError(err).Error("Failed to retrieve the container list") return } for _, contID := range cList { if ignoredContainer(contID) { continue } if alreadyHandled := ws.handlingContainerID(contID); !alreadyHandled { log.WithFields(logrus.Fields{ logfields.ContainerID: shortContainerID(contID), }).Debug("Found unwatched container") wg.Add(1) go func(wg *sync.WaitGroup, id string) { defer wg.Done() Client().handleCreateWorkload(id, false) }(&wg, contID) } } // Wait for all spawned go routines handling container creations to exit wg.Wait() }
[ "func", "(", "ws", "*", "watcherState", ")", "syncWithRuntime", "(", ")", "{", "var", "wg", "sync", ".", "WaitGroup", "\n\n", "timeoutCtx", ",", "cancel", ":=", "ctx", ".", "WithTimeout", "(", "ctx", ".", "Background", "(", ")", ",", "10", "*", "time", ".", "Second", ")", "\n", "defer", "cancel", "(", ")", "\n\n", "cList", ",", "err", ":=", "Client", "(", ")", ".", "workloadIDsList", "(", "timeoutCtx", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "WithError", "(", "err", ")", ".", "Error", "(", "\"", "\"", ")", "\n", "return", "\n", "}", "\n", "for", "_", ",", "contID", ":=", "range", "cList", "{", "if", "ignoredContainer", "(", "contID", ")", "{", "continue", "\n", "}", "\n\n", "if", "alreadyHandled", ":=", "ws", ".", "handlingContainerID", "(", "contID", ")", ";", "!", "alreadyHandled", "{", "log", ".", "WithFields", "(", "logrus", ".", "Fields", "{", "logfields", ".", "ContainerID", ":", "shortContainerID", "(", "contID", ")", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", "wg", "*", "sync", ".", "WaitGroup", ",", "id", "string", ")", "{", "defer", "wg", ".", "Done", "(", ")", "\n", "Client", "(", ")", ".", "handleCreateWorkload", "(", "id", ",", "false", ")", "\n", "}", "(", "&", "wg", ",", "contID", ")", "\n", "}", "\n", "}", "\n\n", "// Wait for all spawned go routines handling container creations to exit", "wg", ".", "Wait", "(", ")", "\n", "}" ]
// syncWithRuntime is used by the daemon to synchronize changes between Docker and // Cilium. This includes identities, labels, etc.
[ "syncWithRuntime", "is", "used", "by", "the", "daemon", "to", "synchronize", "changes", "between", "Docker", "and", "Cilium", ".", "This", "includes", "identities", "labels", "etc", "." ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/workloads/watcher_state.go#L136-L167
163,289
cilium/cilium
pkg/ipam/ipam.go
NewIPAM
func NewIPAM(nodeAddressing datapath.NodeAddressing, c Configuration) *IPAM { ipam := &IPAM{ nodeAddressing: nodeAddressing, config: c, owner: map[string]string{}, } if c.EnableIPv6 { ipam.IPv6Allocator = ipallocator.NewCIDRRange(nodeAddressing.IPv6().AllocationCIDR().IPNet) } if c.EnableIPv4 { ipam.IPv4Allocator = ipallocator.NewCIDRRange(nodeAddressing.IPv4().AllocationCIDR().IPNet) } return ipam }
go
func NewIPAM(nodeAddressing datapath.NodeAddressing, c Configuration) *IPAM { ipam := &IPAM{ nodeAddressing: nodeAddressing, config: c, owner: map[string]string{}, } if c.EnableIPv6 { ipam.IPv6Allocator = ipallocator.NewCIDRRange(nodeAddressing.IPv6().AllocationCIDR().IPNet) } if c.EnableIPv4 { ipam.IPv4Allocator = ipallocator.NewCIDRRange(nodeAddressing.IPv4().AllocationCIDR().IPNet) } return ipam }
[ "func", "NewIPAM", "(", "nodeAddressing", "datapath", ".", "NodeAddressing", ",", "c", "Configuration", ")", "*", "IPAM", "{", "ipam", ":=", "&", "IPAM", "{", "nodeAddressing", ":", "nodeAddressing", ",", "config", ":", "c", ",", "owner", ":", "map", "[", "string", "]", "string", "{", "}", ",", "}", "\n\n", "if", "c", ".", "EnableIPv6", "{", "ipam", ".", "IPv6Allocator", "=", "ipallocator", ".", "NewCIDRRange", "(", "nodeAddressing", ".", "IPv6", "(", ")", ".", "AllocationCIDR", "(", ")", ".", "IPNet", ")", "\n", "}", "\n\n", "if", "c", ".", "EnableIPv4", "{", "ipam", ".", "IPv4Allocator", "=", "ipallocator", ".", "NewCIDRRange", "(", "nodeAddressing", ".", "IPv4", "(", ")", ".", "AllocationCIDR", "(", ")", ".", "IPNet", ")", "\n", "}", "\n\n", "return", "ipam", "\n", "}" ]
// NewIPAM returns a new IP address manager
[ "NewIPAM", "returns", "a", "new", "IP", "address", "manager" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/ipam/ipam.go#L52-L68
163,290
cilium/cilium
pkg/client/endpoint.go
EndpointList
func (c *Client) EndpointList() ([]*models.Endpoint, error) { resp, err := c.Endpoint.GetEndpoint(nil) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) EndpointList() ([]*models.Endpoint, error) { resp, err := c.Endpoint.GetEndpoint(nil) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "EndpointList", "(", ")", "(", "[", "]", "*", "models", ".", "Endpoint", ",", "error", ")", "{", "resp", ",", "err", ":=", "c", ".", "Endpoint", ".", "GetEndpoint", "(", "nil", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Hint", "(", "err", ")", "\n", "}", "\n", "return", "resp", ".", "Payload", ",", "nil", "\n", "}" ]
// EndpointList returns a list of all endpoints
[ "EndpointList", "returns", "a", "list", "of", "all", "endpoints" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L26-L32
163,291
cilium/cilium
pkg/client/endpoint.go
EndpointGet
func (c *Client) EndpointGet(id string) (*models.Endpoint, error) { params := endpoint.NewGetEndpointIDParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointID(params) if err != nil { /* Since plugins rely on checking the error type, we don't wrap this * with Hint(...) */ return nil, err } return resp.Payload, nil }
go
func (c *Client) EndpointGet(id string) (*models.Endpoint, error) { params := endpoint.NewGetEndpointIDParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointID(params) if err != nil { /* Since plugins rely on checking the error type, we don't wrap this * with Hint(...) */ return nil, err } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "EndpointGet", "(", "id", "string", ")", "(", "*", "models", ".", "Endpoint", ",", "error", ")", "{", "params", ":=", "endpoint", ".", "NewGetEndpointIDParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Endpoint", ".", "GetEndpointID", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "/* Since plugins rely on checking the error type, we don't wrap this\n\t\t * with Hint(...)\n\t\t */", "return", "nil", ",", "err", "\n", "}", "\n", "return", "resp", ".", "Payload", ",", "nil", "\n", "}" ]
// EndpointGet returns endpoint by ID
[ "EndpointGet", "returns", "endpoint", "by", "ID" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L35-L45
163,292
cilium/cilium
pkg/client/endpoint.go
EndpointCreate
func (c *Client) EndpointCreate(ep *models.EndpointChangeRequest) error { id := pkgEndpointID.NewCiliumID(ep.ID) params := endpoint.NewPutEndpointIDParams().WithID(id).WithEndpoint(ep).WithTimeout(api.ClientTimeout) _, err := c.Endpoint.PutEndpointID(params) return Hint(err) }
go
func (c *Client) EndpointCreate(ep *models.EndpointChangeRequest) error { id := pkgEndpointID.NewCiliumID(ep.ID) params := endpoint.NewPutEndpointIDParams().WithID(id).WithEndpoint(ep).WithTimeout(api.ClientTimeout) _, err := c.Endpoint.PutEndpointID(params) return Hint(err) }
[ "func", "(", "c", "*", "Client", ")", "EndpointCreate", "(", "ep", "*", "models", ".", "EndpointChangeRequest", ")", "error", "{", "id", ":=", "pkgEndpointID", ".", "NewCiliumID", "(", "ep", ".", "ID", ")", "\n", "params", ":=", "endpoint", ".", "NewPutEndpointIDParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithEndpoint", "(", "ep", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "_", ",", "err", ":=", "c", ".", "Endpoint", ".", "PutEndpointID", "(", "params", ")", "\n", "return", "Hint", "(", "err", ")", "\n", "}" ]
// EndpointCreate creates a new endpoint
[ "EndpointCreate", "creates", "a", "new", "endpoint" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L48-L53
163,293
cilium/cilium
pkg/client/endpoint.go
EndpointPatch
func (c *Client) EndpointPatch(id string, ep *models.EndpointChangeRequest) error { params := endpoint.NewPatchEndpointIDParams().WithID(id).WithEndpoint(ep).WithTimeout(api.ClientTimeout) _, err := c.Endpoint.PatchEndpointID(params) return Hint(err) }
go
func (c *Client) EndpointPatch(id string, ep *models.EndpointChangeRequest) error { params := endpoint.NewPatchEndpointIDParams().WithID(id).WithEndpoint(ep).WithTimeout(api.ClientTimeout) _, err := c.Endpoint.PatchEndpointID(params) return Hint(err) }
[ "func", "(", "c", "*", "Client", ")", "EndpointPatch", "(", "id", "string", ",", "ep", "*", "models", ".", "EndpointChangeRequest", ")", "error", "{", "params", ":=", "endpoint", ".", "NewPatchEndpointIDParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithEndpoint", "(", "ep", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "_", ",", "err", ":=", "c", ".", "Endpoint", ".", "PatchEndpointID", "(", "params", ")", "\n", "return", "Hint", "(", "err", ")", "\n", "}" ]
// EndpointPatch modifies the endpoint
[ "EndpointPatch", "modifies", "the", "endpoint" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L56-L60
163,294
cilium/cilium
pkg/client/endpoint.go
EndpointDelete
func (c *Client) EndpointDelete(id string) error { params := endpoint.NewDeleteEndpointIDParams().WithID(id).WithTimeout(api.ClientTimeout) _, _, err := c.Endpoint.DeleteEndpointID(params) return Hint(err) }
go
func (c *Client) EndpointDelete(id string) error { params := endpoint.NewDeleteEndpointIDParams().WithID(id).WithTimeout(api.ClientTimeout) _, _, err := c.Endpoint.DeleteEndpointID(params) return Hint(err) }
[ "func", "(", "c", "*", "Client", ")", "EndpointDelete", "(", "id", "string", ")", "error", "{", "params", ":=", "endpoint", ".", "NewDeleteEndpointIDParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "_", ",", "_", ",", "err", ":=", "c", ".", "Endpoint", ".", "DeleteEndpointID", "(", "params", ")", "\n", "return", "Hint", "(", "err", ")", "\n", "}" ]
// EndpointDelete deletes endpoint
[ "EndpointDelete", "deletes", "endpoint" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L63-L67
163,295
cilium/cilium
pkg/client/endpoint.go
EndpointLogGet
func (c *Client) EndpointLogGet(id string) (models.EndpointStatusLog, error) { params := endpoint.NewGetEndpointIDLogParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDLog(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) EndpointLogGet(id string) (models.EndpointStatusLog, error) { params := endpoint.NewGetEndpointIDLogParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDLog(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "EndpointLogGet", "(", "id", "string", ")", "(", "models", ".", "EndpointStatusLog", ",", "error", ")", "{", "params", ":=", "endpoint", ".", "NewGetEndpointIDLogParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Endpoint", ".", "GetEndpointIDLog", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Hint", "(", "err", ")", "\n", "}", "\n", "return", "resp", ".", "Payload", ",", "nil", "\n", "}" ]
// EndpointLogGet returns endpoint log
[ "EndpointLogGet", "returns", "endpoint", "log" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L70-L77
163,296
cilium/cilium
pkg/client/endpoint.go
EndpointHealthGet
func (c *Client) EndpointHealthGet(id string) (*models.EndpointHealth, error) { params := endpoint.NewGetEndpointIDHealthzParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDHealthz(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) EndpointHealthGet(id string) (*models.EndpointHealth, error) { params := endpoint.NewGetEndpointIDHealthzParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDHealthz(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "EndpointHealthGet", "(", "id", "string", ")", "(", "*", "models", ".", "EndpointHealth", ",", "error", ")", "{", "params", ":=", "endpoint", ".", "NewGetEndpointIDHealthzParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Endpoint", ".", "GetEndpointIDHealthz", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Hint", "(", "err", ")", "\n", "}", "\n", "return", "resp", ".", "Payload", ",", "nil", "\n", "}" ]
// EndpointHealthGet returns endpoint healthz
[ "EndpointHealthGet", "returns", "endpoint", "healthz" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L80-L87
163,297
cilium/cilium
pkg/client/endpoint.go
EndpointConfigGet
func (c *Client) EndpointConfigGet(id string) (*models.EndpointConfigurationStatus, error) { params := endpoint.NewGetEndpointIDConfigParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDConfig(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) EndpointConfigGet(id string) (*models.EndpointConfigurationStatus, error) { params := endpoint.NewGetEndpointIDConfigParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDConfig(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "EndpointConfigGet", "(", "id", "string", ")", "(", "*", "models", ".", "EndpointConfigurationStatus", ",", "error", ")", "{", "params", ":=", "endpoint", ".", "NewGetEndpointIDConfigParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Endpoint", ".", "GetEndpointIDConfig", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Hint", "(", "err", ")", "\n", "}", "\n", "return", "resp", ".", "Payload", ",", "nil", "\n", "}" ]
// EndpointConfigGet returns endpoint configuration
[ "EndpointConfigGet", "returns", "endpoint", "configuration" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L90-L97
163,298
cilium/cilium
pkg/client/endpoint.go
EndpointConfigPatch
func (c *Client) EndpointConfigPatch(id string, cfg *models.EndpointConfigurationSpec) error { params := endpoint.NewPatchEndpointIDConfigParams().WithID(id).WithTimeout(api.ClientTimeout) if cfg != nil { params.SetEndpointConfiguration(cfg) } _, err := c.Endpoint.PatchEndpointIDConfig(params) return Hint(err) }
go
func (c *Client) EndpointConfigPatch(id string, cfg *models.EndpointConfigurationSpec) error { params := endpoint.NewPatchEndpointIDConfigParams().WithID(id).WithTimeout(api.ClientTimeout) if cfg != nil { params.SetEndpointConfiguration(cfg) } _, err := c.Endpoint.PatchEndpointIDConfig(params) return Hint(err) }
[ "func", "(", "c", "*", "Client", ")", "EndpointConfigPatch", "(", "id", "string", ",", "cfg", "*", "models", ".", "EndpointConfigurationSpec", ")", "error", "{", "params", ":=", "endpoint", ".", "NewPatchEndpointIDConfigParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "if", "cfg", "!=", "nil", "{", "params", ".", "SetEndpointConfiguration", "(", "cfg", ")", "\n", "}", "\n\n", "_", ",", "err", ":=", "c", ".", "Endpoint", ".", "PatchEndpointIDConfig", "(", "params", ")", "\n", "return", "Hint", "(", "err", ")", "\n", "}" ]
// EndpointConfigPatch modifies endpoint configuration
[ "EndpointConfigPatch", "modifies", "endpoint", "configuration" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L100-L108
163,299
cilium/cilium
pkg/client/endpoint.go
EndpointLabelsGet
func (c *Client) EndpointLabelsGet(id string) (*models.LabelConfiguration, error) { params := endpoint.NewGetEndpointIDLabelsParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDLabels(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
go
func (c *Client) EndpointLabelsGet(id string) (*models.LabelConfiguration, error) { params := endpoint.NewGetEndpointIDLabelsParams().WithID(id).WithTimeout(api.ClientTimeout) resp, err := c.Endpoint.GetEndpointIDLabels(params) if err != nil { return nil, Hint(err) } return resp.Payload, nil }
[ "func", "(", "c", "*", "Client", ")", "EndpointLabelsGet", "(", "id", "string", ")", "(", "*", "models", ".", "LabelConfiguration", ",", "error", ")", "{", "params", ":=", "endpoint", ".", "NewGetEndpointIDLabelsParams", "(", ")", ".", "WithID", "(", "id", ")", ".", "WithTimeout", "(", "api", ".", "ClientTimeout", ")", "\n", "resp", ",", "err", ":=", "c", ".", "Endpoint", ".", "GetEndpointIDLabels", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Hint", "(", "err", ")", "\n", "}", "\n", "return", "resp", ".", "Payload", ",", "nil", "\n", "}" ]
// EndpointLabelsGet returns endpoint label configuration
[ "EndpointLabelsGet", "returns", "endpoint", "label", "configuration" ]
6ecfff82c2314dd9d847645361b57e2646eed64b
https://github.com/cilium/cilium/blob/6ecfff82c2314dd9d847645361b57e2646eed64b/pkg/client/endpoint.go#L111-L118